在Windows窗体应用程序中. [英] In the Windows Form Application..

查看:82
本文介绍了在Windows窗体应用程序中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows From应用程序中.我有一个Datagridview.在那个gridview中,我使用数据库绑定了一些值. 现在,如果我在gridview中单击该绑定值,则该值将显示在特定的文本框中.

我该怎么做.

预先感谢.

In the Windows From application . I have a Datagridview. In that gridview, i bind some values using database..
Now if i click that bind value in the gridview that value is displayed in the particular Textbox.

How i do it.

Thanks in advance.

推荐答案


我认为您希望将某个数据库列的值在绑定到Grid View后立即绑定到文本框,如果是这样,这将很有帮助.
http://www.java2s.com/Code/CSharp/Database-ADO.net/DataViewBindingtoTextBox.htm [ ^ ]
Hi,
I think you want to bind value of some database column to text box as soon as you bind to Grid View, if it is so, this will be helpful.
http://www.java2s.com/Code/CSharp/Database-ADO.net/DataViewBindingtoTextBox.htm[^]


意味着您要在GridView单元格中单击该值以将该值填充到数据库中.对吧?

成功绑定gridview之后.生成单元格单击事件.

Means on GridView cell click you want to fill that value to database. Right ?

after binding gridview successfully. Generate cell click event.

private void dataGridView1_CellClick(object sender,DataGridViewCellEventArgs e)
{
   DataGridViewImageCell cell = (DataGridViewImageCell)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
   txtTextbox.text = cell.value; 

}


textBox1.Text=dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].ToString();



在DataGridView单元格单击事件中使用它.当您单击特定的单元格时.它将触发并设置TextBox的值来自Database.
希望对您有帮助...快乐编码...:-)



use it in DataGridView Cell Click Event. When You click particular cell. It will fire and set the TextBox with value coming from Database.
Hope it helps...Happy Coding...:-)


这篇关于在Windows窗体应用程序中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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