在datagridview中添加按钮列 [英] Adding button column in datagridview
问题描述
我有一个 datagridview,它显示数据库中的销售详细信息.我想在列的末尾添加一个删除按钮,这样我就可以在每一行的末尾看到删除按钮.我知道要向 datagridview 添加一个按钮列.但在这里我显示来自数据库的数据,当它显示数据时,我想要在 gridview 的末尾有一个自定义按钮列.我们怎样才能做到这一点?我添加了一个按钮列,但它位于 datagridview 的第一个位置......之后只显示我的整个数据.我想要它在最后一个位置.有人可以帮我怎么做吗?
I have a datagridview which displays sale detail from database. I want to add a delete button at the end of the columns so i can see the delete button at the end of every row. I know to add a button column to datagridview. but here iam displaying data from database and when it displays data i want a custom button column at the end of the gridview. how can we achieve this? I added a button column but it comes at the first position of the datagridview.. after that only my whole data displays. I want it at last position. Can someone help me how to do that?
推荐答案
您可以将 DataGridView.Columns[columnName]
的 DisplayIndex
属性设置为 (columns count - 1)最后显示按钮列.
You can set DisplayIndex
property of DataGridView.Columns[columnName]
to (columns count - 1) to display button column in the end.
dataGridView1.Columns["ButtonColumn"].DisplayIndex = dataGridView1.ColumnCount - 1;
这篇关于在datagridview中添加按钮列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!