Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Germany, Germany
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Highlighting of a control element in a UserForm (Excel 2000)

    Hello everybody!

    Some time ago, I had an idea to make it easier for users to work with a UserForm. This form has some radiobuttons. To make orientation easier, I would like to hichlight the radiobutton which is under the mouse. Therefore I use the MouseMove-Event. Highlighting the element works pretty good, but I have no idea how to get back the original color. Does anybody have an idea?

    Many greetings, Porley

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Highlighting of a control element in a UserForm (Excel 2000)

    I don't know how you highlight the radio buttons. You could set the BackColor property to the desired highlight color in design mode, then set the BackStyle property to transparent (you must do it in this order!)

    You could then use code like this (this is for 3 radio buttons, but it can be extended easily):

    Private Const NumButtons = 3

    Private Sub OptionButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    HandleMouseMove 1
    End Sub

    Private Sub OptionButton2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    HandleMouseMove 2
    End Sub

    Private Sub OptionButton3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    HandleMouseMove 3
    End Sub

    Private Sub HandleMouseMove(i As Integer)
    Dim j As Integer
    For j = 1 To NumButtons
    If j = i Then
    Me.Controls("OptionButton" & j).BackStyle = fmBackStyleOpaque
    Else
    Me.Controls("OptionButton" & j).BackStyle = fmBackStyleTransparent
    End If
    Next j
    End Sub

    Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Dim j As Integer
    For j = 1 To NumButtons
    Me.Controls("OptionButton" & j).BackStyle = fmBackStyleTransparent
    Next j
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •