I''m using GDBG to implement unbound column, in QueryCellInfo event, I use the GridBoundRecordState object to get DataRow property , when I want retrive the column in DataRow, it always get the value of the first row. even the GridBoundRecordState.Position had changed but the column value of DataRow always show the value of first row. How can I solve the problem? Thank a lot
AD
Administrator
Syncfusion Team
November 2, 2005 05:59 PM UTC
Are you using hierarchical data? If state is teh GridBoundRecordState, are you using code like:
DataRowView drv = state.Table[state.Position] as DataRowView;
to get at the DataRowView?
If this does not help, post the code you are trying to use.
KL
Ken Lee
November 2, 2005 05:59 PM UTC
if( e.ColIndex==_GridCustomerInfo.Binder.NameToColIndex("AltName") && e.RowIndex>0 && e.ColIndex>0)
{
int _Position = _GridCustomerInfo.Binder.RowIndexToPosition( e.RowIndex);
GridBoundRecordState _RecordState = _GridCustomerInfo.Binder.GetRecordStateAtRowIndex( e.RowIndex);
if( _RecordState!=null)
{
System.Data.DataRowView _DRV = _RecordState.ListManager.Current as System.Data.DataRowView;
if( _DRV!=null)
{
ROW_OB_CUSTOMERINFO _CurrentRow = _DRV.Row as ROW_OB_CUSTOMERINFO;
if( _CurrentRow.CUSTOMERTYPE=="PE" )
{
e.Style.CellValue = String.Format( "{0}", _CurrentRow.FULLNAME);
}
else
{
e.Style.CellValue = String.Format( "{0}", _CurrentRow.COMPANYNAME);
}
Console.WriteLine( "Position:{0}, Row:{1}, Col:{2}, Pos:{3}, CustomerID:{4}", new object[] {_Position, e.RowIndex, e.ColIndex, _RecordState.Position, _CurrentRow.CUSTOMERID});
e.Handled = true;
}
}
}
KL
Ken Lee
November 2, 2005 06:14 PM UTC
Sorry, It''s work as your mention.
The other point when I click on the unbound cell, in the first column should have array icon that show the current position, but it was not display, when click on the bound cell is normally shown, what''s happen in this case ? thanks.
AD
Administrator
Syncfusion Team
November 2, 2005 06:27 PM UTC
System.Data.DataRowView _DRV = _RecordState.ListManager.Current as System.Data.DataRowView;
This does not give you the datarowview of the grid row being drawn. It gives you the datarowview corresponding to the row with the triangle in the row header. QueryCellInfo is hit for any row that needs to be drawn, not just the current one (the one pointed to by the CurrencyManager).
If you are using hierarchical data, you should try the code I suggested above. If it is a flat grid, then you can get the DataRowView using:
int position = grid.Binder.RowIndexToPosition(e.RowIndex);
CurrencyManager cm = grid.BindingContext[grid.DataSource, grid.DataMember] as CurrencyManager;
DataRowView drv = cm.List[position] as DataRowView;
KL
Ken Lee
November 2, 2005 07:17 PM UTC
It did help to me
Thanks Clay Burch