Removing Windows' ugly Selection marker thing from Splitter in SpitContainer Control
Asked Answered
D

7

18

I have a SplitContainer control, and the Splitter in the middle is very ugly. By setting the BackColor of the SplitContainer to (insert color here), then setting the BackColor of Panel1 and Panel2 to white, I can have my splitter looking nice. But by default, Windows puts the selection mark over the Splitter, even before it's selected.

How can I make sure that the selection mark never shows on the Splitter?

enter image description here

Dive answered 14/5, 2011 at 21:49 Comment(1)
How do you want your splitter to look like? How will user know that it is a splitter if you hide its appearance?Alliteration
R
11

I think by "Selection Marker Crap", you mean the fuzzy line that indicates the control is selected. If you don't want this showing up, set some other control to be selected at startup. Something like:

Textbox1.Selected = true;

This should solve your issue if it is just one of it not being selected. However, this will come back if you select the item to resize something. In that case, you could put something in the mouse_up event to move the selection off of the control. That way, the user moves the splitter bar and then when they let go, the selection gets cleared off of the splitter.

Another way would be to make the splitter bar narrow enough that the gray fuzzy line doesn't show up. To do this, you could do the following (tested):

splitContainer1.BorderStyle = BorderStyle.FixedSingle;
splitContainer1.SplitterWidth = 1;
Roundtheclock answered 14/5, 2011 at 21:57 Comment(1)
But I don't want it to be that way at all. Because (obviously) when the user goes to resize the panel with the splitter, it will show up again. But I don't want that. Is there a way to change this behaviour?Snapper
L
7

I experienced the same problem, and fixed it by setting TabStop to False in the Properties window for SplitContainer1.

This could annoy people who depend or insist on using the keyboard to operate every aspect of your form, but other than that it will work. Controls inside the SplitContainer will remain tab-able, just not the SplitContainer itself.

Leffert answered 22/5, 2014 at 15:51 Comment(0)
D
3

This code will move the focus from the splitContainer to TreeView shortly after moved.

private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e) {
  if(this.splitContainer1.CanFocus) {
     this.splitContainer1.ActiveControl = this.treeView1;
  }
}
Dominations answered 28/6, 2011 at 19:34 Comment(0)
P
2

You could add an event handler to steal the focus from the container on MouseUp's... It's a little messy but it works. :)

Pyromania answered 6/6, 2011 at 5:58 Comment(0)
U
1

I tried a lot to remove splitter but nothing work. I did some different why we need to use splitter for that we can use picture box control make it width (or) height depend upon your project set 5 or 3 .... after picture box mouse move event write code like... picturebox property-cursor change the cursor type Hsplit its look like splitter

private void picturebox1_MouseMove(object sender, MouseEventArgs e)
        {

 if (e.Button == MouseButtons.Left)//this for mouse left click its work
            {
//write you code here if you use panel set panel height or width it reaches...

Cursor.Position = new Point(e.X, e.Y); // this for mouse cursor position according your //project  do some fine tune you will get its work... 
}

its work because i tried lot for this and i itself found this method...

Ungracious answered 29/6, 2012 at 12:12 Comment(0)
C
0

I set the TabStop to false and it went away.

Corpulent answered 16/6, 2013 at 19:25 Comment(0)
E
0

Most simple solution i found/made - create a button, select it, and hide it. All via code. there is not side effects or problems with this, place it in the forms load event.

Button DeSelectButton = new Button();
        this.Controls.Add(DeSelectButton);
        DeSelectButton.Select();
        DeSelectButton.Visible = false;
Economics answered 7/3, 2017 at 6:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.