I'm currently working on upgrading a Vb6 app that used Flexgrid to C#, and one of the requirements is to have several dynamically added columns added to the end of the bound data where the user inputs data.
AllowEditing is enabled on the entire grid at present to allow me to test some things out, and i've found that i'm able to manipulate data programmatically or manually on the grid if it the column I am editing is one of the bound columns, however if I try and edit one of the unbound columns, it lets me input the value then it dissapears as soon as I leave the cell.
This is the code I have adding the Dynamic Columns and setting their data:
foreach (var O in Orders)
{
if (!AddedOrders.Contains(O.L.Order))
{
c1FlexGrid1.Cols.Add(2);
c1FlexGrid1.Cols[c1FlexGrid1.Cols.Count - 2].Caption = "Cus " + (AddedOrders.Count + 1).ToString();
c1FlexGrid1.Cols[c1FlexGrid1.Cols.Count - 2].Name = "Cus " + (AddedOrders.Count + 1).ToString();
c1FlexGrid1.Cols[c1FlexGrid1.Cols.Count - 2].DataType = typeof(string);
c1FlexGrid1.Cols[c1FlexGrid1.Cols.Count - 1].Caption = "Qty " + (AddedOrders.Count + 1).ToString();
c1FlexGrid1.Cols[c1FlexGrid1.Cols.Count - 1].Name = "Qty " + (AddedOrders.Count + 1).ToString();
c1FlexGrid1.Cols[c1FlexGrid1.Cols.Count - 1].DataType = typeof(int);
bool Res = c1FlexGrid1.SetData(1, c1FlexGrid1.Cols.Count - 2, O.C.Company, true);
c1FlexGrid1.SetData(2, c1FlexGrid1.Cols.Count - 2, O.L.Order, true);
c1FlexGrid1.SetData(3, c1FlexGrid1.Cols.Count - 2, O.L.Confirmed, true);
c1FlexGrid1.SetData(4, c1FlexGrid1.Cols.Count - 2, O.L.Variety, true);
c1FlexGrid1.SetData(1, c1FlexGrid1.Cols.Count - 1 , 0);
CustCols.Add(c1FlexGrid1.Cols.Count - 2);
AddedOrders.Add(O.L.Order);
}
}
The bool I added was to test that the function was returning true, which it is, so as far as the code as concerned it appears as if it successfully set the value.
So in short - How to do I allow editing of unbound columns in a bound Flexgrid?