赢表格DatagridView。如何从设计器添加自定义列? [英] Win Forms DatagridView. How to add custom column from designer?

查看:111
本文介绍了赢表格DatagridView。如何从设计器添加自定义列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了自定义DataGridViewSliderColumn类,该类在单元格内呈现了一个TrackBar。



我的问题是,如何将列的类型设置为我在设计器中自定义的DataGridViewSliderColumn? (我在设计器上定义了很多列。)



我尝试过,但是设计器上仅显示预定义的列类型。



是否可以通过代码设置它而不必在运行时更改列定义?

解决方案

简单答案:创建自定义列类后,重新生成项目。






例如,假设我们创建了一个


  • 选择添加列...




  • 在添加列对话框中,选择 Type-> YourCustomColumn ,然后单击添加




  • 就是这样。进行必要的编辑(例如在此示例中设置 Column.WatermarkText ),运行它,然后欣赏。




    I've already created my custom DataGridViewSliderColumn class, which renders a TrackBar inside the cell.

    My question is, how can I set the type of a column to my custom DataGridViewSliderColumn in the designer? (I have defined a lot of columns on the designer).

    I've tried, but only predefined column types appear on the designer.

    Is possible to set it without having to alter the column definition at runtime, by code?

    解决方案

    Simple answer: After creating your custom column class, Rebuild your project.


    For example, let's say we've created a custom Watermark column named DataGridViewWatermarkColumn. To add it to the designer options and consequently to the DataGridView, do the following:

    1. Rebuild the solution once the custom column class is complete.
    2. In the Designer for your DataGridView, click the arrow in the upper right corner to expand the DataGridView Tasks.

    3. Select Add Column...

    4. On the Add Column Dialog, select Type -> YourCustomColumn, then click Add.

    That's it. Do any editing necessary (such as setting the Column.WatermarkText in this example), run it, and enjoy.

    这篇关于赢表格DatagridView。如何从设计器添加自定义列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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