473,604 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.DataGridV iew.

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 5939
On Dec 31, 1:33*pm, "colin" <colin.ro...@nt world.NOSPAM.co mwrote:
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.DataGridV iew.

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.Fi rstDisplayedScr ollingRowIndex =
rowIndex.

Greg
Jan 1 '08 #2
>"Greg" <gc*****@gmail. comwrote in message
>news:20******* *************** ************@e1 0g2000prf.googl egroups.com...
On Dec 31, 1:33 pm, "colin" <colin.ro...@nt world.NOSPAM.co mwrote:
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.DataGrid View.

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.Fi rstDisplayedScr ollingRowIndex =
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.ClearSelec tion();
grid.Rows[i].Selected = true;
if (i < grid.FirstDispl ayedScrollingRo wIndex)
grid.FirstDispl ayedScrollingRo wIndex = i;
else if (i >= grid.FirstDispl ayedScrollingRo wIndex + 8)
grid.FirstDispl ayedScrollingRo wIndex = 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
5602
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 to edit the same last visited cell, focus gets shifted to the first few visible rows as per the dimensions set for the DataGridView. To be exact it goes to the cell in the first row, and the same column. If I can say it this way, I would like...
4
22115
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 = false; //mobiltelefon When I run the programm, the columns are still displayed. I am developing with Visual C#2005 Express Edition Beta.
0
2301
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 Edit feature of the DataGridView. I have set several of the BoundField elements of the DataGridView to ReadOnly="True". When I attempt to use the Edit feature to UPDATE the rows in the DataGridView I get a System.NullReferenceException for...
0
1256
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 selected. But it is always displayed at the bottom (= the last row)
3
5071
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
1740
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 edit the same last visited cell, focus gets shifted to the first few visible rows as per the dimensions set for the DataGridView. To be exact it goes to the cell in the first row, and the same column. If I can say it this way, I would like to see...
1
3369
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) export to excel button exports the visible columns from the datagridview to excel (this works fine)
1
3773
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. Another combobox that shows the databases in that particular server. Another combobox with the filesets from the selected database above.
6
8754
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, the SelectionChanged event fires and I load some more data that's particular to that row. The problem I'm having is that the SelectionChanged event is going way
0
7997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8409
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8065
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8280
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5441
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1526
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.