Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 834
βӔḺṪẶⱫŌŔ Avatar asked May 14 '11 21:05

βӔḺṪẶⱫŌŔ


4 Answers

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;
like image 82
IAmTimCorey Avatar answered Oct 13 '22 22:10

IAmTimCorey


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.

like image 44
Peter B Avatar answered Oct 13 '22 22:10

Peter B


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;
  }
}
like image 33
new bie Avatar answered Oct 13 '22 22:10

new bie


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

like image 40
javaguy512 Avatar answered Oct 13 '22 21:10

javaguy512