如何在Windows窗体C#4.0中的DataGridView控件中选择行值 [英] How to Select a row values in DataGridView control in Windows forms c# 4.0

查看:58
本文介绍了如何在Windows窗体C#4.0中的DataGridView控件中选择行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在Windows窗体中有DataGridView控件.如何在该控件中选择特定的行值.我无法在Windows中看到datagridview的选定索引更改事件,因此我可以在特定行上获取该控件.在datagridview控件中选择一个特定的行,我需要获取完整的行值,并需要在文本框控件中填充这些值.任何人都可以帮忙吗?

在此先感谢
Prahsanth

Hi All,

I have DataGridView control in windows form.How can i select a particular row values in that control.I am not able to see the selected index changed event of datagridview in windows so that i can get the control on particular row.As soon as i select a praticular row in datagridview control i need to get the complete row values and need to populate those values in textbox controls.Can anyone help on this?

Thanks in Advance
Prahsanth

推荐答案

亲爱的朋友,

我认为您是在复选框的帮助下选择行,然后在网格的复选框已更改事件上编写代码:-

Dear Friend,

I take that you are selecting the row with the help of checkbox then write the code on the checkbox changed event of the grid :-

private void chkSelect_CheckedChanged(object sender, EventArgs e)
{
  try
  {
   CheckBox chk = new CheckBox();
   chk = sender as CheckBox;

   if(chk.Checked == true)
   {
     foreach(DataGridViewRow row in dgvDetails.Rows)
     {
       [here you can find all the controls and there value and then you can put them into appropriate variables and use them accordingly].
     }
   }
  }
  catch(Exception ex)
  {
    MessageBox.Show(ex.Message())
  }
}



如果您有帮助,请不要忘记将其标记为答案.

谢谢

Varun Sareen



Please don''t forget to mark this as your answer if it helps you out.

Thanks

Varun Sareen


这篇关于如何在Windows窗体C#4.0中的DataGridView控件中选择行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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