简体   繁体   中英

creating a custom column type?

when I try to add a column to my datagrid at design time
there are custom types for the column and i must choose one of these types as an example "dataGridViewTextBoxColumn"
how can I create a custom column type ?
what I want is a custom Type for my column called "dataGridViewNumberTextBoxColumn" that i can choose it for my datagrid at design time

I am using c# and .Net and a windows form application
thanks

Basically, you need to descend from the base class DataGridViewColumn and create your own visual display.

See here for an example of how to do this:

只需从Microsoft获得DataGridViewNumericUpDownColumn

Obviously you can't inherit form TextBox as it is not object that inherits from DataGridViewColumn.

On the other hand, you can inherit from any object that inherits from this object.

Note that when using your new Column class, you must cast DataGridView.Columns[index] to it, otherwise you won't see any of its properties or methods. Or you can also create new class from DataGridView that does this in new property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM