hi,
I'm using the UltraWinGrid and I'm facing a problem with setting a value for a cell for groupby row.
For retrieving the value from cell I tried like this.
this.Day = ((DataRowView)((UltraGrid)sender).ActiveRow.ListObject).Row["Day"].ToString();
Using this I got what I wanted. But I want to set a value for a cell so how can I achieve this?
Please guide me on the same.
You don't say where you're getting the NullReferenceException, but if I were to guess, I'd say it's when you try to access the Value property of the Cells["Icon"], or possibly the row is null if you don't have as many GroupByRows. When you perform a GroupBy operation, the root Rows collection of the grid will now contain GroupByRows and not regular rows. Instead of storing the index, why not just hold onto a reference to the action grid row; that way, you don't have to worry about later locating that row to change its icon.
-Matt
yes it works. but when the grid is group by it throws null reference exception.
Actually I have to set an icon to the active row. for that I handle BeforeRowDeactivate and AfterRowActivate events of the grid control like this.
private void dgvViewSchdule_BeforeRowDeactivate(object sender, System.ComponentModel.CancelEventArgs e)
{
_deactivatedRowIndex = dgvViewSchdule.ActiveRow.Index;
}
private void dgvViewSchdule_AfterRowActivate(object sender, EventArgs e)
//to clear the deactivated row icon
dgvViewSchdule.Rows[dgvViewSchdule.ActiveRow.Index].Cells["Icon"].Appearance.ImageHAlign = HAlign.Center;
dgvViewSchdule.Rows[dgvViewSchdule.ActiveRow.Index].Cells["Icon"].Appearance.ImageVAlign = VAlign.Middle;
the code above works when the grid is not group by but fails when I try to group by the grid.
I also tried to implement the same thing using InitializeRow event but I didn't work.
Thanks.
What part of setting the value is giving you trouble? You should just be able to do grid.ActiveRow.Cells["Day"].Value = something.