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

TheLethalCoder
  • 6,668
  • 6
  • 34
  • 69
βӔḺṪẶⱫŌŔ
  • 1,276
  • 3
  • 17
  • 33

7 Answers7

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;
IAmTimCorey
  • 16,412
  • 5
  • 39
  • 75
  • 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? – βӔḺṪẶⱫŌŔ May 14 '11 at 21:59
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.

Peter B
  • 22,460
  • 5
  • 32
  • 69
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;
  }
}
new bie
  • 2,745
  • 6
  • 24
  • 26
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. :)

javaguy512
  • 21
  • 1
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...

Taryn
  • 242,637
  • 56
  • 362
  • 405
rubesh.s
  • 11
  • 1
0

I set the TabStop to false and it went away.

bsb
  • 39
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;