-
May 6th, 2010, 09:35 AM
#1
Thread Starter
Addicted Member
Having trouble populating datagridviewer column. Please help
I have the following dataset and datatable:
1 Code:
Dim topics As New DataSet()
Public Function JT_PullData(ByVal TableName As String) As DataTable
If topics.Tables.Count >= 1 Then
topics.Clear()
names = Nothing
intSetArray = 0
i = 0
End If
Dim conn As String = "Server=192.168.0.36;Port=3306;Database=wc;Uid=root;Pwd=123454321"
Dim cmd As String = "SELECT * FROM " & TableName
Dim ad As New MySql.Data.MySqlClient.MySqlDataAdapter(cmd, conn)
ad.GetFillParameters()
ad.Fill(topics)
Dim dr As DataRow
Dim dt As DataTable
dt = topics.Tables(0)
intSetArray = dt.Rows.Count
ReDim names(intSetArray, 4)
For Each dr In dt.Rows
names(i, 1) = dr(1) 'Username
names(i, 2) = dr(2) 'Password
names(i, 3) = dr(3) 'Active
names(i, 4) = dr(4) 'Accesslevel
i += 1
Next
topics.Dispose()
JT_PullData = topics.Tables(0)
End Function
Now I have a column in my DataGridViewer that is a dropdown list. This list is to be populated by the datasel above.
I can't seem to get it to work. Help me, please
Here is an image:
I am supposed to set the dataset and then set the values that would be shown. (all by code )
-
May 6th, 2010, 09:41 AM
#2
Fanatic Member
Re: Having trouble populating datagridviewer column. Please help
Each of those you see are properties in code.
DataGridView1.Datasource = dt (if for some reason you can't set a datatable as a source, add the table to a data set and then use the dataset as a source)
DataGridView1.DisplayMember = "Name of your Column"
DataGridView1.ValueMember = "Name of your Column" (this is usually a PK or ID type field)
Where I'm from we only have one bit of advice for new comers: "If you hear banjos, turn and run".
VS 2008 .NetFW 2.0
-
May 6th, 2010, 09:46 AM
#3
Thread Starter
Addicted Member
Re: Having trouble populating datagridviewer column. Please help
I do get
DataGridView1.Datasource
But I cant find the DisplayMember and ValueMember Properties for some weird reason. Any Ideas?
-
May 6th, 2010, 10:48 AM
#4
Fanatic Member
Re: Having trouble populating datagridviewer column. Please help
That's because I was wrong assuming the display and value members were properties of the columns of your data grid view. They're actually properties of the comboboxcolumn itself.
Code:
Dim comboboxcol As DataGridViewComboBoxColumn = Me.DataGridView1.Columns("NameOfCol")
comboboxcol.DisplayMember =
comboboxcol.ValueMember =
You could always add the column in by code rather through the designer.
Where I'm from we only have one bit of advice for new comers: "If you hear banjos, turn and run".
VS 2008 .NetFW 2.0
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|