在C#中的datagridview中的另一种形式的文本框中显示数据 [英] display data on the text box of another form from datagridview in c#

查看:66
本文介绍了在C#中的datagridview中的另一种形式的文本框中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先要感谢dave的帮助,但是现在我想再次在datagridview中选择一个单元格之后从datagridview中检索所有数据,并在调用下面另一种形式的代码的方法中传递该值,这是第一种形式的代码:

I first start by thanking dave for his help but now again I want to retrieve all the data from datagridview after selecting one cell in the datagridview and pass that value in the method that calling another form below are the code for the first form:

private void dataGridView1_CellClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
       {
           int i =int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
           if (e.ColumnIndex == (dataGridView1.Columns.Count - 9))
           {
               {
                  // int i = int.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
                   updateFaults obj = new updateFaults(i);
                   obj.Show();
               }
           }


以下是第二种形式的代码:


the following is the code for the second form:

private void updateFaults_Load(object sender, EventArgs e)
       {  
           cmbclient.Text = fault_id.ToString();
           textBox1.Text = fault_id.ToString();
           cmbsys.Text = fault_id.ToString();
           cmbsite.Text = fault_id.ToString();
           cmbcategory.Text = fault_id.ToString();
           textBox4.Text = fault_id.ToString();
           textBox5.Text = fault_id.ToString();
           textBox6.Text = fault_id.ToString();
       }



有人可以帮我吗:(



can someone help me please :(

推荐答案

创建一个属性并将每个列值分配给该属性,然后在您的下一页访问这些属性,因为您可以创建窗口形式静态属性
Create a property and assign each column value into property then access these property on your next page since its a window form you can create a static property


嗨.
您可以使用以下代码作为示例:

Hi.
you can use of this code for example :

Textbox1.text=dataGridView1.SelectedRows[0].Cells[0].Value;
Textbox2.text=dataGridView1.SelectedRows[0].Cells[1].Value;
Textbox3.text=dataGridView1.SelectedRows[0].Cells[2].Value;
.
.
.


这篇关于在C#中的datagridview中的另一种形式的文本框中显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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