列名称 DataGridView 的值
我正在使用 Visual Studio 2010,正在开发一个 Windows 窗体。现在我正在使用数据网格视图,我想编写一些函数,这些函数允许您通过更改数据网格视图中的文本来自动编辑数据网格。现在,我能够获取实际值,但我需要列的值,以便在使用 ADO.net 时将其用作参数,这是我的代码现在的样子,
private void dgv_DataLookup_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
DialogResult dr;
dr = MessageBox.Show("Are you sure you want to edit this field?", "Edit Cell", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
DataGridViewCell editItemCell = dgv_DataLookup[dgv_DataLookup.CurrentCell.RowIndex, dgv_DataLookup.CurrentCell.ColumnIndex];
string editItem = editItemCell.Value.ToString();
}
}
这里获取当前单元格的值当前选择的。我尝试做这样的事情
DataGridViewColumns columnCells = dgv_DataLookup.CurrentCell.ColumnIndex.Value.ToString()... 可以代表这个实际代码的东西。谢谢!
I'm using Visual Studio 2010 and i'm developing a windows form. Right now I'm using a data grid view and i want to write some functions that would allow you to automaticlly edit the datagrid by just changing the text in the Datagrid view. Right now, I am able to get the actual value but I need the value of the column in order to use it as a parameter when i use ADO.net here's what my code looks like now
private void dgv_DataLookup_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
DialogResult dr;
dr = MessageBox.Show("Are you sure you want to edit this field?", "Edit Cell", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
DataGridViewCell editItemCell = dgv_DataLookup[dgv_DataLookup.CurrentCell.RowIndex, dgv_DataLookup.CurrentCell.ColumnIndex];
string editItem = editItemCell.Value.ToString();
}
}
this here gets me the value of the current cell that is currently selected. I tried doing something like this
DataGridViewColumns columnCells = dgv_DataLookup.CurrentCell.ColumnIndex.Value.ToString()... something that would represent this but actual code. thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解,您想要编辑字段内的值,您可以通过这种方式选择值。
再见
According to what I understand you want to edit the value within a field, you can choose the value in this way.
Bye