I created a DataGridView
and generate one of the columns by following code:
DataTable accessDT = SQL.GetDT(@"select * from [Access]"); //Custom-made method to get the DataTable.
DataGridViewComboBoxColumn dcAccess = new DataGridViewComboBoxColumn();
dcAccess.Name = "Access";
dcAccess.HeaderText = "權限";
dcAccess.DataSource = accessDT;
dcAccess.ValueMember = "ID";
dcAccess.DisplayMember = "Name";
dgvUser.Columns.Add(dcAccess);
It will populate the "Access" column with dtAccess
, that's no problem at all.
But I don't know how to let it update automatically upon any change of the table [Access].
I tried to get the DataTable
again and do Update()
and Refresh()
, but the "Access" column is still the old data.
And I can't find any DataSource
under dgvUser.Columns["Access"]
once it was created.
Could somebody please be so kind and teach me how to let it auto-update properly?
Much appreciated!