man_luck Posted July 26, 2004 Posted July 26, 2004 I want to create my own user control.I know i have to start "Windows Control Library" project and then i can define property, events and/or methods.But the problem is i want to create readonly combobox.I drag and drop a cobo box on the form.Now how to define this property? The code should go like this Property ReadOnlyCbo() As Boolean Get End Get Set(ByVal Value As Boolean) End Set End Property Can anyone tell me what code should go inside. :o Quote
man_luck Posted July 26, 2004 Author Posted July 26, 2004 Hey i have figured out how to make combo box read only without making a user control. My code is as follows: Private Sub cboDepartmentName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDepartmentName.TextChanged cboDepartmentName.Text = "" End Sub though i have achieved what i wished to do but still i would like to know how to create user control readonly combobox. Quote
Administrators PlausiblyDamp Posted July 26, 2004 Administrators Posted July 26, 2004 Rather than create a user control you could create a new class and inherit from the existing combobox. You would then need to override the relevant events. Not tested the following at all but it should give you the idea Public Class ReadOnlyComboBox Inherits ComboBox Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs) Text = "" End Sub End Class Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Joe Mamma Posted July 26, 2004 Posted July 26, 2004 Hey i have figured out how to make combo box read only without making a user control. My code is as follows: Private Sub cboDepartmentName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDepartmentName.TextChanged cboDepartmentName.Text = "" End Sub though i have achieved what i wished to do but still i would like to know how to create user control readonly combobox. Are you saying you only want the user to be able to select a value from the list and not change the text? just set the DropDownStyle to 'DropDownList' as opposed to dropdown Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
man_luck Posted July 27, 2004 Author Posted July 27, 2004 thanx i have got it right and now its working fine :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.