From: Onur Güzel on 16 Jun 2010 14:17 On Jun 15, 9:52 pm, sid <sidwe...(a)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
From: sid on 16 Jun 2010 16:15 On Jun 16, 1:17 pm, Onur Güzel <kimiraikkone...(a)gmail.com> wrote: > On Jun 15, 9:52 pm, sid <sidwe...(a)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.
From: Onur Güzel on 17 Jun 2010 02:25 On Jun 16, 11:15 pm, sid <sidwe...(a)alexian.net> wrote: > On Jun 16, 1:17 pm, Onur Güzel <kimiraikkone...(a)gmail.com> wrote: > > > > > On Jun 15, 9:52 pm, sid <sidwe...(a)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
From: sid on 17 Jun 2010 16:27 On Jun 17, 1:25 am, Onur Güzel <kimiraikkone...(a)gmail.com> wrote: > On Jun 16, 11:15 pm, sid <sidwe...(a)alexian.net> wrote: > > > > > > > On Jun 16, 1:17 pm, Onur Güzel <kimiraikkone...(a)gmail.com> wrote: > > > > On Jun 15, 9:52 pm, sid <sidwe...(a)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
From: Onur Güzel on 19 Jun 2010 17:18 On Jun 17, 11:27 pm, sid <sidwe...(a)alexian.net> wrote: > On Jun 17, 1:25 am, Onur Güzel <kimiraikkone...(a)gmail.com> wrote: > > > > > On Jun 16, 11:15 pm, sid <sidwe...(a)alexian.net> wrote: > > > > On Jun 16, 1:17 pm, Onur Güzel <kimiraikkone...(a)gmail.com> wrote: > > > > > On Jun 15, 9:52 pm, sid <sidwe...(a)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 Glad it worked, cheers, Onur
First
|
Prev
|
Pages: 1 2 Prev: only one instance of a typed Dataset Next: insert control to parent at reverse order. |