将网格数据加载到文本框和下拉列表中以编辑和更新网格数据 [英] Load grid data into Textboxes and dropdown list to Edit and update grid data

查看:75
本文介绍了将网格数据加载到文本框和下拉列表中以编辑和更新网格数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击网格视图中的编辑"按钮时,我需要在文本框中显示相应的记录值,并下拉列表以更新其值.这样做的代码是什么.现在,我正在直接在grid vie上对其进行编辑.我需要在其文本框和pdatethem中编辑值.如何实现此目标..pls帮助我的朋友们.

请帮助我frnz

When i click the edit button in grid view i need the corresponding record values to be displayed in the text boxes and drop down lists in order to update their values. what is the code for doing so. Right now i am editing it directly on grid vie. i need to edit the values in their text boxes and pdatethem ..how can i achieve this,..pls help me friends.

pls help me frnz

推荐答案

关于DataGridView.SelectionChanged事件
编写以下代码:-
On DataGridView.SelectionChanged Event
Write the following code:-
private void DataGridView1_SelectionChanged(object sender, EventArgs e)
{
  if( DataGridView1.SelectedRows.Count = 0 )
  {
    TextBox1.Value = DataGridView1.SelectedRows(0).Cells(0).Value;
    TextBox2.Value = DataGridView1.SelectedRows(0).Cells(1).Value;
    //your code
  }
}



确保将DataGridView的SelectionMode属性设置为FullRowSelect才能起作用.



Make sure that SelectionMode Property of DataGridView is set to FullRowSelect for this to work.


这篇关于将网格数据加载到文本框和下拉列表中以编辑和更新网格数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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