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

DataGridView making a row visible

Hi,
I need to tell how many rows are visible on the screen,
in my DataGridView control
so that I can ensure my newly selected row is visible
without doing any unecessry scrolling,

I thought RowCount would give me this :-
Summary:
Gets or sets the number of rows displayed in the
System.Windows.Forms.DataGridView.

but this isnt meaning the number dispalyed on the screen,
im not sure what it is, it serems to be the same as the number of rows in
the coollection.
I gues it just truncates the number of rows.

it conveniently tells you the first visible row
but not the last it seems, unless I am missing something.

is there another way to get this info ?
or do i have to work it out using pixels :s

Colin =^.^=
Dec 31 '07 #1
2 5901
On Dec 31, 1:33*pm, "colin" <colin.ro...@ntworld.NOSPAM.comwrote:
Hi,
*I need to tell how many rows are visible on the screen,
in my DataGridView control
so that I can ensure my newly selected row is visible
without doing any unecessry scrolling,

I thought RowCount would give me this :-
Summary:
Gets or sets the number of rows displayed in the
System.Windows.Forms.DataGridView.

but this isnt meaning the number dispalyed on the screen,
im not sure what it is, it serems to be the same as the number of rows in
the coollection.
I gues it just truncates the number of rows.

it conveniently tells you the first visible row
but not the last it seems, unless I am missing something.

is there another way to get this info ?
or do i have to work it out using pixels :s

Colin =^.^=
I thought RowCount would have worked too.
However, if you want to show your newly 'selected' row,
then simply use DataGridView.FirstDisplayedScrollingRowIndex =
rowIndex.

Greg
Jan 1 '08 #2
>"Greg" <gc*****@gmail.comwrote in message
>news:20**********************************@e10g200 0prf.googlegroups.com...
On Dec 31, 1:33 pm, "colin" <colin.ro...@ntworld.NOSPAM.comwrote:
Hi,
.>I need to tell how many rows are visible on the screen,
>in my DataGridView control
so that I can ensure my newly selected row is visible
without doing any unecessry scrolling,

I thought RowCount would give me this :-
Summary:
Gets or sets the number of rows displayed in the
System.Windows.Forms.DataGridView.

but this isnt meaning the number dispalyed on the screen,
im not sure what it is, it serems to be the same as the number of rows in
the coollection.
I gues it just truncates the number of rows.

it conveniently tells you the first visible row
but not the last it seems, unless I am missing something.

is there another way to get this info ?
or do i have to work it out using pixels :s

Colin =^.^=
>I thought RowCount would have worked too.
However, if you want to show your newly 'selected' row,
then simply use DataGridView.FirstDisplayedScrollingRowIndex =
rowIndex.

Greg
ah yes I do that already, I realy thought id mentioned that.. oh well,
anyway that scrolls the selection to be at the top of the list always,
but the selection is set via a mousehover on a 3d graphical object,
wich are wireframe models,
when the mouse is moving accros several objects
its scrolling up and down like crazy and its a bit of a pain.

I had hoped to only scroll up or down as few lines as possible to bring it
into view,
for now im just assuming theres 8 lines.

for(int i=0;i < grid.Rows.Count;i++)
{
if(grid.Rows[i].Tag == selection)
{
if (!grid.Rows[i].Selected)
{
grid.ClearSelection();
grid.Rows[i].Selected = true;
if (i < grid.FirstDisplayedScrollingRowIndex)
grid.FirstDisplayedScrollingRowIndex = i;
else if (i >= grid.FirstDisplayedScrollingRowIndex + 8)
grid.FirstDisplayedScrollingRowIndex = i - (8-1);

Colin =^.^=
Jan 1 '08 #3

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

Similar topics

1
by: Arvind | last post by:
Hi I edit a cell in a DataGridView, and then would move to another cell in the DataGridView using mouse. Then the DataGridView as of now does scroll down to the last visited cell. But when I try...
4
by: Stropher | last post by:
I have the following: this.dataGridViewBill.DataSource = tblResult; //hide the following columns this.dataGridViewBill.Columns.Visible = false; //email this.dataGridViewBill.Columns.Visible =...
0
by: schoultzy | last post by:
Hello Everyone, I have been trying to figure this one out for two days now. I have created a DataGridView which is populated by an ObjectDataSource. My problem occurs when I attempt to use the...
0
by: teo | last post by:
Hello. I have a DataGridView with a lot of rows. I created a sort of "Goto" . I used the CurrentCell property. The DataGridView scrolls down and the new cell is now visible and it is blue...
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
0
by: =?Utf-8?B?S3VtYXIuQS5QLlA=?= | last post by:
I edit a cell in a DataGridView, and then would move to another cell in the DataGridView using mouse. Then the DataGridView as of now does scroll down to the last visited cell. But when I try to...
1
by: TG | last post by:
Hi! I have an application in which I have some checkboxes and depending which ones are checked those columns will show in the datagridview from sql server or no. After that I have 2 buttons:...
1
by: =?Utf-8?B?VGFtbXk=?= | last post by:
Hi! I am using VB 2008 with SQL Server 2000 and SQL Server 2005 (depending which server the user selects to connect to). I have a combox in which the user types the server to connect to. ...
6
by: Simon Harvey | last post by:
Hi all, I'm really hoping someone can help me with this as it's causing me some serious problems. I have a Windows Forms application using the gridview control. When the user selects a row,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.