473,324 Members | 1,678 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,324 software developers and data experts.

VS2500 - How to set 'currently viewed rows' ??

Greetings:

Working on a VS2005 C# program.

I have a DataGridView control that is bound to dataviews generated by
various database queries. i.e. the user enters search criteria and the
query results end up in the grid. The DataViewGrid is Read Only. The user
has the option of selecting a single record from the grid which causes all
of the associated database record values to become available for edit in an
area outside of the DataViewGrid.

Once the user completes the data updates and saves the data back to the
database I >refresh << the DataGridView to reflect the updates.

I have figured out how to re-select the DataGridView record that was
updated.

How do I ensure that the selected/updated record is visible in the
DataGridView window after the requery ???

i.e. if the window can display 10 rows and the data set is 30 rows long ...
how to I ensure that row #21 appears in the DataGridView window ??

Thanks in advance.

Barry
in Oregon


Aug 30 '07 #1
3 3229
Hi Oregon,

Based on my understanding, your question is how to ensure a particular
DataGridViewRow to be visible in a DataGridView. If I'm off base, please
feel free to let me know.

You have two options to do this.

One option is to set the DataGridView's CurrentCell property to the first
cell of the specified DataGridViewRow. Once we set a DataGridViewRow as the
current row, this row will scroll into the visible area of the
DataGridView. The following is a sample which sets the 5th DataGridViewRow
as the current row:

this.dataGridView1.CurrentCell = this.dataGridView1.Rows[4].Cells[0]

The other option is to set the DataGridView's
FirstDisplayedScrollingRowIndex property to the row index of the specified
DataGridViewRow. The following is a sample:

this.dataGridView1.FirstDisplayedScrollingRowIndex = 4;

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 30 '07 #2
Bar
Linda,

Thank you for the quick reply and aplogies for the late reply on my
part.

I used your " this.dataGridView1.CurrentCell =
this.dataGridView1.Rows[4].Cells[0]" option and it worked just as I
had hoped. Now when a user updates data derived from a specific
DataGridView row, I can ensure that the updated information appears as
one of the rows in the refreshed DataGridView display window.

Many Thanks !

Barry
in Oregon

On Aug 30, 1:45 am, v-l...@online.microsoft.com (Linda Liu [MSFT])
wrote:
Hi Oregon,

Based on my understanding, your question is how to ensure a particular
DataGridViewRow to be visible in a DataGridView. If I'm off base, please
feel free to let me know.

You have two options to do this.

One option is to set the DataGridView's CurrentCell property to the first
cell of the specified DataGridViewRow. Once we set a DataGridViewRow as the
current row, this row will scroll into the visible area of the
DataGridView. The following is a sample which sets the 5th DataGridViewRow
as the current row:

this.dataGridView1.CurrentCell = this.dataGridView1.Rows[4].Cells[0]

The other option is to set the DataGridView's
FirstDisplayedScrollingRowIndex property to the row index of the specified
DataGridViewRow. The following is a sample:

this.dataGridView1.FirstDisplayedScrollingRowIndex = 4;

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer tohttp://msdn.microsoft.com/subscriptions/managednewsgroups/default.asp...
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) athttp://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 6 '07 #3
Linda,

I am using the FirstDisplayedScrollingRowIndex to scroll the view to the
bottom without changing the selected "CurrentCell". If the window is small
before the scroll is called, I get an InvalidOperationException "No room is
available to display rows" event. How can I avoid this error and yet have
the grid scroll to the bottom without changing the current cell?
--
mnlarsen
"Linda Liu [MSFT]" wrote:
Hi Oregon,

Based on my understanding, your question is how to ensure a particular
DataGridViewRow to be visible in a DataGridView. If I'm off base, please
feel free to let me know.

You have two options to do this.

One option is to set the DataGridView's CurrentCell property to the first
cell of the specified DataGridViewRow. Once we set a DataGridViewRow as the
current row, this row will scroll into the visible area of the
DataGridView. The following is a sample which sets the 5th DataGridViewRow
as the current row:

this.dataGridView1.CurrentCell = this.dataGridView1.Rows[4].Cells[0]

The other option is to set the DataGridView's
FirstDisplayedScrollingRowIndex property to the row index of the specified
DataGridViewRow. The following is a sample:

this.dataGridView1.FirstDisplayedScrollingRowIndex = 4;

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 17 '07 #4

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

Similar topics

14
by: NotGiven | last post by:
I am guessing I would hold a variable of when it's opened, then in the script that runs when the page is offloaded, I coudl calcualte it. How do you store a time variable? How do you calculate...
4
by: la_haine | last post by:
I have a collection of pages that are designed to be called into an iframe (named displayView), and the managers don't want people to be able to view them unless they're in that iframe. If I use...
0
by: Firona | last post by:
Hi, I have a DataGridView in a form which I populate with some data. I would need to know which rows the user is currently viewing. I found the dataGridView.DisplayedRowCount() method which only...
3
by: Margie | last post by:
Hello all, after getting no where with my Access 2007 database problem for an entire week I figured I could use some outside help. Wanting to skill myself in Access, I decided to make a movie...
4
by: ASPnewb1 | last post by:
Hello, I have a 2-dimensional array created from the following text file: data1=asdfawe data2=2 data3=223d data4=22
2
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, I have a gridview with paging enabled. I need to know how many rows of data are on the last page!!! When I look at the Gridview1.Rows.Count in the Page_Load, it always returns the...
5
by: eBob.com | last post by:
I am so frustrated. I've been working all weekend on what I thought would be a simple script. I never find it easy to look at someone else's code, but if someone can help with this I would be...
11
by: sanju | last post by:
Dear All, I have html table and this table contains 10 Rows and 2 column, I want every time this HTML page is called by the user to view the rows Randomly. How can I do this from JavaScript? ...
4
by: ravir81 | last post by:
Hi, I am currently working on excel validation using Perl. I am new to Excel validation but not for Perl. I have a question regarding one of the validation. Could anyone please tell me how to get...
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...
1
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: 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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.