I have agrid with an unbound column. The column is of type string, and is defined inthe grid_init method. Then in th einit_row I set an initial value, which works. But then in code I need to change the value, but it does not change. Can anyone tell me why. I am sure it is something obvious.
Please see my code below
//From grid_Initialize method
if (!e.Layout.Bands[0].Columns.Exists("Desc")){ e.Layout.Bands[0].Columns.Add("Desc");}
foreach (var col in e.Layout.Bands[0].Columns){ switch (col.Key) { case @"Desc": col.Header.Caption = "Description"; col.Header.VisiblePosition = 0; col.DataType = Type.GetType("System.String"); col.DefaultCellValue = ""; break;
case PoSModifierItem.UnitCostField: col.Header.Caption = "Price"; col.Format = "c"; col.Header.VisiblePosition = 1; break;
default: col.Hidden = true; break; }}
private void _ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e){ e.Row.Cells["Desc"].Value = e.Row.Cells[PoSModifierItem.DescriptionField].Value;}
private void _cmdApply_Click(object sender, EventArgs e){ foreach (var row in _ultraGrid1.Selected.Rows) { switch ((int)_txtAdjustment.Value) { case 0: row.Cells["Desc"].Value = row.Cells[PoSModifierItem.DescriptionField].Value; break; case 1: row.Cells["Desc"].SetValue(String.Format("{0}{1}", "Light ", row.Cells[PoSModifierItem.DescriptionField].Value), false); break; } }}
Hello,
Could you please clarify what are '_txtAdjustment' and 'PosModifierItem' or either if possible try to attach a small sample project reproducing your issue. I will be happy to take a look at it.
Please do not hesitate to contact us if you need any additional assistance.
Hi Boris,
_txtAdjustment is a comboeditor control that we just select one of two options that have a numeric value as per the switch options.
PoSModifierItem is a class, the UnitPriceField etc are constant string that hold the names of the fields, hence the names of the columns.
The only part of the program that does not appear to work is where we use the row.Cells["Desc"].Value = ....... and the row.Cells["Desc"].SetValue(...) lines. Neither line throws an error, but they also do not set the value in the "Desc" column. The "Desc" column is an unbound column as you can see from the start of the code.
Hello townsma,This was fixed. Were you able to test your application now with the latest service release for 12.1? Please do not hesitate to contact me if you need any additional assistance.
Hello townsma,
I have created the following case for you: 'CAS-86303-KXBXXG' and will update you through it.
The InitializeRow event is intended allow you to do things like change the appearance of a row or cell based on a value in that row. Or to perform calculations and populate cell values in the row based on the values of other cells in the same row.
As such, it is supposed to fire initially, the first time the row is created, and also any time any value in any cell of the row is changed.
This is why there is a ReInitialize flag on the event args, so that you know if it's firing for the first time or not.
I agree that the documentation could be a lot clearer, so I think this should be written up as a bug in the documentation so we can get it corrected.
I have read that page, several times recently in fact, and it agrees with me, and I quote.
'This event is generated once for each row being displayed or printed and provides an opportunity to perform actions on the row before it is rendered, such as populating an unbound cell or changing a cell's color based on its value."
It should only fire when the row is initially displayed, i.e grid populated, or repopulated. It should not fire because I change the value of a single unbound cell in code.
I have been using UltraWinGrid since it was still called Sheriden Grid. I know when these events are supposed to fire, and changing the value of any cell using code is not supposed to re-initialize the row.
I have implemented the work around to check if this is a re-init as opposed to the initial init, and it solves my immediate problem. However, I should not need to do that, so I suggest you pass this along to the developers, as this is a bug, whether you wish to admit it or not.
I believe that this is by design and is not an issue in our control. Could you please take a look at the following link and especially at the last section 'Remarks':
http://help.infragistics.com/NetAdvantage/WinForms/2011.2/CLR2.0/?page=Infragistics2.Win.UltraWinGrid.v11.2~Infragistics.Win.UltraWinGrid.UltraGrid~InitializeRow_EV.html.