Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
22307 | Dec 9,2004 11:42 AM UTC | Apr 28,2005 12:46 AM UTC | WinForms | 18 |
![]() |
Tags: Grouping |
private void gridGroupingControl1_TableControlCurrentCellValidating(object sender, GridTableControlCancelEventArgs e) { GridCurrentCell cc = e.TableControl.CurrentCell; GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex]; if(style.TableCellIdentity.TableCellType == GridTableCellType.AddNewRecordFieldCell) { string colName = style.TableCellIdentity.Column.MappingName; object newValue = cc.Renderer.ControlValue; foreach(Record r in e.TableControl.Table.Records) { if(r.GetValue(colName).Equals(newValue)) { //duplicate found e.Inner.Cancel = true; } } } }
private void gridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
Record r = e.Record as Record;
if (r != null && e.Action == CurrentRecordAction.EndEditCalled)
{
try
{
object id = r.GetValue("CategoryID");
if (id is DBNull || (int) id > 4)
{
object desc = r.GetValue("Description");
if (desc is DBNull || desc.ToString() == "")
{
e.Cancel = true;
MessageBox.Show("Error: Category > 10 or Categort null and Description empty");
}
}
}
catch (Exception ex)
{
e.Cancel = true;
MessageBox.Show(ex.Message);
}
}
}
You can download a sample project here:
CS.zip
Stefan
>the sample codes work if the check is performed on a single column. what if i want to perform it on 2 columns. ensuring column 1 do not have duplicate, and column 2 cannot be empty? if (r != null && (e.Action == CurrentRecordAction.EndEditCalled || e.Action == CurrentRecordAction.NavigateCalled)) {
>if (r != null && > (e.Action == CurrentRecordAction.EndEditCalled > || e.Action == CurrentRecordAction.NavigateCalled)) >{ >
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.