Public Member Functions | |
| OLVColumnAttribute (string colTitle) | |
| Initializes a new instance of the OLVColumnAttribute class. | |
Properties | |
| string | Title [get, set] |
| Gets or sets the column title text. | |
| string | ToolTipText [get, set] |
| Gets or sets the tool tip text. | |
| int | DisplayIndex [get, set] |
| Gets or sets the column display index (display order, left to right). | |
| bool | IsVisible [get, set] |
| Gets or sets a value indicating whether this column is visible by default. | |
| bool | UseInitialLetterForGroup [get, set] |
| Gets or sets a value indicating whether to use the first letter of the aspect for grouping. | |
| bool | FillsFreeSpace [get, set] |
| Gets or sets a value indicating whether the column will fill free space. | |
| int | FreeSpaceProportion [get, set] |
| Gets or sets the free space proportion. | |
| int | MaximumWidth [get, set] |
| Gets or sets the column's maximum width. | |
| int | MinimumWidth [get, set] |
| Gets or sets the column's minimum width. | |
| int | Width [get, set] |
| Gets or sets the column's width. | |
| string | Tag [get, set] |
| Gets or sets the OLVColumn's tag value. | |
| HorizontalAlignment | TextAlign [get, set] |
| Gets or sets the columns's alignment. | |
| object[] | GroupValues [get, set] |
| Gets or sets the grouping values. The value must be an array of object which may contain only constant values, i.e. numerics/strings/types. | |
| string[] | GroupDescrs [get, set] |
| Gets or sets the grouping descriptions. See MakeGroupies<T>. | |
This attribute attaches basic information to a property such that a set of columns may be dynamically built for an ObjectListView by using ColumnBuilder.BuildColumns<T>() to construct the columns.
OLVColumnAttribute does not support all the properties available in an OLVColumn. Many of the properties are simply not supportable via the attribute framework, like delegates. Only the basic display/organization properties are supported.
If custom getters/setters are required for a column, these may be assigned to the OLVColumn after it's built by BuildColumns - a simple lookup in the resulting collection will fetch the OLVColumn reference.
This example demonstrates usage of the attribute on a property and build a columns list for the ObjectListView:
public class AnItem { [OLVColumn( "Item", ToolTipText = "Item's Name", DisplayIndex = 1, UseInitialLetterForGroup = true )] public string Name { get; set; } } // ... somewhere in forms initialization ... List<OLVColumn> cols = ColumnBuilder.BuildColumns<AnItem>( dataList ); // // attach a custom AspectGetter cols.Find( c => c.AspectName == "Name" ).AspectGetter = o => ((AnItem)o).name;
This is an example of specifying grouping information within the attribute (see MakeGroupies<T> for details):
[OLVColumn( "Age", ToolTipText = "Wine's Age", DisplayIndex = 3, GroupValues = new object[] { 1, 5, 10, 20 }, GroupDescrs = new string[] { "New", "Drinkable", "Perfect", "Ceremonial", "Vinegar" } )] public int Age { get; set; }
Definition at line 65 of file ColumnBuilder.cs.
| RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.OLVColumnAttribute | ( | string | colTitle | ) |
Initializes a new instance of the OLVColumnAttribute class.
| colTitle | The col title. |
Definition at line 181 of file ColumnBuilder.cs.
int RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.DisplayIndex [get, set] |
Gets or sets the column display index (display order, left to right).
The display index.
Definition at line 80 of file ColumnBuilder.cs.
bool RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.FillsFreeSpace [get, set] |
Gets or sets a value indicating whether the column will fill free space.
true if [fills free space]; otherwise, false.
Definition at line 100 of file ColumnBuilder.cs.
int RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.FreeSpaceProportion [get, set] |
Gets or sets the free space proportion.
The free space proportion.
Definition at line 105 of file ColumnBuilder.cs.
string [] RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.GroupDescrs [get, set] |
Gets or sets the grouping descriptions. See MakeGroupies<T>.
The group descriptions.
Definition at line 175 of file ColumnBuilder.cs.
object [] RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.GroupValues [get, set] |
Gets or sets the grouping values. The value must be an array of object which may contain only constant values, i.e. numerics/strings/types.
See OLVColumn.MakeGroupies<T>.
[OLVColumn( "Age", ToolTipText = "Wine's Age", DisplayIndex = 3, GroupValues = new object[] { 1, 5, 10, 20 }, GroupDescrs = new string[] { "New", "Drinkable", "Perfect", "Ceremonial", "Vinegar" } )] public int TotalAge { get; set; }
Unfortunately an attribute may be assigned only static information. Anything that requires a constructor (custom type) or anything really fun like a lambda expression are out of the question.
This simply will not work:
[OLVColumn( "Age", ToolTipText = "Wine's Age", DisplayIndex = 3, GroupValues = new object[] { new Age( 1 ), new Age( 5 ), new Age( 10 ), new Age( 20 ) }, GroupDescrs = new string[] { "New", "Drinkable", "Perfect", "Ceremonial", "Vinegar" } )] public Age TotalAge { get; set; }
If you're using a custom type, this limitation may be ocercome by supplying implicit conversions to a numeric or string type. Your results will vary.
Definition at line 170 of file ColumnBuilder.cs.
bool RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.IsVisible [get, set] |
Gets or sets a value indicating whether this column is visible by default.
true if this instance is visible; otherwise, false.
Definition at line 87 of file ColumnBuilder.cs.
int RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.MaximumWidth [get, set] |
Gets or sets the column's maximum width.
The maximum width.
Definition at line 110 of file ColumnBuilder.cs.
int RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.MinimumWidth [get, set] |
Gets or sets the column's minimum width.
The minimum width.
Definition at line 115 of file ColumnBuilder.cs.
string RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.Tag [get, set] |
HorizontalAlignment RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.TextAlign [get, set] |
Gets or sets the columns's alignment.
The text align.
Definition at line 131 of file ColumnBuilder.cs.
string RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.Title [get, set] |
string RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.ToolTipText [get, set] |
bool RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.UseInitialLetterForGroup [get, set] |
Gets or sets a value indicating whether to use the first letter of the aspect for grouping.
true if [use initial letter for group]; otherwise, false.
Definition at line 95 of file ColumnBuilder.cs.
int RiggsHill.Windows.Forms.OLVHelper.OLVColumnAttribute.Width [get, set] |
1.5.8