Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
Hide button code as follows;
 
 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 15-Jan-13 0:13am
Edited 15-Jan-13 0:14am
digimanus28.3K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I dont quite understand your question but here is a code snippet, is this what you were looking for?
 
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;
          }
     }
}
  Permalink  
v2
Comments
jibesh at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 505
1 OriginalGriff 248
2 ChintanShukla 185
3 Richard Deeming 175
4 Bhavik_Patel 170
0 Sergey Alexandrovich Kryukov 8,688
1 OriginalGriff 7,237
2 CPallini 2,598
3 Richard MacCutchan 2,080
4 Abhinav S 1,888


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100