Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have gridview with a combo box column Named ColumnLocationDemo. I want to ensure that user every time selected distinct option from comobox. i am trying this code message box appearing but dont know how to change the index of columnLocationDemo
C#
private void dataGridView1_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            string str1 = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            for (int i = 0; i < dataGridView1.Rows.Count - 2; i++)
            {
                string str = dataGridView1.Rows[i].Cells[1].Value.ToString();
                if (str==str1)
                {
                    MessageBox.Show("same occur");
                    ColumnLocationDemo
                }
            }


        }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900