Windows Develop Bookmark and Share   
 index > Windows Forms General > How to get displayed rows in datagridview
 

How to get displayed rows in datagridview

I have a DataGridView which includes 100 rows. User can resize this DataGridView see more rows or columns. I want to find a way to get rows and cells in displayed area. How can I do this?

I tried use DataGridView.Rows[idx].Displayed. However, it always has true value even user only can see the first 10 rows in DataGridView.

Thanks,
TravelMan  Monday, July 16, 2007 4:23 PM
The Displayed property should work. I've tried the following code, and OK

Code Snippet

void button1_Click(object sender, EventArgs e)

{

foreach (DataGridViewRow dr in this.dataGridView1.Rows)

{

if( dr.Displayed )

{

MessageBox.Show("row " + dr.Index.ToString() + " displayed");

}

}

}

Zhi-Xin Ye  Tuesday, July 17, 2007 3:04 PM
The Displayed property should work. I've tried the following code, and OK

Code Snippet

void button1_Click(object sender, EventArgs e)

{

foreach (DataGridViewRow dr in this.dataGridView1.Rows)

{

if( dr.Displayed )

{

MessageBox.Show("row " + dr.Index.ToString() + " displayed");

}

}

}

Zhi-Xin Ye  Tuesday, July 17, 2007 3:04 PM
Hi Zhi-Xin:
You post at really odd hours from Shanghai time. Weekends too. Are you somewhere else or a nite-owl? My compliments on your posts.
nobugz  Tuesday, July 17, 2007 8:49 PM
Hi, nobugz:
I'm here in Shanghai and sometimes a nite-owl. Thanks for your compliments. :-)

Best Regards
Zhi-Xin Ye
Zhi-Xin Ye  Wednesday, July 18, 2007 2:44 AM

You can use google to search for other answers

Custom Search

More Threads

• WebBrowser and Stylesheets (CSS)
• Image size wrong
• set cursor position
• Button is not outlined when it got focus
• how to set a messagebox , which ask for username and password?
• how can I call this listview.ColumnClick event on form load?
• To display Node atrributes such that node name added to tree?
• Handling the Close Event
• C# windows form looks different on different OS/Platform
• create increasingly later date value for testing listview column