Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
when i hid the particular column i don't want to hid the date and session in data grid view.
 

for that how to validate.
 

Hide button code as follows;

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;
            }
 
Output as follows; Hide(Button)
 
DATE SESSION RK Mk CK VB GS CMK UNNI
 
1//2013 1
 

in that when i click the hide button,in that column values is there that validation is working fine. no problem.
 

But i don't to hide the DATE and SESSION Column always in data grid view.
 
for that validation how to write the code.
Posted 14-Jan-13 23:39pm
Edited 14-Jan-13 23:42pm
v2

1 solution

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

Solution 1

void HideButton_Click(object sender, EventArgs e)
{
    DataGridViewColumn column
        = datagridView.Columns[datagridView.CurrentCellAddress.X];
    if(
        column == _dateColumn
        || column == _sessionColumn
    )
    // Both mentioned columns shall not be hidden.
    {
        return;
    }
 
    if (MessageBox.Show("Are You sure, You want to Hide", "Hide confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
    {
        column.Visible = false;
    }
}
  Permalink  

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 509
1 Nirav Prabtani 298
2 OriginalGriff 215
3 _Amy 165
4 Abhinav S 160
0 OriginalGriff 7,715
1 Sergey Alexandrovich Kryukov 6,911
2 Maciej Los 3,954
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web04 | 2.8.140721.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