Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Design as follows in datagridview;

i have two checkbox as follows;
Session1 (sess1) session4 (sess4)

i have two columns above i mentioned session1 and session4.

when i select the Sess4(check box) i want sess1 (Check Box to be unchecked)

for that how can i do? using csharp.

Please help me.

from the below code what i done is when i click the sess4 checkbox i show the pop up message.
but when i click the sess4 checkbox i want the sess1 checkbox to be unchecked.

for that how can i write the code.

My Code as follows;

C#
private void DGVCalendar_CellContentClick(object sender, DataGridViewCellEventArgs e)
       {

          if (e.ColumnIndex == DGVCalendar.Columns["Sess4"].Index)
           {MessageBox.Show("Don't Select session if you don't have any session on that day = " + DGVCalendar.Rows[e.RowIndex].Cells[2].Value.ToString());

           }
       }
Posted
Updated 6-Mar-13 22:17pm
v2

1 solution

try this,
C#
private void DGVCalendar_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            try
            {


                DataGridView dgv = (DataGridView)sender;
                DataGridViewCell cell = dgv.CurrentCell;
                if (cell.RowIndex > -1 && (cell.ColumnIndex == 1 || cell.ColumnIndex == 2))
                {
                    if (cell.ColumnIndex == 1)
                    {
                        DGVCalendar.Rows[cell.RowIndex].Cells[1].Value = true;
                        DGVCalendar.Rows[cell.RowIndex].Cells[2].Value = false;
                    }
                    else
                    {
                        DGVCalendar.Rows[cell.RowIndex].Cells[2].Value = true;
                        DGVCalendar.Rows[cell.RowIndex].Cells[1].Value = false;                    
                    }                    
                }
            }
            catch (Exception exc)
            {

                exc.ToString();
            }
        }
 
Share this answer
 

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