Ok, this has been driving me crackers for a couple of hours now. I'm a newbie to UltraGrid
I have a databound UltraGrid. I added an extra column with an icon and text in it with the following:-
private void ugrBlah_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e){ // Add new column for padlock (if it's not already there) if (!e.Layout.Bands[0].Columns.Contains("IsLocked")) e.Layout.Bands[0].Columns.Add("IsLocked", "Locked");}private void ugrBlah_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e){ e.Row.Cells["IsLocked"].Appearance.Image = Properties.Resources.padlock; e.Row.Cells["IsLocked"].Value = "Cheese";}
Which works fine... I get a nice padlock icon with "Cheese" next to it. Padlocked cheese.
But then, in response to a button click, I want the currently selected / lit / active row to change icon and text. I've tried the following:-
ugrBlah.ActiveRow.Cells["IsLocked"].Value = "Cake";ugrBlah.ActiveRow.Cells["IsLocked"].Appearance.Image = Properties.Resources.padlock_open;
It changes the icon, but not the text Value.
I have tried ...ActiveRow.Update(), and ugrBlah.Refresh(), both to no avail.
Any ideas anybody?
Are you sure that the row that you're trying to change is the active row? Are you clicking a button in a grid column, or is it a button outside of the grid? The following code worked for me:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e){ UltraGridColumn col = e.Layout.Bands[0].Columns.Add("Button"); col.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button; col = e.Layout.Bands[0].Columns.Add("Food"); }private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e){ e.Cell.Row.Cells["Food"].Value = "The cake is a lie"; e.Cell.Row.Cells["Food"].Appearance.Image = Image.FromFile("images.jpg");}private void button1_Click(object sender, EventArgs e){ this.ultraGrid1.ActiveRow.Cells["Food"].Value = "The cake is a lie"; this.ultraGrid1.ActiveRow.Cells["Food"].Appearance.Image = Image.FromFile("images.jpg");}
The code worked for both a cell button and grid button. It's possible the row is selected, but not active. If you're positive it's the correct row and it's active, I'm not sure what's going on; perhaps you should make sure you have the latest hotfix.
-Matt