Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
575
How to identify the duplicate cell
posted

Hi,

 

I am using this code but it has a couple of problems: 1. it does not focus to that cell 2. I see some other problems, such that if I move away and then change the cell it does not complain again!

 

        void gridDiscounts_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
        {
            this.IsDirty = true;
            if (e.Cell.Column.Key == "Name")
            {
                foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in this.gridDiscounts.Rows)
                {
                    if (e.Cell.Row != row)
                    {
                        if (e.Cell.Value != null && row.Cells["Name"].Value != null && e.Cell.Value != DBNull.Value
                            && row.Cells["Name"].Value != DBNull.Value)
                        {
                            if (String.Compare(e.Cell.Value.ToString(), row.Cells["Name"].Value.ToString(), true) == 0)
                            {
                                MessageBox.Show("This name already exists");
                                e.Cell.Row.Activate();
                                e.Cell.CancelUpdate();
                                e.Cell.Activate();
                                e.Cell.SelectAll();
                                e.Cell.Value = e.Cell.OriginalValue;
                          
                                break;
                            }
                        }
                    }
                }
            }
        }

  • 48586
    posted

    Hello, ­­­­­

     

    I am just checking about the progress of this issue. Let me know If you need my further assistance on this  issue?

     

    Thank you for using Infragistics Components.

  • 48586
    posted

    Hi,

     

    I just wanted to know if you were able to solve your issue based on Mike's suggestions or you still need help? Just let me know.

    Thank you.

  • 48586
    posted

    Hello ,

     

    If you are using a DataTable for your underling data source, you could use Unique property of the DataColumn of the DataTable. More about this property you could find here:

     

    http://msdn.microsoft.com/en-us/library/system.data.datacolumn.unique%28v=vs.71%29.aspx

     

    if you set it to true, it will prevent having a cells with duplicate values in the DataTable and also in the UltraGrid.

     

    Please let me know if you have any further questions .