How to make DataColumn.Expression work?
-
Had anybody found that DataColumn.Expression sometime is valid and sometime is invalid? If the DataTable which have a column define DataColumn.Expression binding a DataGrid which has a GridTableStyle, when your edit the grid and change the cloumn value which relation with the column has set 'Expression', the relation column MUST NOT calculate and display a new value. If I use DataTable.New to create a new DataRow and set value to the columns(not needn't set value to the column has set 'Expression'), and then use DataTable.Row.Add to add a new row, it sometimes can calculate and display a new value. But if I change the column's name and accordingly modify Expression's value, sometimes you surprise to found that it can not work, why? :confused::confused::confused: === Game is power! === -- modified at 23:24 Thursday 29th September, 2005
-
Had anybody found that DataColumn.Expression sometime is valid and sometime is invalid? If the DataTable which have a column define DataColumn.Expression binding a DataGrid which has a GridTableStyle, when your edit the grid and change the cloumn value which relation with the column has set 'Expression', the relation column MUST NOT calculate and display a new value. If I use DataTable.New to create a new DataRow and set value to the columns(not needn't set value to the column has set 'Expression'), and then use DataTable.Row.Add to add a new row, it sometimes can calculate and display a new value. But if I change the column's name and accordingly modify Expression's value, sometimes you surprise to found that it can not work, why? :confused::confused::confused: === Game is power! === -- modified at 23:24 Thursday 29th September, 2005
Haha..., I got the answer myself. If you write the sentence
this.dataColumn.Expression="Col1 * Col2";
after((System.ComponentModel.ISupportInitialize)(this.dataTable)).EndInit();
then it will work right. But if the code generate by IDE wizzard, it gererate the dataColumn code at the front part, and the sentence '(...).EndInit()' is generate at //Formxx part which must be generated at the end of mothed InitializeComponent(), so, the 'Expression' can not work. As the said, if you want to use 'DataCloumn.Express' property, the good way is written the code yourself after InitializeComponent(). :cool: === Game is power! === -- modified at 1:37 Friday 30th September, 2005