Click here to Skip to main content
14,980,646 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i hide the particular column name from data grid view.

Code as follows;

i have one button called Hide.
C#
private void Btn_Hide_Click(object sender, EventArgs e)
        {
            //confirmation to Hide the column
            datagridView.Columns[datagridView.CurrentCellAddress.X].Visible = false;
        }
when i click the Hide button that partiuclar column will hide in data grid view.

Before Hiding to the particular column in data grid view user have to confirm suppose in that column values are there to check.

for that how to validate.please send the code.
Posted
Updated 14-Jan-13 22:09pm
v2

Hi,

Just popup a Confirm Message Box.

ASP[^]Windows[^]
   
Check out Window.DialogResult[^]
C#
private void Btn_Hide_Click(object sender, EventArgs e)
{
  DialogResult dialogResult = MessageBox.Show("Sure", "Some Title",    MessageBoxButtons.YesNo);
  if(dialogResult == DialogResult.Yes)
  {
    //confirmation to Hide the column
            datagridView.Columns[datagridView.CurrentCellAddress.X].Visible = false;
  }
  else if (dialogResult == DialogResult.No)
  {
    //do something else
  }
}


Good luck,
OI
   

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