vb123.com

Garry Robinson's Popular MS Access, Office and VB Resource Site

 

Home  Contact Us
Order our Software

RSS & Newsletter  
Join our XML/RSS Newsfeed or sign up for our informative newsletter on Office Automation, Access and VB topics
Read More

Get Good Help
If you need help with a database, our Professionals could be the answer
Read More

  Is Your Database Corrupt ?
If you have a corrupt database, Try our Access Recovery service

The Workbench  Find out who has your database open, start the correct version of Access, easy compacting and backups, change startup options, mde compile,  shutdown database Read and Download

The Toolshed 
Searchable help file comprising of all the information at vb123.com plus hidden downloads etc. Read More



The Toolbox

Libraries of software that we regularly import into our projects. Enhances the Toolshed More..


Upsize to SQL 
Upsize to SQL Server 2005 or 2008 or improve the performance of your Access to SQL Server application
Read More


DryToast New
Backup and query your BaseCamp
® projects
Read More


Datamining/Graphs

Explore your data with this versatile graphing and data mining shareware tool.  Read More

Garry's Blog
Find out a few other things that Garry has been writing about Microsoft Access. Read more

About The Editor Garry Robinson writes for a number of popular computer magazines, is now a book author and has worked on 100+ Access databases. He is based in Sydney, Australia
Contact Us ...

Search ...

or try our new Expression Web
 vb123.com.au
 

 

Adding Interactivity To A User Control

When developing a Graph User Control in Visual Basic 5 for a client, I was asked to provide a event on the control which would return the data index as the mouse moved across the control. As a graphical user control has only dumb line and print objects, there was no special event that I could use to provide this feature. So I created one using the following techniques.

 

In the user control, make a public event as follows

Public Event ucMouseMove()

Now add a MouseMove subroutine to the control

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim i As Integer

' Define which graph column the user is pointing at

GrafDataId = 0

For i = dataRowsMaxRows To 1 Step -1

 

Check the current position of the mouse against an array that holds the X axis positions of the different objects in the graph

If X > grafX(i) Then

' Set the plot indexes and raise the event that can be trapped by the control holding the user control

GrafDataId = i

RaiseEvent ucMouseMove

Exit Sub

End If

Next i

GrafDataId = 0

End Sub

And now set a property for the user control as follows

Public Property Get GrafDataPos () As Variant

GrafDataPos = GrafDataId

End Property 

Now in the form holding the user control, you will be able to add the new event for the control

 

Private Sub myGraph1_ucMouseMove

' Find the current index of a bar in a graph by using the following code

MsgBox " Index " & myGraph1.GrafDataPos

End Sub

Where GrafDataPos is a property of the graph that holds the current position of the graph

 

 

Links >>>  Home | Search | Workbench | Orders | Newsletter | Access Security | Access professionals