Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Combbox Stop Manual Data Entry
 

Combbox Stop Manual Data Entry

I have a combbox and want to stop manual data entry.
Code as follows:

Dim d As String

d = cn.ConnectionString

Dim ds As DataSet = New DataSet

Dim da As New SqlClient.SqlDataAdapter("select CompanyCode,Name from MtCM where del='0' order by CompanyCode", d)

da.SelectCommand.CommandType = CommandType.Text

da.Fill(ds,

"ComID")

cmbCompany.DataSource = ds.Tables(

"ComID")

cmbCompany.DisplayMember =

"Name"

cmbCompany.ValueMember =

"CompanyCode"

Iqbal Mehram  Thursday, September 17, 2009 7:47 AM
just set ComboBox.DropDownStyle to 'DropDownList' . And it'll work perfectly (non-editable mode)


[On msdn]
The DropDownStyle property specifies whether the list is always displayed or whether the list is displayed in a drop-down. The DropDownStyle property also specifies whether the text portion can be edited. See ComboBoxStyle for the available settings and their effects. There is no setting to always display the list and disallow entering a new value.



Please mark as answer, if it helps you..
  • Proposed As Answer byHassan Mehmood Thursday, September 17, 2009 7:59 AM
  • Edited byHassan Mehmood Thursday, September 17, 2009 8:02 AMto give links on msdn..
  • Marked As Answer byIqbal Mehram Thursday, September 17, 2009 8:05 AM
  •  
Hassan Mehmood  Thursday, September 17, 2009 7:59 AM
just set ComboBox.DropDownStyle to 'DropDownList' . And it'll work perfectly (non-editable mode)


[On msdn]
The DropDownStyle property specifies whether the list is always displayed or whether the list is displayed in a drop-down. The DropDownStyle property also specifies whether the text portion can be edited. See ComboBoxStyle for the available settings and their effects. There is no setting to always display the list and disallow entering a new value.



Please mark as answer, if it helps you..
  • Proposed As Answer byHassan Mehmood Thursday, September 17, 2009 7:59 AM
  • Edited byHassan Mehmood Thursday, September 17, 2009 8:02 AMto give links on msdn..
  • Marked As Answer byIqbal Mehram Thursday, September 17, 2009 8:05 AM
  •  
Hassan Mehmood  Thursday, September 17, 2009 7:59 AM

You can use google to search for other answers

Custom Search

More Threads

• How ca I shrink the program's windows to an icon at the right cornor of the Explorer.
• Unable to move the position of custom control during design time
• How can I get the menu designer for MainMenu to show up?
• Outlook-style Notification Box
• Can a component know where it is? on initialize?
• table integrity
• hyperlink to open a new form
• using windows controls with unmanaged code
• What the eck??? Error on Line 0???
• MenuItem MouseEventArgs... possible?