-
January 1st, 2021, 03:09 PM
#1
[RESOLVED] Selectively prevent a combobox from scrolling past a certain point Visual Studio 2012
I have two combo boxes on a form.
Both of them contain the letters A - Z. One is loaded foreword (A-Z), the other backward (Z-A).
They also hold the asterisk (*) symbol. They each have 26 indexes (not counting -1).
Currently when a checkbox is checked, the asterisk symbol is selected for both combo boxes and they are disabled - works great.
If the checkbox is NOT checked, I would like to prevent the user from scrolling to that "*" symbol using the UP/DOWN arrows
of the combo box control.
In summary: I only want the checkbox to select that indexed item.
I tried to manually add and remove the "*" but the value where the asterisk is added is changed - I don't want that.
Here is the checkbox code:
Code:
Private Sub Rnd_Letters_CheckedChanged(sender As Object, e As EventArgs) Handles Rnd_Letters.CheckedChanged
Rnd_Letters.Font = IIf(Rnd_Letters.Checked = True, New Font(Rnd_Letters.Font, FontStyle.Bold), New Font(Rnd_Letters.Font, FontStyle.Regular))
ConfigSet = True
If Rnd_Letters.Checked = False Then
Rnd_Letters.Refresh()
ComboBox1.Enabled = True
ComboBox2.Enabled = True
ComboBox1.SelectedIndex = 0 ' Shows the first letter in the combobox
ComboBox1.Refresh()
ComboBox2.SelectedIndex = 0 ' Shows the first letter in the combobox
ComboBox2.Refresh()
No_Repeats.Checked = False
No_Repeats.Enabled = False
RndSet = False
ElseIf Rnd_Letters.Checked = True Then
No_Repeats.Enabled = True
RndSet = True
ComboBox1.SelectedIndex = 26 ' Selects the * symbol
ComboBox1.Enabled = False
ComboBox2.SelectedIndex = 26 ' Selects the * symbol
ComboBox2.Enabled = False
TextBox1.Text = "0"
End If
ConfigSet = False
Check_Defaults()
OKToolStripMenuItem.Enabled = True
SAVEToolStripMenuItem.Enabled = True
End Sub
-
January 2nd, 2021, 03:38 AM
#2
Re: Selectively prevent a combobox from scrolling past a certain point Visual Studio
Either disable the comboboxes, or remove items that shouldn't be selected.
-
January 2nd, 2021, 07:33 AM
#3
Re: Selectively prevent a combobox from scrolling past a certain point Visual Studio
Removing the "*" works great. It's when I try to put it back. Doing so replaces one of the letters stored. Not good.
-
January 2nd, 2021, 08:47 AM
#4
Re: Selectively prevent a combobox from scrolling past a certain point Visual Studio
Originally Posted by oldGMtireman
Removing the "*" works great. It's when I try to put it back. Doing so replaces one of the letters stored. Not good.
You have control over the list, if you can't figure out how to insert an item at a specific position, then delete the items and reinsert them.
-
January 2nd, 2021, 08:53 AM
#5
Re: Selectively prevent a combobox from scrolling past a certain point Visual Studio
You were correct. I was populating the list dynamically when the form loaded and added the "*" at that time. I removed that.
Then I had the checkbox add the "*" when checked and replaced the list with a call to the code that loaded it to begin with.
DONE!
Thank You!!!!!!!!!!!!!!!!!!
-
January 2nd, 2021, 09:20 AM
#6
Re: [RESOLVED] Selectively prevent a combobox from scrolling past a certain point Vis
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|