We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ReadOnly ComboBoxBase

I am using the ComboBoxBase with a GridListControl as the source for the drop down. I need to be able to make the ComboBoxBase so that the user can not edit the contents of the combo box, can not change which row is selected in the drop down, but can display the contents of the drop down. I have tried setting the ComboBox.ReadOnly property to false, but that prevents the user from seeing the contents of the drop down list. I also tried setting the comboboxbase1.DropDownButton.Enabled to true, but as long as the ComboBox.ReadOnly is set to false, the user can not see the contents of the drop down list. I have tried setting the ComboBox.TextBox.ReadOnly property to false, but that lets the user add text to the combo box, changed the selected value, but not delete the text in the combo box. Any suggestions on how to accomplish this? Thanks, Chad

2 Replies

AR Anupama Roy Syncfusion Team November 10, 2005 12:28 PM UTC

Hi Chad, You can try changing the Enum value of DropDownStyle property to DropDownList. This will prevent users from editing the text portion and at the same time, it will allow the change of display text by the selection through the GridListControl. this.comboBoxBase1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; Please let me know if this helps you. Best Regards, Anu


CE Chad Elliot November 10, 2005 05:18 PM UTC

That’s not quite what I need. By changing the DropDownStyle to DropDownList, the user can still change which item is selected. Also, the user can not highlight the text in the combo box. What I have decided to do is create my own custom control with a ReadOnly property. Here is the code that I am using. Let me know if can think of a better way to do it. Private Sub MyComboBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Enter BeforeUpdateValue = MyComboBox.Text BeforeUpdateIndex = MyComboBox.ListControl.SelectedIndex End Sub Private Sub MyComboBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyComboBox.KeyPress If mReadOnly = True Then e.Handled = True End If End Sub Private Sub MyComboBox_SelectedIndexChanging(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.SelectedIndexChangingArgs) Handles MyComboBox.SelectedIndexChanging If mReadOnly = True Then MyComboBox.Text = BeforeUpdateValue MyComboBox.ListControl.SelectedIndex = BeforeUpdateIndex End If End Sub Thanks, Chad

Loader.
Live Chat Icon For mobile
Up arrow icon