11-11-15, 04:17 AM
بعد البحث وطرح السؤال في المنتديات الاجنبيه (stackoverflow+codeproject.+componentone) تمت الاجابه واود وضعها هنا في المنتدي عسي ان يستفيد منها غيري خصوصا ان هذه الأداه لم اكتشف اي شرح عربي لها كمثل DataGridView
---------------
---------------
In order to prevent the user from entering duplicate entries into the cell of C1TrueDBGrid, you can use the same “BeforeColUpdate” event. But the implementation needs to be changed.
When the user enters the text in the cell, it acts as the text of the Editor of C1TrueDBGrid and before it gets commit in the cell it cannot be read on the grid level.
So in the event, you need to match the Text of the Editor with the text of the cells of C1TrueDBGrid and if the data is present in any other cell, notify the user about the same. Here is the code snippet:
When the user enters the text in the cell, it acts as the text of the Editor of C1TrueDBGrid and before it gets commit in the cell it cannot be read on the grid level.
So in the event, you need to match the Text of the Editor with the text of the cells of C1TrueDBGrid and if the data is present in any other cell, notify the user about the same. Here is the code snippet:
كود :
private void c1TrueDBGrid1_BeforeColUpdate(object sender, C1.Win.C1TrueDBGrid.BeforeColUpdateEventArgs e)
{
if (e.ColIndex == 1)
{
for (int i = 0; i < c1TrueDBGrid1.RowCount; i++)
{
if (c1TrueDBGrid1.Editor.Text == c1TrueDBGrid1[i, e.ColIndex].ToString())
{
MessageBox.Show("Sorry: but this item(s) already Exists", "Error Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Cancel = true;
}
}
}
}