我的问题是,由于某些原因,简单的赋值不起作用。dataGridView绑定到DB,im尝试将值类型字符串分配给字符串类型的列
enter code here //the initialization of the DataGridView
bindingSourceSchema.DataSource = null;
dgwSchema.Columns["colID"].DataPropertyName = "APP_ID";
dgwSchema.Columns["colName"].DataPropertyName = "DESCRIPTION";
dgwSchema.Columns["colTextbox"].DataPropertyName = "APP_ARGS";
dgwSchema.Columns["colTextbox"].HeaderText = "Parameters";
dgwSchema.Columns["colLink"].DataPropertyName = "APP_PATH";
dgwSchema.Columns["colLink"].HeaderText = "Path";
DataGridViewLinkColumn colLink = (DataGridViewLinkColumn)dgwSchema.Columns["colLink"];
colLink.UseColumnTextForLinkValue = true;
colLink.Text = "Edit";
bindingSourceSchema.DataSource = SchemaDB.GetGenericApps();//the assignment
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
dgwSchema.CurrentRow.Cells["colLink"].Value = openFileDialog.FileName;
// !! ?? dgwSchema.CurrentRow.Cells["colLink"].Value STAYS with parameter "Edit"
}感谢Eyal
发布于 2009-12-17 15:57:26
这可能是你在哪里运行这段代码的问题。这是在PageLoad事件中吗?执行此操作后,请确保网格不会再次被绑定。如果在赋值后放置断点,调试器会向您显示什么?
发布于 2009-12-17 17:16:32
原因是下面的属性设置为true。
colLink.UseColumnTextForLinkValue =真;
将其设置为false。然后它就会解决你的问题。
https://stackoverflow.com/questions/1920102
复制相似问题