i try this code and it's trow exception from Program.cs
this.sfDataGrid1.DrawCell += SfDataGrid1_DrawCell;
private void SfDataGrid1_DrawCell(object sender, DrawCellEventArgs e)
{
if (sfDataGrid1.ShowRowHeader && e.RowIndex != 0)
{
if (e.ColumnIndex == 0)
{
e.DisplayText = e.RowIndex.ToString();
}
}
}
there is another issue when I add a new row if add new row position is fixed at the bottom, it makes an empty record but fixed at the top it isn't
|
this.sfDataGrid.AddNewRowPosition = RowPosition.FixedTop;
this.sfDataGrid.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning;
or
this.sfDataGrid.AddNewRowPosition = RowPosition.FixedBottom;
this.sfDataGrid.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd; |
|
if i press enter when adding new record it makes empty record |
By default, when pressing enter key with editing in AddNewRow cell, new row will be committed to the View with the default value from the underlying collection. Since DataTable has null default value, empty record is added to the view. This is the default behavior. | |
|
some time if click add new row cell and typing it's trow exception from program.cs |
We have tried the maximum possibilities to reproduce the reported exception, but we could not reproduce the exception.
On analyzing the provided screenshot, we suspect that you are using tooltip.
The built-in tooltip support for SfDataGrid could not reproduce the reported exception. We suspect that you are customizing the built-in tooltip or showing the tooltip using SfToolTip component externally.
So, could you please share us the customization or settings for tooltip if any or if using SfToolTip, please let us know the settings of showing the tooltip? Or let us know the replication of the exception clearly. | |
|
To delete the empty row added |
Instead of removing the empty record, you can prevent adding the empty record itself by validating the adding row in RowValidating event. Please refer to the below modified code example.
Code Example:
|
|
void sfDataGrid_DrawCell(object sender, Syncfusion.WinForms.DataGrid.Events.DrawCellEventArgs e)
{
if (sfDataGrid.ShowRowHeader && e.RowIndex != 0)
{
if (e.ColumnIndex == 0)
{
e.DisplayText = e.RowIndex.ToString();
}
}
} |
|
<Reference Include="Syncfusion.SfDataGrid.WinForms, Version= 16.1400.0.37, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<!--</Change the above code like as below>-->
<Reference Include="Syncfusion.SfDataGrid.WinForms" /> |