|
-
May 30th, 2007, 08:23 PM
#1
Thread Starter
Member
Read-only combo box
What is the the best way to make a combobox which is binded to a datasource read-only. Although the Enabled property works, but it makes the combobox too dim to be able to be visible to end user.
I realised that there is no Read-only property for combobox.
Thank You.
-
May 30th, 2007, 08:27 PM
#2
Frenzied Member
Re: Read-only combo box
Set the DropdownStyle property to DropDownList.
-
May 30th, 2007, 08:51 PM
#3
Thread Starter
Member
Re: Read-only combo box
Even when I set to dropdownlist, there is no read only property.
I dun want user to select any thing from the list. That means when they clicked the drop down error, nothing will happen.The combo is only for displayed purpose till they click an edit button which reset the property back to dafault.
-
May 30th, 2007, 09:15 PM
#4
Re: Read-only combo box
You may want to use a ListBox instead of a ComboBox. You can set the ListBox's SelectionMode to None so the user cannot select any items.
-
May 30th, 2007, 09:34 PM
#5
Frenzied Member
Re: Read-only combo box
If it is for display only, I'd be doing as circuits2 suggests - use a list box or a data grid.
If you really want to use a combo, you could assign the index of the combo that you want to maintain in the SelectedIndexChanged event:
Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox1.SelectedIndex = 2
End Sub
-
May 30th, 2007, 09:40 PM
#6
Re: Read-only combo box
If the user sees an enabled ComboBox they have a right to expect it to allow them to choose an item. If it doesn't then they have a right to assume that your app is broken. If you don't want the user to make a selection and you don't want to disable the ComboBox (how bad is your user's eyesight that they can't read a disabled ComboBox?) then hide it and display a read-only TextBox in its place.
-
May 30th, 2007, 09:55 PM
#7
Thread Starter
Member
Re: Read-only combo box
 Originally Posted by robertx
If it is for display only, I'd be doing as circuits2 suggests - use a list box or a data grid.
If you really want to use a combo, you could assign the index of the combo that you want to maintain in the SelectedIndexChanged event:
Code:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox1.SelectedIndex = 2
End Sub
If the data inside the combo box is grab from a database, combobox1.selectedindex=0 or 1 or 2 doesn't seems to get any value
-
May 30th, 2007, 10:31 PM
#8
Frenzied Member
Re: Read-only combo box
You will need to refer to the index of the item in your datasource. For example, if you want to display data relating to the fourth record in your datasource then set the SelectedIndex to 3.
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
|