Problem with ComboBox DataGridView Column

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 21
Reputation: Eyo is an unknown quantity at this point 
Solved Threads: 0
Eyo Eyo is offline Offline
Newbie Poster

Problem with ComboBox DataGridView Column

 
0
  #1
Dec 29th, 2008
Hi everybody,

if you please i have a problem with the display field of a combobox column in datagridview...

here is my code to add the column :

'First filling the datatable

Dim dt As New DataTable
Dim da As New SqlDataAdapter
Dim query As String = "SELECT id, name FROM Company_Tbl ORDER BY id "

con.open()
Dim mycommand As New SqlCommand(query, con.getConn)
da.SelectCommand = mycommand
da.Fill(dt)
con.close()

'Setting the combobox column properites
With comboBoxColumn
.DataSource = dt
.DataPropertyName = "company_name"
.Name = "company_name"
.Width = 100
.HeaderText = "Company"
.DisplayMember = "name"
.ValueMember = "id"
.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton

End With

Dim loc As Integer = grdViewVisaDetails.Columns.IndexOf(grdViewVisaDetails.Columns("company_name"))
grdViewVisaDetails.Columns.RemoveAt(loc)
grdViewVisaDetails.Columns.Insert(loc, comboBoxColumn)

'The problem is the value dispalyed on the grdview is the value field (id) not the display field (name) ..
but when am editing(cellcontentclick) the combobox displays the dispaly field and when finish editing it again display the value field

I provided a picture so this will explain what i mean

Thank u all in advance
Attached Thumbnails
Untitled.jpg  
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC