views:

680

answers:

4

I have a problem with windows combobox when the style is dropdown.the combox contains two values - "hello" and "Hi". I want to show the default value for my windows combobox is "Hello" when the page gets loaded. Now when the style is DropDown it selects the whole text("hello"), which creates confusion betweem first and third control(as focus is on first control(Textbox) but looks like that focus is in third control which is combbox). can somebody tell me how to resolve it?

A: 

I would try setting your combobox dropdown style to DropDownList and see if that gives you the results you're after

keith
A: 

keith, yeah setting dropdown style to DropDownList works, but the problem is when combobox is in dropdownlist it doesn't allow user to type the char (for search) in combobox rather than on keypress it selects the row based on the keyboar char. wat i m trying to say is tht user should be able to type "hello" in combobox.

A: 

i want to clear the selection of the selected text ( don't want to clear the text). hope it clarifies :)

A: 

I think you are saying that you have a textbox and a combobox. When the form loads, the combobox gets "hello" (the first item) selected. Furthermore, the actual focus is on the textbox when the form loads, so if a user starts you app and begins typing, the text goes into the textbox, but all the text in the combobox is highlighted, so it looks like the user's typing would go into the combobox instead of in the text box, where it actually ends up going.

Does that describe your problem?

If it does, I think you can use the following in your from_load() method:

  comboBox1.SelectedIndex = 0; // Select first item in combo.

  // Uncomment next line if you want no text selected in the 
  // text box and the insertion point and end of textbox text.
  //textBox1.Select(textBox1.Text.Length, 0);

  textBox1.Select(); // Select the textbox.
JeffH