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