Adding Properties to a Custom Column

You may want to add properties to a column in order to set a specific behavior. Continuing with the hyperlink column created in the previous topics, in this topic you'll add a property called TargetName. This property allows the user to specify the name of the target window or frame where the page will open.

Complete the following steps:

1.   Add the following code to create the TargetName property:

      Visual Basic

      C#

2.   Once the property is created you'll propagate this to the hyperlink in the BindCellContent method:

      Visual Basic

      C#

Tips

You may find the following tips helpful when adding properties to a custom column:

      Provide a constructor that takes PropertyInfo as parameter calling base(property) in order to automatically set the Binding, SortMemberPath, FilterMemberPath and Header properties as well as properties set using custom attributes. Currently supported attributes include: DisplayAttribute (AutoGenerateFilter, Name, GroupName, Order), DisplayFormatAttribute, and EditableAttribute.

 

public DataGridHyperlinkColumn(PropertyInfo property) : base(property)

 

      You can set a converter in the binding to help you to manage scenarios where you need to use a column bound to property source that is not the same type. Suppose you want to bind a numeric column against a string property, this scenario will work correctly if you set a converter type which converts the string to a double.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.