Click here to Skip to main content
11,495,486 members (64,827 online)
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 1:13am
Edited 15-Jan-13 1:14am
digimanus35.1K
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 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 265
3 Nakul Chaudhari 236
4 OriginalGriff 191
0 Sergey Alexandrovich Kryukov 10,322
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,889
3 Maciej Los 3,422
4 Richard Deeming 2,560


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2015
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