Hi All:
I would like to know if I can loop my selection in a combobox. For
instance, I got 8 items in a combobox, and when I selected it using the up
and down arrow, it will stop in the first record even I keep on press the up
arrow, on the other hand, if it's the last selection, it will stop in the
last record even I keep on press the down arrow. Is there any way that if I
keep on press the up or down arrow, the slection in it will keep on moving
such as if i am at the first record, and I press the up asrrow, then it will
goto the last selection record, another way is, if i am at the last record
and I keep on press the down arrow, it will goback to the first record. Hope
someone can help me out!
Best rgds,
Ivan Vong
--
Message posted via http://www.dotnetmonster.com 3 1663
Ivan, I would like to know if I can loop my selection in a combobox. For instance, I got 8 items in a combobox, and when I selected it using the up and down arrow, it will stop in the first record even I keep on press the up arrow, on the other hand, if it's the last selection, it will stop in the last record even I keep on press the down arrow. Is there any way that if I keep on press the up or down arrow, the slection in it will keep on moving such as if i am at the first record, and I press the up asrrow, then it will goto the last selection record, another way is, if i am at the last record and I keep on press the down arrow, it will goback to the first record. Hope someone can help me out!
What do you mean with a down and with an up arrow from a combobox?
I can also not understand how you would achieve this with a combobox, with a
listbox I can understand it with some extra buttons on a form or with an
extra scrollbar
Cor
"Ivan V via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message news:52***********@DotNetMonster.com... Hi All:
I would like to know if I can loop my selection in a combobox. For instance, I got 8 items in a combobox, and when I selected it using the up and down arrow, it will stop in the first record even I keep on press the up arrow, on the other hand, if it's the last selection, it will stop in the last record even I keep on press the down arrow. Is there any way that if I keep on press the up or down arrow, the slection in it will keep on moving such as if i am at the first record, and I press the up asrrow, then it will goto the last selection record, another way is, if i am at the last record and I keep on press the down arrow, it will goback to the first record. Hope someone can help me out!
Best rgds, Ivan Vong
-- Message posted via http://www.dotnetmonster.com
Assuming you have a ComboBox named ComboBox1 on a form and it has items in the Items collection, I think this may give you a start.
/////
Private Sub ComboBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown
Dim cbo As ComboBox = DirectCast(sender, ComboBox)
If e.KeyCode = Keys.Down Then
If cbo.SelectedIndex < cbo.Items.Count - 1 Then
cbo.SelectedIndex += 1
ElseIf cbo.SelectedIndex = cbo.Items.Count - 1 Then
cbo.SelectedIndex = 0
End If
e.Handled = True
ElseIf e.KeyCode = Keys.Up Then
If cbo.SelectedIndex > 0 Then
cbo.SelectedIndex -= 1
ElseIf cbo.SelectedIndex = 0 Then
cbo.SelectedIndex = cbo.Items.Count - 1
End If
e.Handled = True
End If
End Sub
\\\\\\
I'm sure you will need to clean it up abit and tailor it to suite your needs, but it's a start.
--
Al Reid
"Ivan V via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:52***********@DotNetMonster.com... if i am at the first record, and I press the up asrrow, then it will goto the last selection record, another way is, if i am at the last record and I keep on press the down arrow, it will goback to the first record.
Try handling the KeyUp Event on the ComboBox : (air-code)
Private Sub Combo1_KeyUp(sender ..., e ...) _
Handles Combo1.KeyUp
With Combo1
If e.KeyCode = Keys.Up _
And .SelectedIndex = 0 _
Then
.SelectedIndex = .Items.Count - 1
e.Handled = True
ElseIf e.KeyCode = Keys.Down _
And .SelectedIndex = .Items.Count - 1 _
Then
.SelectedIndex = 0
e.Handled = True
End If
End With
End Sub
HTH,
Phill W. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: - ions |
last post by:
Hi, im a just wondering how to add elements into a JComboBox through a
loop ie. just say i wanted to add the numbers 1 throught to 100. It
seems easy but im having a bit of trouble. One problem...
|
by: Nicolae Fieraru |
last post by:
Hi All,
I am trying to change the rowsource of a combobox when I click on it. I
played with many events, associated with the form and the combobox, but
still haven't figured out what is the way...
|
by: NCrum |
last post by:
I have a while loop which seems to run twice, I call one routine from another
once the first loop is completed it returns to the calling routine (the line
above) and runs again
Calling routine()...
|
by: TT (Tom Tempelaere) |
last post by:
Hay there,
I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one
(I hope .NET 2.0 supplies one). I based it on this article:...
|
by: kberry |
last post by:
I am clearing Textboxes on a form... this is loop I have came up with
but was wondering if it can be shorter or not as long... Can anyone
help?
Dim controlOnForm As Control 'Places a control...
|
by: Rejimonb |
last post by:
Can I fill a combobox without using a loop. Using a loop will be time consuming.
Reji
|
by: SkyTV |
last post by:
i have got 15 combo Boxs on the form
they are named cbo1 - cbo15
the following works just fun
strY= cbo1.Text;
but i wanna learn the for loop way to do it....
i have tried many...
|
by: jbott59 |
last post by:
I have 10 comboboxes. i would like to run a loop that would reference each combo box and resets certain values. The comboboxes are named ComboBox1, Combobox2, ..... ComboBox10. Here is a sample of...
|
by: cmdolcet69 |
last post by:
I need to loop through a index change event, however whenever i loop
through the first combo box always report back correctly its when i
move to the next combobox, that instead of changing the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |