I am trying to add a new row to my grouping list. I created a sfdatagrid source which is set to a list.
sfDataGrid1.DataSource = workloadGridViewList.ToList();
I have a button, which then "adds" to to this workloadgridview list however the sfdatagrid does not update. I typically am able to update the sfdatagrid view when I have it bound to a bounded datasource table and works fine when updating the table, but in this case I am using a list.
Right now I am able to modify the workloadgridviewlist by adding a new entry, however it does not update the sfdatagridview. I tried setting the sfdatagrid.datasource to the new workloadgridviewlist however by doing this, it removes the grouping. If I add the grouping again to the code, it will cause the sfdatagrid view to collapse in which that is not what I want.
I used the view.createrecordEntry as well as view.records.add functions but nothing seems to be updating the view.
public class WorkloadGrid
{
[DisplayName("Project #")]
public string Project { get; set; }
[DisplayName("number1")]
public int number1 { get; set; }
}
List<WorkloadGrid> workloadGridViewList = new List<WorkloadGrid>();
private void sfButton1_Click(object sender, EventArgs e)
{
WorkloadGrid workloadObj = new WorkloadGrid();
workloadObj.Project = "HIHI";
workloadObj.number1 = 1;
workloadGridViewList.Add(workloadObj);
//If i do the sfDataGrid1.DataSource = workloadGridViewList.ToList(); my grouping will get messed up
//sfDataGrid1.DataSource = workloadGridViewList.ToList();
var record = sfDataGrid1.View.CreateRecordEntry(workloadObj);
sfDataGrid1.View.Records.Insert(0, record);
}
private void Form1_Load(object sender, EventArgs e)
{
for (var i = 0; i < 5; i++)
{
WorkloadGrid workloadObji = new WorkloadGrid();
workloadObji.Project = i.ToString() ;
workloadObji.number1 = i;
workloadGridViewList.Add(workloadObji);
}
sfDataGrid1.DataSource = workloadGridViewList.ToList();
}