Allright, but setting SelectionStart in GotFocus behind the last character,
or setting SelectionLength to 0 would clear the selection. It won't work if
"Jack Jackson" wrote:
> Thanks.
>
> Putting code in GotFocus and Enter doesn't help, as I am trying to
> find a way to remove the selection that the combobox does every time
> it repaints whether or not the control has focus.
>
> I finally fixed it by clearing the selection when the control gets a
> WM_PAINT message in WndProc.
>
> I find it problematic because when a form first displays all of the
> comboboxes with DropDownStyle = DropDown have their text selected and
> none of the textboxes do. To me that is a confusing visual effect.
> Then as you tab through each combobox the selection gets removed. I'm
> sure my customers would complain about that.
>
> On Mon, 19 May 2008 23:11:01 -0700, Morten Wennevik [C# MVP]
> <MortenWennevik@hotmail.com> wrote:
>
> >Hi Jack,
> >
> >I'm not sure why it does that, although I never found it problematic as a
> >ComboBox isn't a TextBox even though you can sometimes write in it. You can
> >however override the selection in the focus/enter events, but unless you keep
> >track of the cursor position the cursor will for the ComboBox always be at
> >the end.
> >
> > void comboBox1_GotFocus(object sender, EventArgs e)
> > {
> > comboBox1.SelectionStart = comboBox1.Text.Length;
> > }
> >
> > void textBox1_Enter(object sender, EventArgs e)
> > {
> > textBox1.SelectAll();
> > }
> >
> >If you have Visual Studio 2008 you may be able to gain further information
> >by stepping into the ComboBox source code.
> >
> >
http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx