【问题标题】:How to create two DataGridViewButtonColumn in just one column?如何在一列中创建两个 DataGridViewButtonColumn?
【发布时间】:2011-12-21 00:41:31
【问题描述】:

我目前正在使用 C# 中的 DataGridView,我发现很难在一列中创建两个 DataGridViewButtonColumn。

我只能在一列中创建一个 DataGridViewButtonColumn:

DataGridViewButtonColumn btnCol = new DataGridViewButtonColumn();
btnCol.Text = "...";
btnCol.UseColumnTextForButtonValue = true;            
DataGridView1.Columns.Add(btnCol);

DataGridView 的单列中是否可以有两个 DataGridViewButtonColumn?

提前致谢。 :)

【问题讨论】:

    标签: c# winforms datagridview datagridcolumn


    【解决方案1】:

    有可能,您需要创建自己的列类型。实现此目的的一种简单方法是使用两个按钮创建一个用户控件,然后将此用户控件用作自定义网格列上的编辑控件。

    这里有一个关于制作日历栏的好 MSDN 页面:

    http://msdn.microsoft.com/en-us/library/7tas5c80.aspx

    您可以以此为基础了解自定义列的结构,也可以在网上更准确地搜索更多资源。我见过有人使用这种技术制作了一个自定义列,其中包含 DataGridView 作为其编辑控件。

    或者更容易...只需将两个按钮列彼此相邻。

    【讨论】:

    • 你真的可以有一个UserControl 作为编辑控件吗?
    • @V4Vendetta 我自己没做过,我只是假设你可以,因为它是一个有效的控件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-10
    • 2011-09-21
    • 2013-04-24
    • 2020-03-24
    • 2012-07-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多