如何在DataGrid中的每一行添加按钮? [英] How to Add Button to Every Row in DataGrid ?

查看:200
本文介绍了如何在DataGrid中的每一行添加按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Datagrid中为每一行添加一个Button

,当点击该按钮时,它应该更新Datagrid中的当前行



i want to add a Button to every Row in my Datagrid
and when some click that button it should update the current Row in Datagrid

SqlConnection conn = new SqlConnection("Server= localhost; database=tailoringmng; integrated Security=true");
                SqlCommand cmd = new SqlCommand("undonetask",conn);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                
                if (conn == null && conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                    DataTable dt = new DataTable("myTable");
                    da.Fill(dt);
                    
                dgridstatus.DataSource = dt.DefaultView;
                conn.Close();
                }



这是我的代码我不知道如何从Datagrid中选择所选行

以及我应该如何添加按钮


this is my code i have no idea how to select selected row from Datagrid
and how should i add button

推荐答案

你好,试试这些文章的食谱:

Winforms

1。 使用DataGrid控件 [ ^ ]

2. Windows DataGridColumns用户控件 [ ^ ]

3. 如何向DataGrid添加其他控件 - (第一部分) [ ^ ]

4. DataGridView图像按钮单元格 [ ^ ]

网络应用程序

1. GridView all in one [ ^ ]

2. < a href =http://www.codeproject.com/Articles/10667/DataGridHelper-tool> DataGridHelper工具 [ ^ ]
Hello, try recipes from these articles:
Winforms
1. Using the DataGrid Control[^]
2. Windows DataGridColumns User Controls[^]
3. How to add other controls to DataGrid - (Part I )[^]
4. DataGridView Image Button Cell[^]
Web apps
1. GridView all in one[^]
2. DataGridHelper tool[^]


这篇关于如何在DataGrid中的每一行添加按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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