By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

lookup table using combobox

P: n/a
i have successfully added a combobox control in datagrid. this is the
code i have created but don't show up the record from another table.

Private Sub AddCustomDataTableStyle()

Dim ts1 As DataGridTableStyle
ts1 = New DataGridTableStyle()
ts1.MappingName = "SchYrSemCourseJoin"
' Set other properties.
ts1.AlternatingBackColor = Color.LightGray

Dim ComboTextCol As DataGridComboBoxColumn
ComboTextCol = New DataGridComboBoxColumn()
ComboTextCol.MappingName = "CourseID"
ComboTextCol.HeaderText = "Course"
ComboTextCol.Width = 100
ts1.GridColumnStyles.Add(ComboTextCol)

ts1.PreferredRowHeight =
(ComboTextCol.ColumnComboBox.Height + 3)

With ComboTextCol.ColumnComboBox
.DataSource = DsStudentCourse1
.DisplayMember = "Course.CourseID"
.ValueMember = "Course.CourseID"
End With

' c) set the dropdown style of the combo...
ComboTextCol.ColumnComboBox.DropDownStyle =
ComboBoxStyle.DropDownList
'add the custom table style to the datagrid table styles
DataGrid3.TableStyles.Add(ts1)

End Sub

i would be very glad for any reply...
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, 27 Jan 2004 16:15:22 +0800, jaYPee <hi******@yahoo.com> wrote:

i have successfully added a combobox control in datagrid. this is the
code i have created but don't show up the record from another table.

Private Sub AddCustomDataTableStyle()

Dim ts1 As DataGridTableStyle
ts1 = New DataGridTableStyle()
ts1.MappingName = "SchYrSemCourseJoin"
' Set other properties.
ts1.AlternatingBackColor = Color.LightGray

Dim ComboTextCol As DataGridComboBoxColumn
ComboTextCol = New DataGridComboBoxColumn()
ComboTextCol.MappingName = "CourseID"
ComboTextCol.HeaderText = "Course"
ComboTextCol.Width = 100
ts1.GridColumnStyles.Add(ComboTextCol)

ts1.PreferredRowHeight =
(ComboTextCol.ColumnComboBox.Height + 3)

With ComboTextCol.ColumnComboBox
.DataSource = DsStudentCourse1
.DisplayMember = "Course.CourseID"
.ValueMember = "Course.CourseID"
End With

' c) set the dropdown style of the combo...
ComboTextCol.ColumnComboBox.DropDownStyle =
ComboBoxStyle.DropDownList
'add the custom table style to the datagrid table styles
DataGrid3.TableStyles.Add(ts1)

End Sub


See if the following example works for you:

Adding ComboBox to the DataGrid
http://www.visual-basic-data-mining....spx?PostID=907
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 20 '05 #2

P: n/a
thanks for the reply but the example is the same also w/ the sample i
have downloaded from other sources. what i wanted is that the data in
the combobox that is integrated in the datagrid is come from another
table.

i have now successfully filled the data in the combobox the only
problem i have is on how to make the data in the combobox match the
data in actual table...

i have a CourseID field in my table that i want to lookup from another
table called course...the course table contains the field courseid,
course...the combobox lookups the course field from course table but
the combobox does not match the data in the actual table
See if the following example works for you:

Adding ComboBox to the DataGrid
http://www.visual-basic-data-mining....spx?PostID=907
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.