Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combobox in Datagrid wont show DisplayMember

Status
Not open for further replies.

AndreAraujo

Programmer
Feb 14, 2002
62
PT
Hello, im new to .net, im using a windows form with a datagrid, in that data grid i display information about my costumers, id, Name, Country, pay method, pay conditions, ..
I´m using a DataGridComboBoxColumn to display not the code of the country (table Costumers) but the name of the country (table country).
The problem is that tha cell display the code of the country, only when i open the combo i can see the names .

after i fill the dataset with the tables costumers and country, this is the code i use to format the data grid, currently im using only 2 fields from table Costumers, until resolve this problem

Code:
private sub FillGrid()
DvClientes.AllowNew = False
DataGrid1.TableStyles.Clear()
Dim ts As New DataGridTableStyle
ts.MappingName = "Def_costumers"
DataGrid1.DataSource = (MyDataSet.Tables("costumers"))


Dim Col1 As New DataGridTextBoxColumn
Col1.MappingName = MyDataSet.Tables(0).Columns(0).ColumnName
Col1.HeaderText = "Id"
Col1.Width = 20
ts.GridColumnStyles.Add(Col1)

Dim Col4 As New DataGridComboBoxColumn
Col4.MappingName = MyDataSet.Tables(0).Columns(3).ColumnName
Col4.HeaderText = "Country" 
Col4.Width = 100
ts.PreferredRowHeight = (Col4.ColumnComboBox.Height + 3)
Col4.ColumnComboBox.DataSource = MyDataSet.Tables(5).DefaultView 'table country
Col4.ColumnComboBox.DisplayMember = "Name"' fields from country
Col4.ColumnComboBox.ValueMember = "Cod_Country"'fields from country
Col4.ColumnComboBox.DropDownStyle = comboBoxStyle.DropDownList
ts.GridColumnStyles.Add(Col4)

DataGrid1.TableStyles.Add(ts)
DataGrid1.DataSource = MyDataSet.Tables(0)
end sub

Can be the problem in the comboboxcolumn class

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top