Virtual colums in a datagrid?
-
hi, im using a datagrid generated from a XML file using the VS XSD builder. now i want to add a "virtual" colum that add's some extra information, i only need this information on the runtime so i don't wanna add it to the XML file. i have read some examples with "BindingContext" and "Expression" but this examples are mostly DataGridBoolColumn and no TextColums. dose anybody knows a tuturial or have some example code?
-
hi, im using a datagrid generated from a XML file using the VS XSD builder. now i want to add a "virtual" colum that add's some extra information, i only need this information on the runtime so i don't wanna add it to the XML file. i have read some examples with "BindingContext" and "Expression" but this examples are mostly DataGridBoolColumn and no TextColums. dose anybody knows a tuturial or have some example code?
First, you should consider using
DataGridTableStyle
(s) to control exactly what the user sees (for instance, if you have a PK in your strongly-typedDataSet
as a numeric type, users probably don't need to see that). This will allow you to add columns that aren't bound to theDataSet
as well. You can use expressions in yourDataSet
and these are not limited to boolean expressions. For more information and examples, see the documentation for theDataColumn.Expression
property at http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataDataColumnClassExpressionTopic.asp[^]. Why I mentionedDataGridTableStyle
before is that you could also extendDataGridColumnStyle
and make your own class if you need expressions that are supported byDataColumn.Expression
. See the documentation forDataGridColumnStyle
in the MSDN library at http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsDataGridColumnStyleClassTopic.asp[^].Microsoft MVP, Visual C# My Articles