如何以自动方式获取文本框中所选行的单元格0的值 [英] how autometically get the value of cell 0 of selected row in text boxes

查看:70
本文介绍了如何以自动方式获取文本框中所选行的单元格0的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<pre> for(i=0;i<=dataGridView1.Rows.Count-1;i++)
            {
                if (dataGridView1.Rows[i].Cells[1].Value.ToString() == txtcscnic1.Text + "-" + txtcscnic2.Text + "-" + txtcscnic3.Text)
                {
                    
                    dataGridView1.Rows[i].Selected = true;
                    itemFound = true;
                    
                   
                
             
            }
            string str = dataGridView1.Rows[i].Cells[0].Value.ToString();
            string[] gcnic;
            gcnic = str.Split('-');
            txtcnic1.Text = gcnic[0];
            txtcnic2.Text = gcnic[1];
            txtcnic3.Text = gcnic[2];

推荐答案

这样......

this way...
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
   txtbox1.Text = dataGridView1.SelectedRows[0].cells[0].value;
}



快乐编码!

:)


Happy coding!
:)


private void dataGridView1_CellClick(object sender, EventArgs e)
{
   int i;
   i = dataGridView1.SelectedCells[0].RowIndex;
   txtbox1.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
   txtbox2.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
}





谢谢



Thanks


这篇关于如何以自动方式获取文本框中所选行的单元格0的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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