You are
clearing the Text of a specific Column's header.
At
design-time you can set
all Headers visibility in the Property Browser: [
^]
At
run-time you can set the property in code:
dataGridView1.ColumnHeadersVisible = false;
To set a
specific Column header visibility:
0) you will find 'visible properties on row[#n].Cells[0] header cells, and on on column[#n] headers, but,
those properties are read-only.
1) clear the Text, but save the Text first, restore it later, as necessary
1a) write code to record the current Columm Header Text properties when your app loads.
1b) create a map of Column Header Text values.
1c) write a function to clear or restore a specific Column's Header Text using 1a( and 1b)
1d) see code ideas below
2) set the specific column's header Cell visibility [
^] (not recommended unless you are an advanced WinForm programmer).
Code ideas ...
note: i do not provide full working code solutions because i am here to teach, and, if you learn to write the missing code, you will learn something valuable you can re-use in the future. If you get started using these code ideas, and ask specific questions about the code you show me, i'll be happy to respond.
1) to save the values of all current Columns' header Text; you write the code to initialize this List in the appropriate place:
private List<string> CurrentColumnHeaderText = new List<string>();
2) you write functions like these;
private void UpdateSavedHeaderText(DataGridViewColumn col)
{
}
publicvoid SetColHeaderVisibility(int columnndx, bool RestoreOrClear)
{
DataGridViewColumn col = dataGridView1.Columns[columnndx];
if (RestoreOrClear)
{
}
else
{
if (CurrentColumnHeaderText[col.Index] != col.HeaderText)
{
UpdateSavedHeaderText(col);
}
}
dataGridView1.Invalidate();
}
private void RestoreHeaderText(DataGridViewColumn column)
{
}