473,320 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Hide selected row in DataGridView

When I try to make the current row invisible, I got an error.
I put a checbox that turns some rows visible/invisible.
Then if the selected row is turning to invisible, it raises an
exception.

My code:

foreach (DataGridViewRow row in myGrid.Rows)
if ((bool)row.Cells[0].Value.Equals(false))
row.Visible = checkbox.Checked;

What's wrong in that???

Thanx....

Junior.

Mar 31 '06 #1
4 20244
osmarjunior wrote:
When I try to make the current row invisible, I got an error.
I put a checbox that turns some rows visible/invisible.
Then if the selected row is turning to invisible, it raises an
exception.

My code:

foreach (DataGridViewRow row in myGrid.Rows)
if ((bool)row.Cells[0].Value.Equals(false))
row.Visible = checkbox.Checked;

What's wrong in that???

Thanx....

Junior.


Um, What's the exception?

You may need to change the current row to the next/previous row before
you hide it.

Chris
Mar 31 '06 #2
I didn't posted the exception, 'cause I just got it in portuguese.
I've tried to invoke the method ClearSelection() before the foreach
loop.
Without success... :(

myGrid.ClearSelection();

foreach (DataGridViewRow row in myGrid.Rows)
if ((bool)row.Cells[0].Value.Equals(false))
row.Visible = checkbox.Checked;

Your solution maybe can be a problem if I have one single row in
DataGridView.
Then if I try to turn it to invisible??? Because, in this case, there
is no next or previous rows to select...

Thanx...

Junior.

Mar 31 '06 #3
Junior,

Instead of indicating if the row is visible or not, why not bind the
DataGridView to a dataview which is filtered on the column that is storing
the true/false value?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"osmarjunior" <os*********@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
I didn't posted the exception, 'cause I just got it in portuguese.
I've tried to invoke the method ClearSelection() before the foreach
loop.
Without success... :(

myGrid.ClearSelection();

foreach (DataGridViewRow row in myGrid.Rows)
if ((bool)row.Cells[0].Value.Equals(false))
row.Visible = checkbox.Checked;

Your solution maybe can be a problem if I have one single row in
DataGridView.
Then if I try to turn it to invisible??? Because, in this case, there
is no next or previous rows to select...

Thanx...

Junior.

Apr 1 '06 #4
Good sugestion. Thanx...

Apr 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: steve | last post by:
Hi All How do I get the screen coordinates of the selected cell boundaries in a datagridview I need to position a form at the top left position of the selected cell regardless of where the...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
1
by: roland-d | last post by:
Hello all, Toggling divs is a popular subject and I have found plenty of information and was able to make it work. There is only 1 thing I am still stuck with for quite some time. I have a...
3
by: =?Utf-8?B?U3RldmVU?= | last post by:
Is it possible with VS 2005 to hide a row within a datagridview based upon the "true/false" status of another boolean property within the datagridview? -- ----------- Thanks, Steve
2
by: atlewis | last post by:
Hi, I'm trying to grab a string of the value in the first column of a DataGridView object on the selected row. What's the easiest way to go about that? I'm building part of a SQL statement...
1
nev
by: nev | last post by:
i can select a particular dgv cell by... dgv.currentcell = dgv.rows(i).cells(i) but how can i activate the blinking cursor in it so that it's ready to accept text input?
6
by: hzgt9b | last post by:
Using VS2005, VB.NET, I have a windows app with a DataGridView (lets call it DGV). At some point in the life of my app I want to clear the selection of the currently selected row...
1
nirmalsingh
by: nirmalsingh | last post by:
hai all i have selected datagridview by datagridview.selectAll(); now i want to deselect datagridview how to do this? with Cheers Nirmal
3
by: frostbb | last post by:
Greetings, We're starting to transition our legacy C# apps from earlier versions to VS2008 versions. Many of our apps allow the user to select a row from a DataGrid into a 'Data Edit' area...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.