使用C#为datagridview中的每一行添加包含删除按钮的col [英] adding a col which contains a delete button for each row in a datagridview using C#

查看:437
本文介绍了使用C#为datagridview中的每一行添加包含删除按钮的col的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datagridview,我需要在datagridview中添加一个删除按钮,它将从数据库中删除该特定行...我需要知道如何在datagridview中的col中添加删除按钮。

谢谢

解决方案

对于datagridview,



尝试这个:

 DataGridViewButtonColumn btn =  new  DataGridViewButtonColumn(); 
dataGridView1.Columns.Add(btn);
btn.HeaderText = 点击数据;
btn.Text = 点击此处;
btn.Name = btn;
btn.UseColumnTextForButtonValue = true ;





如果这解决了你的问题,请标记为答案并投票5



问候,

Eduard


gridview属性中的

,设置

 AutoGenerateDeleteButton =  true  





希望它有所帮助!



不要忘记投票,



谢谢


要删除任何行或记录,不需要删除按钮。



您可以通过选择它并按下KeyBord上的删除按钮来删除任何行。在执行此操作之前,只需检查DataGridView的以下属性是否为True


 AllowUserToDeleteRows =  True  



我希望它可以帮到你:)


hi i have a datagridview and i need to add a delete button in the datagridview which will delete that particular row from the database...i need to know how is it possible to add the delete button in a col in the datagridview.
Thanks

解决方案

For datagridview,

try this one:

DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
dataGridView1.Columns.Add(btn);
btn.HeaderText = "Click Data";
btn.Text = "Click Here";
btn.Name = "btn";
btn.UseColumnTextForButtonValue = true;



Please mark as answer and vote 5 if this solved your problem

Regards,
Eduard


in the properties of the gridview, set

AutoGenerateDeleteButton = true



hope it helps!

don't to forget to vote,,

thanks


To delete any row or record therer is no need of delete button.

You can Delete any row by selecting it and pressing Delete Button on your KeyBord.Brfore doing this just check that ther following property of DataGridView should be True

AllowUserToDeleteRows = True


I hope it will help you :)


这篇关于使用C#为datagridview中的每一行添加包含删除按钮的col的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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