4 Replies - 5909 Views - Last Post: 16 July 2010 - 10:24 AM Rate Topic: -----

#1 MarmiteX1  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 159
  • Joined: 17-October 09

How to go about Hiding and Unhiding rows in DataGridView?

Posted 01 January 2010 - 05:10 PM

Hello and Happy New Year!

I have a database with a few records. I am using SQL CE. What i would like to be able to do is well you run the application, all the rows in the grid view should be hidden. I dont want the rows to be deleted.

Then when you click on a button, i want all the rows to be visible in the gridview. Is this possible?

I tried to do it myself but i kept getting an error message:

Quote

Row associated with the currency manager's position cannot be made invisible.


  
private void MakeInvisible()
		{
			foreach (DataGridViewRow row in AnimalDataGridView.Rows)
			{
				row.Visible = false;
			}
		}



I have written a method that unhides the rows which is called MakeVisible by using the code above but changing the Visible property to "true".

Could anyone advise how I could go about solving this please?

Thanks in advance.

This post has been edited by MarmiteX1: 01 January 2010 - 05:11 PM


Is This A Good Question/Topic? 0
  • +

Replies To: How to go about Hiding and Unhiding rows in DataGridView?

#2 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 380
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: How to go about Hiding and Unhiding rows in DataGridView?

Posted 02 January 2010 - 06:17 AM

bool rowsVisible = false;

private void btnHideRows_Click(object sender, EventArgs e)
{
	foreach (DataGridViewRow row in dgvSongs.Rows)
	{
		row.Visible = rowsVisible;
	}

	rowsVisible = !rowsVisible;
}



Hope this helps.
Was This Post Helpful? 0
  • +
  • -

#3 MarmiteX1  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 159
  • Joined: 17-October 09

Re: How to go about Hiding and Unhiding rows in DataGridView?

Posted 02 January 2010 - 07:51 AM

View PostFlashM, on 2 Jan, 2010 - 04:17 AM, said:

bool rowsVisible = false;

private void btnHideRows_Click(object sender, EventArgs e)
{
	foreach (DataGridViewRow row in dgvSongs.Rows)
	{
		row.Visible = rowsVisible;
	}

	rowsVisible = !rowsVisible;
}



Hope this helps.


Hi what I have done is put the code that is in the button into a method. I then call that method on the button once clicked and i still get the error message when you click on the button:

Quote

"Row associated with the currency manager's position cannot be made invisible."


This error occured on
row.visible = rowsVisible;


I declared the following line at the top of the program.
private bool rowsVisible;


I have declared in the following line the method
this.rowsVisible = false;


Do you know why this could be happening? Is it something to do with currency manager value?

Thanks
Was This Post Helpful? 0
  • +
  • -

#4 FlashM  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 380
  • View blog
  • Posts: 1,195
  • Joined: 03-December 09

Re: How to go about Hiding and Unhiding rows in DataGridView?

Posted 02 January 2010 - 07:53 AM

Well, I'm never using currency manager, so I really wouldn't know why this exception is thrown. But I do know that it is impossible to hide a new row in your datagridview (this is the last row in grid). Have to go now because I have run out of my laptop batery :-(

This post has been edited by FlashM: 02 January 2010 - 07:54 AM

Was This Post Helpful? 0
  • +
  • -

#5 Guest_Roger*


Reputation:

Re: How to go about Hiding and Unhiding rows in DataGridView?

Posted 16 July 2010 - 10:24 AM

Cannot set datagridview row visible property to false when current row index
Will encounter such error if trying to hide current cell
"Row associated with the currency manager's position cannot be made invisible."
Was This Post Helpful? 0

Page 1 of 1