Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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.

  • Administrators
Posted

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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
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

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...