Home All Groups Group Topic Archive Search About

Disable the search feature of a ComboBox

Author
15 Jun 2010 6:52 PM
sid
Using the following code snip in VB.net, When I start the app and
pulldown the list from the combox box it tries to make a selection.
But I don't want this feature. How do I prevent it.
Why is the first item of the list selected as soon as the pulldown
drops ?


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

        Dim i As Integer

        For i = 0 To 5
            Me.ComboBox1.Items.Add(Chr(65 + i) & "- " & Format(i,
"00"))
        Next
        Me.ComboBox1.Text = "A"

End Sub

Author
15 Jun 2010 9:37 PM
Mr. Arnold
sid wrote:
Show quoteHide quote
> Using the following code snip in VB.net, When I start the app and
> pulldown the list from the combox box it tries to make a selection.
> But I don't want this feature. How do I prevent it.
> Why is the first item of the list selected as soon as the pulldown
> drops ?
>
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
>         Dim i As Integer
>
>         For i = 0 To 5
>             Me.ComboBox1.Items.Add(Chr(65 + i) & "- " & Format(i,
> "00"))
>         Next
>         Me.ComboBox1.Text = "A"

           Me.ComboBox1.SelectedIndex = -1   -- to deselect combobox you
may have to execute the deselect statement twice.
Show quoteHide quote
>
> End Sub
Author
16 Jun 2010 1:37 AM
sid
Show quote Hide quote
On Jun 15, 4:37 pm, "Mr. Arnold" <Arn***@Arnold.com> wrote:
> sid wrote:
> > Using the following code snip in VB.net, When I start the app and
> > pulldown the list from the combox box it tries to make a selection.
> > But I don't want this feature. How do I prevent it.
> > Why is the first item of the list selected as soon as the pulldown
> > drops ?
>
> > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
>
> >         Dim i As Integer
>
> >         For i = 0 To 5
> >             Me.ComboBox1.Items.Add(Chr(65 + i) & "- " & Format(i,
> > "00"))
> >         Next
> >         Me.ComboBox1.Text = "A"
>
>            Me.ComboBox1.SelectedIndex = -1   -- to deselect combobox you
> may have to execute the deselect statement twice.
>
>
>
>
>
> > End Sub- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

I have already tried this without any success.
The autoselection is made when the list is opened, then the text field
is populated with whatever selection is the closest match.

I want to give the user the option to browse the selections with out
actually choosing one, and then they can choose or manually type an
entry in the text field.
Author
16 Jun 2010 6:52 AM
Cor Ligthert[MVP]
It seems that you have set at design time the autocomplete property.


Show quoteHide quote
"sid" <sidwe***@alexian.net> wrote in message
news:0c2d4abf-5f2c-4bc9-ab84-eccf8bd81b2a@c10g2000yqi.googlegroups.com...
> Using the following code snip in VB.net, When I start the app and
> pulldown the list from the combox box it tries to make a selection.
> But I don't want this feature. How do I prevent it.
> Why is the first item of the list selected as soon as the pulldown
> drops ?
>
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
>        Dim i As Integer
>
>        For i = 0 To 5
>            Me.ComboBox1.Items.Add(Chr(65 + i) & "- " & Format(i,
> "00"))
>        Next
>        Me.ComboBox1.Text = "A"
>
> End Sub
Author
16 Jun 2010 2:38 PM
sid
Show quote Hide quote
On Jun 16, 1:52 am, "Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl>
wrote:
> It seems that you have set at design time the autocomplete property.
>
> "sid" <sidwe***@alexian.net> wrote in message
>
> news:0c2d4abf-5f2c-4bc9-ab84-eccf8bd81b2a@c10g2000yqi.googlegroups.com...
>
>
>
> > Using the following code snip in VB.net, When I start the app and
> > pulldown the list from the combox box it tries to make a selection.
> > But I don't want this feature. How do I prevent it.
> > Why is the first item of the list selected as soon as the pulldown
> > drops ?
>
> > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
>
> >        Dim i As Integer
>
> >        For i = 0 To 5
> >            Me.ComboBox1.Items.Add(Chr(65 + i) & "- " & Format(i,
> > "00"))
> >        Next
> >        Me.ComboBox1.Text = "A"
>
> > End Sub- Hide quoted text -
>
> - Show quoted text -

No, I set this property to none at desing time and in the code after
the app started.

Private Sub form1_Load(ByVal sender ...
   combobox1.AutocompleteMode = AutoCompleteMode.None
Author
16 Jun 2010 6:17 PM
Onur_Güzel
On Jun 15, 9:52 pm, sid <sidwe***@alexian.net> wrote:
Show quoteHide quote
> Using the following code snip in VB.net, When I start the app and
> pulldown the list from the combox box it tries to make a selection.
> But I don't want this feature. How do I prevent it.
> Why is the first item of the list selected as soon as the pulldown
> drops ?
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
>         Dim i As Integer
>
>         For i = 0 To 5
>             Me.ComboBox1.Items.Add(Chr(65 + i) & "- " & Format(i,
> "00"))
>         Next
>         Me.ComboBox1.Text = "A"
>
> End Sub

Probably your combobox's "DropDownStyle" property was NOT set to
"DropDownList" (Maybe it's "DropDown"). Based on my experiment, the
behaviour doesn't occur if it is a "DropDownList" combobox (No item
gets selected automatically when user clicks on Combobox).

HTH,

Onur Güzel
Author
16 Jun 2010 8:15 PM
sid
On Jun 16, 1:17 pm, Onur Güzel <kimiraikkone***@gmail.com> wrote:
Show quoteHide quote
> On Jun 15, 9:52 pm, sid <sidwe***@alexian.net> wrote:
>
>
>
>
>
> > Using the following code snip in VB.net, When I start the app and
> > pulldown the list from the combox box it tries to make a selection.
> > But I don't want this feature. How do I prevent it.
> > Why is the first item of the list selected as soon as the pulldown
> > drops ?
>
> > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
>
> >         Dim i As Integer
>
> >         For i = 0 To 5
> >             Me.ComboBox1.Items.Add(Chr(65 + i) & "- " & Format(i,
> > "00"))
> >         Next
> >         Me.ComboBox1.Text = "A"
>
> > End Sub
>
> Probably your combobox's "DropDownStyle" property was NOT set to
> "DropDownList" (Maybe it's "DropDown"). Based on my experiment, the
> behaviour doesn't occur if it is a "DropDownList" combobox (No item
> gets selected automatically when user clicks on Combobox).
>
> HTH,
>
> Onur Güzel- Hide quoted text -
>
> - Show quoted text -

Yes, but then you don't get a textbox to type in if you want to make
an entry that is not in the list.
Author
17 Jun 2010 6:25 AM
Onur_Güzel
On Jun 16, 11:15 pm, sid <sidwe***@alexian.net> wrote:
Show quoteHide quote
> On Jun 16, 1:17 pm, Onur Güzel <kimiraikkone***@gmail.com> wrote:
>
>
>
> > On Jun 15, 9:52 pm, sid <sidwe***@alexian.net> wrote:
>
> > > Using the following code snip in VB.net, When I start the app and
> > > pulldown the list from the combox box it tries to make a selection.
> > > But I don't want this feature. How do I prevent it.
> > > Why is the first item of the list selected as soon as the pulldown
> > > drops ?
>
> > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> > > System.EventArgs) Handles MyBase.Load
>
> > >         Dim i As Integer
>
> > >         For i = 0 To 5
> > >             Me.ComboBox1.Items.Add(Chr(65 + i) & "- " & Format(i,
> > > "00"))
> > >         Next
> > >         Me.ComboBox1.Text = "A"
>
> > > End Sub
>
> > Probably your combobox's "DropDownStyle" property was NOT set to
> > "DropDownList" (Maybe it's "DropDown"). Based on my experiment, the
> > behaviour doesn't occur if it is a "DropDownList" combobox (No item
> > gets selected automatically when user clicks on Combobox).
>
> > HTH,
>
> > Onur Güzel- Hide quoted text -
>
> > - Show quoted text -
>
> Yes, but then you don't get a textbox to type in if you want to make
> an entry that is not in the list.

Yes, i have tought that but there's no such event that's fired after
dropdown portion is displayed then we would have chance to change
selectedindex. However, in the code of comobox item population which
you posted , "A-00" gets selected automatically because you're setting
text "A" to combobox. As you want leave DropDownStyle property as
"DropDown", which allows you to edit combox text area with keyboard,
you can overcome this behaviour by adding a textbox above the
combobox, whose height will be same as combobox and width will be less
as much as combobox's drop-down arrow, then you send back the
combobox, in your form_load set text to textbox, rather than combobox:

Like:

Dim i As Integer
For i = 0 To 5
Me.ComboBox1.Items.Add _
(Chr(65 + i) & "- " & Format(i, "00"))
Next
Me.TextBox1.Text = "A"

Finally, of course you must equalise combobox selection with textbox,
if user selects any item in combobox.

Private Sub ComboBox1_SelectedIndexChanged _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles ComboBox1.SelectedIndexChanged
TextBox1.Text = ComboBox1.SelectedItem
End Sub

At this time you will be able to use drop-down portion of combobox but
nobody will see any selection as textbox is in the front. To describe
what i mean, look at the screenshoot which will clarify the trick:

http://img541.imageshack.us/img541/8721/resimnew.jpg

HTH,

Onur Güzel
Author
17 Jun 2010 8:27 PM
sid
On Jun 17, 1:25 am, Onur Güzel <kimiraikkone***@gmail.com> wrote:
Show quoteHide quote
> On Jun 16, 11:15 pm, sid <sidwe***@alexian.net> wrote:
>
>
>
>
>
> > On Jun 16, 1:17 pm, Onur Güzel <kimiraikkone***@gmail.com> wrote:
>
> > > On Jun 15, 9:52 pm, sid <sidwe***@alexian.net> wrote:
>
> > > > Using the following code snip in VB.net, When I start the app and
> > > > pulldown the list from the combox box it tries to make a selection.
> > > > But I don't want this feature. How do I prevent it.
> > > > Why is the first item of the list selected as soon as the pulldown
> > > > drops ?
>
> > > > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> > > > System.EventArgs) Handles MyBase.Load
>
> > > >         Dim i As Integer
>
> > > >         For i = 0 To 5
> > > >             Me.ComboBox1.Items.Add(Chr(65 + i) & "- " & Format(i,
> > > > "00"))
> > > >         Next
> > > >         Me.ComboBox1.Text = "A"
>
> > > > End Sub
>
> > > Probably your combobox's "DropDownStyle" property was NOT set to
> > > "DropDownList" (Maybe it's "DropDown"). Based on my experiment, the
> > > behaviour doesn't occur if it is a "DropDownList" combobox (No item
> > > gets selected automatically when user clicks on Combobox).
>
> > > HTH,
>
> > > Onur Güzel- Hide quoted text -
>
> > > - Show quoted text -
>
> > Yes, but then you don't get a textbox to type in if you want to make
> > an entry that is not in the list.
>
> Yes, i have tought that but there's no such event that's fired after
> dropdown portion is displayed then we would have chance to change
> selectedindex. However, in the code of comobox item population which
> you posted , "A-00" gets selected automatically because you're setting
> text "A" to combobox. As you want leave DropDownStyle property as
> "DropDown", which allows you to edit combox text area with keyboard,
> you can overcome this behaviour by adding a textbox above the
> combobox, whose height will be same as combobox and width will be less
> as much as combobox's drop-down arrow, then you send back the
> combobox, in your form_load set text to textbox, rather than combobox:
>
> Like:
>
> Dim i As Integer
> For i = 0 To 5
> Me.ComboBox1.Items.Add _
> (Chr(65 + i) & "- " & Format(i, "00"))
> Next
> Me.TextBox1.Text = "A"
>
> Finally, of course you must equalise combobox selection with textbox,
> if user selects any item in combobox.
>
> Private Sub ComboBox1_SelectedIndexChanged _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) _
> Handles ComboBox1.SelectedIndexChanged
> TextBox1.Text = ComboBox1.SelectedItem
> End Sub
>
> At this time you will be able to use drop-down portion of combobox but
> nobody will see any selection as textbox is in the front. To describe
> what i mean, look at the screenshoot which will clarify the trick:
>
> http://img541.imageshack.us/img541/8721/resimnew.jpg
>
> HTH,
>
> Onur Güzel- Hide quoted text -
>
> - Show quoted text -

This was a good solution.  I was about to start to create my own
control.
Another programmer had the idea of adding a space to the text on
'DropDown', this fools the Autocomplete by not finding a match, but
this solution was not consistent. Timing issues ...

The floating textbox worked perfectly.

Thanks