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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ReadOnly ComboBoxBase

Thread ID:





36781 Nov 9,2005 08:05 PM UTC Nov 10,2005 05:18 PM UTC WinForms 2
Tags: Tools
Chad Elliot
Asked On November 9, 2005 08:05 PM UTC

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

Anupama Roy [Syncfusion]
Replied On 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

Chad Elliot
Replied On 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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon