Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
Hide button code as follows;

C#
private void Btn_Hide_Click(object sender, EventArgs e)
       {
 if (MessageBox.Show("Are You sure, You want to Hide?", "Hide confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
           {
               datagridView.Columns[datagridView.CurrentCellAddress.X].Visible = false;
           }

       }


from the above code when i click the hide button the message popups Are You sure, You want to Hide?.

but before this message shows,
for that column the course is there do u want to clear if user says yes clear the item and hide the particular column.

Output as follows;
Hide (Button)

Date Session RK Mk GS VB

1/7/2013 1 tam (course)
2/7/2013 2

when i click the hide button validate for that RK column tam value is there.

first do u want to clear the tam (course) if user says yes clear the tam course and then hide the column.

how to validate to clear the tam course
Posted
Updated 15-Jan-13 0:14am
v2

1 solution

I dont quite understand your question but here is a code snippet, is this what you were looking for?

C#
private void button1_Click(object sender, EventArgs e)
{
     if (string.IsNullOrEmpty(dataGridView1.CurrentRow.Cells["Column Name"].Value.ToString()))
     {
          if (MessageBox.Show("Are You sure, You want to Hide?", "Hide confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
          {
               dataGridView1.Columns[dataGridView1.CurrentCellAddress.X].Visible = false;
          }
     }
     else
     {
          if (MessageBox.Show("Are You sure you want to clear course?", "Clear Course", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
          {
               dataGridView1.Columns[dataGridView1.CurrentCellAddress.X].Visible = false;
          }
     }
}
 
Share this answer
 
v2
Comments
Jibesh 15-Jan-13 19:10pm    
do add the Cell clear code to the else part. OP says clear the course and hide the column if Course cell has any value

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