473,568 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7422
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
DataGridViewCel lPaintingEventA rgs) Handles dgrv1.CellPaint ing
Dim fnt As New Font("Arial", 8)
Dim rect As New Rectangle(e.Cel lBounds.X, e.CellBounds.Y,
e.CellBounds.Wi dth, e.CellBounds.He ight)

Static i As Integer
If i RecCount Then i = 0
i += 1
If (e.ColumnIndex < 0) AndAlso (e.RowIndex 0) Then
e.Graphics.Fill Rectangle(Brush es.Lime, e.CellBounds)
e.Graphics.Draw String(i.ToStri ng, fnt, Brushes.Black, e.CellBounds.X + 3,
e.CellBounds.Y + 3)
e.Graphics.Draw Rectangle(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**@discussio ns.microsoft.co mwrote:
>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
DataGridViewCe llPaintingEvent Args) Handles dgrv1.CellPaint ing
Dim fnt As New Font("Arial", 8)
Dim rect As New Rectangle(e.Cel lBounds.X, e.CellBounds.Y,
e.CellBounds.W idth, e.CellBounds.He ight)

Static i As Integer
If i RecCount Then i = 0
i += 1
If (e.ColumnIndex < 0) AndAlso (e.RowIndex 0) Then
e.Graphics.Fill Rectangle(Brush es.Lime, e.CellBounds)
e.Graphics.Draw String(i.ToStri ng, fnt, Brushes.Black, e.CellBounds.X + 3,
e.CellBounds .Y + 3)
e.Graphics.Draw Rectangle(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.GetRowCou nt(DataGridView ElementStates.D isplayed)
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
5173
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
9433
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 over the control,How can this be accomplished(Im developing in C#)?
0
2667
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 location of the scrollbar etc. I was wondering if anyone else has done something similar and maybe direct me to an example. Also have you found...
0
1225
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 individual treeview nodes. However, I noticed that using the method shown in the KB article made the tooltip pop-up such that the cursor was in the...
0
1144
by: windy | last post by:
Hi all, how can i add tooltip for columnheader on datagridview? Thanks.
1
1870
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 to be an array. Example: Dim ObjParmArr Dim ArrayCounter Dim i Dim ParmList
2
1493
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 EventHandler(Dragging); } private void Dragging(object sender, EventArgs e) {
0
1723
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 tooltip when a mouse is hovered on the Columns correspondingly ...... IS der any event Available for subitem Mouse hover ?? Please Reply ASAP ...
0
7690
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...
0
7597
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7909
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. ...
0
8115
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...
0
7961
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...
0
6273
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...
0
3649
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3630
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1206
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.