Click here to Skip to main content
11,479,486 members (45,237 online)
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 15-Jan-13 0:39am
Edited 15-Jan-13 0:42am
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 OriginalGriff 285
1 Sergey Alexandrovich Kryukov 215
2 F-ES Sitecore 175
3 Richard MacCutchan 125
4 Frankie-C 104
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,441
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web01 | 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