我在Datagrideview中有两列我希望输入一些值到第一列然后它们两者都应该具有相同的值 [英] I Have Two Column In The Datagrideview I Want Enter Some Value To First Column But Then Both Of Them The Same Should Have The Same Value

查看:47
本文介绍了我在Datagrideview中有两列我希望输入一些值到第一列然后它们两者都应该具有相同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第1栏第2栏

8然后8

9 9

10 10

column 1 column 2
8 then 8
9 9
10 10

推荐答案

Just write code in datagridview_cellvaluechanged event like below . And after entering value click in any cell except that cell in which you have just entered text or value then you will see that the same value is in the other column in the corresponding row







private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{

        if (e.ColumnIndex == 0 && e.RowIndex>-1)
        {
            dataGridView1[e.ColumnIndex + 1, e.RowIndex].Value = dataGridView1[e.ColumnIndex, e.RowIndex].Value;

        }

}


这篇关于我在Datagrideview中有两列我希望输入一些值到第一列然后它们两者都应该具有相同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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