472,347 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,347 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 7274
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...
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...
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)...
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 ...
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() { ...
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...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.