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.