473,412 Members | 5,714 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,412 software developers and data experts.

how to add dynamic tooltip when dragging scrollbar of datagridview

Hello,

Some database applicatins have a tooltip feature where when you are dragging
the scrollbar of the table view a tooltip appears next to the mouse cursor
displaying the approximate record number you are scrolling past (Excel,
Access). Sql server has the rownumbers on the Row Header column of its table
view.

Ideally, I would like to add row numbers to the Row Header column of the
datagridview like sql server - Any suggestions appreciated how I could do
this. Is there a property on the datagridview I could set?

The other idea (the idea of the original post) - how can I add a dynamic
tooltip like Excel/Access to display what record number I am passing throught
as I drag the scrollbar?

Thanks,
Rich
Sep 1 '06 #1
2 7392
Well, I started focusing on how to write to the RowHeader Cells of the
datagridview and came up with this:

Private Sub OnCellPainting(ByVal sender As Object, ByVal e As
DataGridViewCellPaintingEventArgs) Handles dgrv1.CellPainting
Dim fnt As New Font("Arial", 8)
Dim rect As New Rectangle(e.CellBounds.X, e.CellBounds.Y,
e.CellBounds.Width, e.CellBounds.Height)

Static i As Integer
If i RecCount Then i = 0
i += 1
If (e.ColumnIndex < 0) AndAlso (e.RowIndex 0) Then
e.Graphics.FillRectangle(Brushes.Lime, e.CellBounds)
e.Graphics.DrawString(i.ToString, fnt, Brushes.Black, e.CellBounds.X + 3,
e.CellBounds.Y + 3)
e.Graphics.DrawRectangle(Pens.Black, rect)
e.Handled = True
End If

End Sub
Apparently, you have to override the initial paint event of the datagridview
- and I do this by donig my own painting. And, of course, I have to draw my
own cells (rectangles) in the RowHeader column. This is actually working
fine. Where I still have a problem is in the row numbering. I was using a
static int - maybe I should use a global int. The other problem is that this
paint event keeps getting invoked, so the numbers are constantly changing
every time I scroll the datagridview and so much as hover the mouse over it.

"Rich" wrote:
Hello,

Some database applicatins have a tooltip feature where when you are dragging
the scrollbar of the table view a tooltip appears next to the mouse cursor
displaying the approximate record number you are scrolling past (Excel,
Access). Sql server has the rownumbers on the Row Header column of its table
view.

Ideally, I would like to add row numbers to the Row Header column of the
datagridview like sql server - Any suggestions appreciated how I could do
this. Is there a property on the datagridview I could set?

The other idea (the idea of the original post) - how can I add a dynamic
tooltip like Excel/Access to display what record number I am passing throught
as I drag the scrollbar?

Thanks,
Rich
Sep 1 '06 #2
On Fri, 1 Sep 2006 15:03:02 -0700, Rich <Ri**@discussions.microsoft.comwrote:
>Well, I started focusing on how to write to the RowHeader Cells of the
datagridview and came up with this:

Private Sub OnCellPainting(ByVal sender As Object, ByVal e As
DataGridViewCellPaintingEventArgs) Handles dgrv1.CellPainting
Dim fnt As New Font("Arial", 8)
Dim rect As New Rectangle(e.CellBounds.X, e.CellBounds.Y,
e.CellBounds.Width, e.CellBounds.Height)

Static i As Integer
If i RecCount Then i = 0
i += 1
If (e.ColumnIndex < 0) AndAlso (e.RowIndex 0) Then
e.Graphics.FillRectangle(Brushes.Lime, e.CellBounds)
e.Graphics.DrawString(i.ToString, fnt, Brushes.Black, e.CellBounds.X + 3,
e.CellBounds.Y + 3)
e.Graphics.DrawRectangle(Pens.Black, rect)
e.Handled = True
End If

End Sub
Apparently, you have to override the initial paint event of the datagridview
- and I do this by donig my own painting. And, of course, I have to draw my
own cells (rectangles) in the RowHeader column. This is actually working
fine. Where I still have a problem is in the row numbering. I was using a
static int - maybe I should use a global int. The other problem is that this
paint event keeps getting invoked, so the numbers are constantly changing
every time I scroll the datagridview and so much as hover the mouse over it.

"Rich" wrote:
>Hello,

Some database applicatins have a tooltip feature where when you are dragging
the scrollbar of the table view a tooltip appears next to the mouse cursor
displaying the approximate record number you are scrolling past (Excel,
Access). Sql server has the rownumbers on the Row Header column of its table
view.

Ideally, I would like to add row numbers to the Row Header column of the
datagridview like sql server - Any suggestions appreciated how I could do
this. Is there a property on the datagridview I could set?

The other idea (the idea of the original post) - how can I add a dynamic
tooltip like Excel/Access to display what record number I am passing throught
as I drag the scrollbar?

Thanks,
Rich

Maybe these will help:

In the DataGridView Scroll Event," e.NewValue" returns the row number of the current, first
displayed row. Scrolling the complete grid will result in the last returned NewValue of the total
rows minus the displayed row count.

Dim i As Integer = Me.DataGridView.Rows.GetRowCount(DataGridViewEleme ntStates.Displayed)
Where"i" is the number of displayed rows.

(i + e.NewValue -1) >>>Scrolling returns row number starting with last visible row to the end row.

Gene
Sep 2 '06 #3

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

Similar topics

2
by: newsgroper | last post by:
I set the AutoScroll property of a windows panel to true. How can I tell when the scrollbar becomes visible?
5
by: Vinny Vin | last post by:
I would like to display a ToolTip (WinForms) when the Control associated recieves focus (when the control.enter event is triggered) as oppose to having the ToolTip displayed when the mouse hovers...
0
by: MJB | last post by:
I was thinking of creating a DataGrid that will query for results as the user scrolls. I realize I would have to know how many rows would fit in the visible area and what rows to show based on the...
0
by: mscdex | last post by:
I have a tooltip control added to my form as well as a treeview control. By using a Microsoft KB article (http://support.microsoft.com/kb/319963) as a guide, I was able to add tooltip support for...
0
by: windy | last post by:
Hi all, how can i add tooltip for columnheader on datagridview? Thanks.
1
by: andrebarn | last post by:
Hi guys I what to create Dynamic variables when I loop through and recordset, I have read this forum : http://bytes.com/forum/thread436288.html But see my problem is that so af the variables need...
2
EinToR
by: EinToR | last post by:
I'm trying to set the opacity = .50 when dragging a windows form. Here's what I've got: public Form1() { InitializeComponent(); this.Move += new...
0
by: tezu | last post by:
Hi all, Im currently having a list view with two columns Key and Value .Key column contains Items and the VAlue contains the subitems.... I want to dispaly the value of each item n subitem in a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...
0
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...
0
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...

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.