Skip to main content
edited title
Link
Yakov
  • 292
  • 2
  • 13

C#: From, Forms, DataGridView. Unexpected Visible behaviour

added 184 characters in body
Source Link
Yakov
  • 292
  • 2
  • 13

I working on application with DataGridView.
It contains several tabs, each tab includes a DataGridView of some parameters. I need implement Admin and User modes, where each grid table should hide some rows according to the mode.
I have a problem with the hiding: on some tabs the hiding work perfect on other doesn't work absolutely.
I did some tests: hid all rows of problematic grid, printed Visible values after delay.
usedgrid.CurrentCell = null.
I didn't found any mistake that point to the reason of the problem. I use the same method for all:

private void HideParameter(DataGridView grid, string ParamName) { CurrencyManager CM = (CurrencyManager)BindingContext[grid.DataSource]; CM.SuspendBinding(); for (int i = 0; i < grid.Rows.Count; i++) { string Val = grid.Rows[i].Cells[0].Value.ToString(); if (Val.Contains(ParamName)) { //grid.CurrentCell = null; grid.Rows[i].Visible = false; } } CM.ResumeBinding(); } 

Grid binding:

void BindGridWithDataSource(DataTable dt, DataGridView grid) { BindingSource bs = new BindingSource(); bs.DataSource = dt; grid.DataSource = bs; } 

<brPicture of the tabs>

I working on application with DataGridView.
It contains several tabs, each tab includes a DataGridView of some parameters. I need implement Admin and User modes, where each grid table should hide some rows according to the mode.
I have a problem with the hiding: on some tabs the hiding work perfect on other doesn't work absolutely.
I did some tests: hid all rows of problematic grid, printed Visible values after delay.
usedgrid.CurrentCell = null.
I didn't found any mistake that point to the reason of the problem. I use the same method for all:

private void HideParameter(DataGridView grid, string ParamName) { CurrencyManager CM = (CurrencyManager)BindingContext[grid.DataSource]; CM.SuspendBinding(); for (int i = 0; i < grid.Rows.Count; i++) { string Val = grid.Rows[i].Cells[0].Value.ToString(); if (Val.Contains(ParamName)) { //grid.CurrentCell = null; grid.Rows[i].Visible = false; } } CM.ResumeBinding(); } 

<brPicture of the tabs>

I working on application with DataGridView.
It contains several tabs, each tab includes a DataGridView of some parameters. I need implement Admin and User modes, where each grid table should hide some rows according to the mode.
I have a problem with the hiding: on some tabs the hiding work perfect on other doesn't work absolutely.
I did some tests: hid all rows of problematic grid, printed Visible values after delay.
usedgrid.CurrentCell = null.
I didn't found any mistake that point to the reason of the problem. I use the same method for all:

private void HideParameter(DataGridView grid, string ParamName) { CurrencyManager CM = (CurrencyManager)BindingContext[grid.DataSource]; CM.SuspendBinding(); for (int i = 0; i < grid.Rows.Count; i++) { string Val = grid.Rows[i].Cells[0].Value.ToString(); if (Val.Contains(ParamName)) { //grid.CurrentCell = null; grid.Rows[i].Visible = false; } } CM.ResumeBinding(); } 

Grid binding:

void BindGridWithDataSource(DataTable dt, DataGridView grid) { BindingSource bs = new BindingSource(); bs.DataSource = dt; grid.DataSource = bs; } 

<brPicture of the tabs>

Source Link
Yakov
  • 292
  • 2
  • 13

C#: From DataGridView. Unexpected Visible behaviour

I working on application with DataGridView.
It contains several tabs, each tab includes a DataGridView of some parameters. I need implement Admin and User modes, where each grid table should hide some rows according to the mode.
I have a problem with the hiding: on some tabs the hiding work perfect on other doesn't work absolutely.
I did some tests: hid all rows of problematic grid, printed Visible values after delay.
usedgrid.CurrentCell = null.
I didn't found any mistake that point to the reason of the problem. I use the same method for all:

private void HideParameter(DataGridView grid, string ParamName) { CurrencyManager CM = (CurrencyManager)BindingContext[grid.DataSource]; CM.SuspendBinding(); for (int i = 0; i < grid.Rows.Count; i++) { string Val = grid.Rows[i].Cells[0].Value.ToString(); if (Val.Contains(ParamName)) { //grid.CurrentCell = null; grid.Rows[i].Visible = false; } } CM.ResumeBinding(); } 

<brPicture of the tabs>