How can i stop blinking when update SfDataGrid's datasource
i tried beginupdate() suspendlayout() and doublebuffered
private void GridSettings()
{
if (!sfDataGrid2.AllowEditing)
{
foreach (DataRow dr in FrmColSettingDT.Rows)
{
sfDataGrid2.Columns[dr["ColumnName"].ToString()].HeaderText = dr["Text"].ToString();
sfDataGrid2.Columns[dr["ColumnName"].ToString()].Visible = Convert.ToBoolean(dr["IsVisible"]);
}
}
else
{
foreach (DataRow dr in FrmColSettingDT.Rows)
{
sfDataGrid2.Columns[dr["ColumnName"].ToString()].HeaderText = dr["Text"].ToString();
sfDataGrid2.Columns[dr["ColumnName"].ToString()].Visible = Convert.ToBoolean(dr["IsVisible"]);
// sfDataGrid2.Columns[dr["ColumnName"].ToString()].AllowEditing = Convert.ToBoolean(dr["IsLocked"]);
}
}
sfDataGrid2.Columns[0].Visible = false;
sfDataGrid2.ShowRowHeader = true;
if (IsNewRowCanBeAdded)
{
sfDataGrid2.AddNewRowPosition = Syncfusion.WinForms.DataGrid.Enums.RowPosition.FixedBottom;
}
else
{
sfDataGrid2.AddNewRowPosition = Syncfusion.WinForms.DataGrid.Enums.RowPosition.None;
}
}
{
if (!sfDataGrid2.AllowEditing)
{
foreach (DataRow dr in FrmColSettingDT.Rows)
{
sfDataGrid2.Columns[dr["ColumnName"].ToString()].HeaderText = dr["Text"].ToString();
sfDataGrid2.Columns[dr["ColumnName"].ToString()].Visible = Convert.ToBoolean(dr["IsVisible"]);
}
}
else
{
foreach (DataRow dr in FrmColSettingDT.Rows)
{
sfDataGrid2.Columns[dr["ColumnName"].ToString()].HeaderText = dr["Text"].ToString();
sfDataGrid2.Columns[dr["ColumnName"].ToString()].Visible = Convert.ToBoolean(dr["IsVisible"]);
// sfDataGrid2.Columns[dr["ColumnName"].ToString()].AllowEditing = Convert.ToBoolean(dr["IsLocked"]);
}
}
sfDataGrid2.Columns[0].Visible = false;
sfDataGrid2.ShowRowHeader = true;
if (IsNewRowCanBeAdded)
{
sfDataGrid2.AddNewRowPosition = Syncfusion.WinForms.DataGrid.Enums.RowPosition.FixedBottom;
}
else
{
sfDataGrid2.AddNewRowPosition = Syncfusion.WinForms.DataGrid.Enums.RowPosition.None;
}
}
public void DataGridRefresh()
{
progressManager.StartProgress(this);
sfDataGrid2.CurrentCell.EndEdit(true);
sfDataGrid2.DataSource = sql.ExecuteDataTable(GetProcName, null);
GridSettings();
sfDataGrid2.Refresh();
sfDataGrid2.Update();
progressManager.CloseProgress();
}
{
progressManager.StartProgress(this);
sfDataGrid2.CurrentCell.EndEdit(true);
sfDataGrid2.DataSource = sql.ExecuteDataTable(GetProcName, null);
GridSettings();
sfDataGrid2.Refresh();
sfDataGrid2.Update();
progressManager.CloseProgress();
}
SIGN IN To post a reply.
3 Replies
AK
Adhikesevan Kothandaraman
Syncfusion Team
June 4, 2018 12:51 PM UTC
Hi Eren,
Thanks for contacting syncfusion support.
By default while setting the DataSource for SfDataGrid, the columns will be generated automatically. Since the visibility of the columns gets collapsed after setting the DataSource, the SfDataGrid will be looks like blinking. This can be stopped by setting theAutoGenerateColumnsMode property as SmartReset.
Code Example:
|
this.sfDataGrid1.AutoGenerateColumnsMode = AutoGenerateColumnsMode.SmartReset; |
Sample Location:
UG Link:
https://help.syncfusion.com/windowsforms/sfdatagrid/columns#autogeneratecolumns-with-different-modes
Regards,
Adhi
ER
Eren
June 4, 2018 03:39 PM UTC
Thank you it's work but i have one more question. After calling DataGridRefresh() (sfDataGrid2.View as CollectionViewAdv).CollectionChanged += FrmList_CollectionChanged event dont' triggered when add new row not firing
FP
Farjana Parveen Ayubb
Syncfusion Team
June 5, 2018 11:29 AM UTC
Hi Eren,
Thanks for your update.
By default, SfDataGrid.View will be created after the DataSource is initialized to the SfDataGrid and SfDataGrid.View is based on the DataSource. Since the View of the SfDataGrid is changed due to change in DataSource, events related to View will be unwired. So, whenever the View changes, the events related to View must be wired if any. So we request you to wire the CollectionChanged event of View after changing the DataSource to the SfDataGrid. Please refer the below code example and sample in the following location,
Code Example:
|
public void DataGridRefresh()
{
sfDataGrid1.CurrentCell.EndEdit(true);
sfDataGrid1.ShowRowHeader = true;
sfDataGrid1.DataSource = GetDataTable();
(sfDataGrid1.View as CollectionViewAdv).CollectionChanged += Form1_CollectionChanged;
GridSettings();
} |
Sample Location: http://www.syncfusion.com/downloads/support/forum/137914/ze/WindowsFormsApplication1-299496406
Regards,
Farjana Parveen A
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
ER Eren
- Jun 2, 2018 01:05 PM UTC
- Jun 5, 2018 11:29 AM UTC