vb123.com

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

 

Home  Contact Us

Order Software

Search vb123

 Smart Access  
The Magazine that Access Developers loved to read and write for is back
Article Index Here or
Purchase Here

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

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

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


Access > SqlServer 
Upsize to SQL Server 2005 or 2008, easily repeated conversions, highly accurate SQL query
translation and web form conversion.
Read More

Like FMS Products?
Purchase them from us and get a free Workbench or Smart Access  More

The Toolbox
Libraries of software that we regularly import into our projects.  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 ...


 

 

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