从datagridview获取选定的单元格值。 [英] Getting a selected cell value from datagridview.

查看:166
本文介绍了从datagridview获取选定的单元格值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击datagridview中的选定单元格时,我需要选择的单元格值并能够将其绘制到图片框上。不知道如何做到这一点?

When the user click on a selected cell in the datagridview,i need that selected cell value and be able to draw it onto the picturebox.Any idea how this can be done?

推荐答案

X = dataGridView1 [Column,Row] .Value;



从datagridview中的选定行获取值 [ ^ ]
X = dataGridView1[Column,Row].Value;

get value from selected rows in datagridview[^]


此事件发生在单元格的任何部分单击,包括边框和填充。当按钮单元格或复选框单元格具有焦点时,用户按下并释放SPACE键时也会发生这种情况,如果在按下SPACE键的同时单击单元格,则会发生两次这些单元格类型。



This event occurs when any part of a cell is clicked, including borders and padding. It also occurs when the user presses and releases the SPACE key while a button cell or check box cell has focus, and will occur twice for these cell types if the cell is clicked while pressing the SPACE key.

private void dataGridView1_CellClick(object sender,
    DataGridViewCellEventArgs e)
{
  if (dataGridView1.CurrentCell.ColumnIndex.Equals(3) && e.RowIndex != -1){
        if (dataGridView1.CurrentCell != null && dataGridView1.CurrentCell.Value != null)
            MessageBox.Show(dataGridView1.CurrentCell.Value.ToString());   
   
}


这篇关于从datagridview获取选定的单元格值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆