private void button1_Click(object sender, EventArgs e)
{
if (sfDataGrid.SelectedItem != null)
{
var orderInfo = (sfDataGrid.SelectedItem as OrderInfo);
if (!string.IsNullOrEmpty(orderInfo.Country) &&
!string.IsNullOrEmpty(orderInfo.CustomerID) &&
!string.IsNullOrEmpty(orderInfo.CustomerName))
{
// You can save the edit value here.
}
}
} |
sfDataGrid.RowValidating += SfDataGrid_RowValidating;
private void SfDataGrid_RowValidating(object sender, Syncfusion.WinForms.DataGrid.Events.RowValidatingEventArgs e)
{
if (sfDataGrid.IsAddNewRowIndex(e.DataRow.RowIndex))
{
var data = (e.DataRow.RowData as DataRowView).Row;
if (string.IsNullOrEmpty(data.ItemArray[0].ToString()) || string.IsNullOrEmpty(data.ItemArray[1].ToString()) || string.IsNullOrEmpty(data.ItemArray[2].ToString()))
{
e.ErrorMessage = "Records cannot be empty";
e.IsValid = false;
}
}
} |