Hi,
I have a dataview that isn't sorting numerically. I'm trying to make a datatable instead, from the dataset for the dataview. The problem is that there are "virtual" columns, for lack of a better word, that make up some of the columns in the dataview. These are lambda expressions. Is it possible to add these types of columns that only exist in the dataview to a datatable?
This code is from an application developed by others, I'm trying to modify the sort so it will sort numerically.
This is the dataview code. The "ViewBuilder" and "setViewLambda" expressions are drawn from other pages in the application.
DEF_ViewBuilder vb = new DEF_ViewBuilder();
vb.SetViewLambda( new VersionNumberLambda( "VERSION_NUMBER", m_versionDataSet.Tables[GetTableName()],this ) );
vb.SetViewLambda( new VersionClosedLambda( "IS_CLOSED" ) );
vb.SetViewLambda( new VersionLockLambda( "LOCKED_BY", m_versionDataSet.Tables[GetTableName()],this ) );
vb.SetDataSources( "TableName", m_versionDataSet.Tables );
m_dv = vb.CreateView( "VersionView (VERSION_NUMBER, RELEASE_VERSION_NAME, IS_CLOSED, LOCKED_BY, ID)", "FROM " + GetTableName() + "(ID)" );
VERSION_NUMBER, RELEASE_VERSION_NAME, IS_CLOSED, LOCKED_BY, ID are the "virtual" columns in the dataview. I need the VERSION_NUMBER sorted, but it's sorting alphanumerically with the dataview.sort method, not numerically. When I add a column to the datatable, I can declare it as an Int32 and sort it then.
I've added a datatable and bound it to a datagrid:
DataTable t = m_versionDataSet.Tables[0];
dgVersions.DataSource = t;
Any ideas or suggestions vastly appreciated.
Thanks,
Anise
anise hollingsheadPosted Sep 22, 2008, 9:04 AM
Thanks for the help!
Anise
Bechir BejaouiPosted Sep 14, 2008, 6:18 PM
you can do this programmatically instansiate a datagridviewcolumn
DataGridViewColumn TheUnboundColumn = new DataGridViewColumn();
yourDataGridView.columns.add(TheUnboundColumn);
you can add a title to your new column as follow
TheUnboundColumn.HeaderCell.Value = "Title";
to add some values in the unbound column
yourDataGridView[Col,Row].Value = /*something here*/;