|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to add dynamic tooltip when dragging scrollbar of datagridviewHello,
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 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. Show quoteHide quote "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 On Fri, 1 Sep 2006 15:03:02 -0700, Rich <R***@discussions.microsoft.com> wrote:
Show quoteHide quote >Well, I started focusing on how to write to the RowHeader Cells of the Maybe these will help:>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 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(DataGridViewElementStates.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
For Next Loop - Manual Might Be Wrong
"If" statement asking for integer Is Thread.Abort() blocking until Thread has exited? Changing the text of a Command Button using SetWindowText Stream Application quit after button click Appending text to an array of textboxes Strange Datagrid Behavior How to use Resource files in VS 2005? C# keyword default(T) to VB.net |
|||||||||||||||||||||||