1

I have a WindowsForm that contains a lot of UserControl. Each UserControl has a PictureBox, a few TextBox and a Button.

As soon as my program loads, my first TextBox is Highlighted in blue and I don't want that.

In fact I don't want anything to be selected at all.(Buttons, TextBox etc..) I've looked into the properties but I can't find exactly how to totally remove this 'Feature'. All my TextBox are ReadOnly but can become Write/Read while the program is running.

Any Idea how i could do this ?

Thanks in advance.


Update

Changing the TabStop properties to false did part of the job since it doesn't allow selection with tab at all. But I don't want to block the user from using tab to navigate between boxes I just don't want any selection when I run the program. Is there another way ?

Thanks for your time again.

phadaphunk
  • 12,785
  • 15
  • 73
  • 107
  • check in constructor, when all the controls are initialized – Zaki Apr 13 '12 at 14:31
  • I've never really played with the Designer.. What should I be looking for ? In the mainform designer or the usercontrol designer? – phadaphunk Apr 13 '12 at 14:42
  • check the usercontrol designer, it may by there... – Zaki Apr 13 '12 at 14:52
  • @Sam1 I'm still searching in it although the TextBox with the selection problem is declared exactly like all the others. The only difference is that it is the first of the texbox (on top) and as `MultiLine` set to true – phadaphunk Apr 13 '12 at 15:00

3 Answers3

3

On form Load set Focus to any label or any other control which is not tab stop on the form

private void Form1_Load(object sender, EventArgs e)  
{ 
  this.ActiveControl = label1;       
}

How to remove the focus from a TextBox in WinForms?

Community
  • 1
  • 1
Sadaf
  • 592
  • 2
  • 11
0

You need to set TabFocus to false for textboxes etc

//textBox1.TabFocus = false;

textBox1.TabStop = false;
Sadaf
  • 592
  • 2
  • 11
Habib
  • 219,104
  • 29
  • 407
  • 436
0

comboBoxName.SelectedIndex = -1;

sara
  • 1
  • It is usually a good idea to write a little sentence that explains your answer, even if just a courtesy. :-) – pschueller Feb 24 '14 at 10:12