Color Mouse Over

4 posts, 1 answers
  1. Andrés David Santacoloma Isaza
    Andrés David Santacoloma Isaza avatar
    51 posts
    Member since:
    Mar 2010

    Posted 17 Jan 2011 Link to this post

    Hi:
    I need to put a code with which the color of my button is the same that appears when you put your mouse over it.
    Thanks.
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 17 Jan 2011 Link to this post

    Hello,

    You can do a few things here. You could either create your own theme using visual style builder or if you just want to keep mouse over style on all, then you can use the following code

    In form load
    Me.RadButton1.ButtonElement.IsMouseOver = True
    AddHandler Me.RadButton1.ButtonElement.RadPropertyChanging, AddressOf Button_RadPropertyChanging

    then
    Private Sub Button_RadPropertyChanging(ByVal sender As Object, ByVal e As RadPropertyChangingEventArgs)
        If e.Property.Name = "IsMouseOver" Then
            e.Cancel = True
        End If
    End Sub

    hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Andrés David Santacoloma Isaza
    Andrés David Santacoloma Isaza avatar
    51 posts
    Member since:
    Mar 2010

    Posted 17 Jan 2011 Link to this post

    Hi:
    Thanks, that code is rigth, but I need put the color when click, and quit this color when I click on other button.
    How I do it?

    Thanks.
  5. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 17 Jan 2011 Link to this post

    Hello again,

    Here you are. Just two buttons on a form.
    RadButtonColorOn is the button that will have the mouse over colour applied, and will stay on until you click RadButtoncolorOff

    Private Sub RadButtonColorOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButtonColorOn.Click
        Me.RadButtonColorOn.ButtonElement.IsMouseOver = True
        AddHandler Me.RadButtonColorOn.ButtonElement.RadPropertyChanging, AddressOf Button_RadPropertyChanging
    End Sub
    Private Sub RadButtonColorOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButtonColorOff.Click
        Me.RadButtonColorOn.ButtonElement.IsMouseOver = False
        RemoveHandler Me.RadButtonColorOn.ButtonElement.RadPropertyChanging, AddressOf Button_RadPropertyChanging
    End Sub
    Private Sub Button_RadPropertyChanging(ByVal sender As Object, ByVal e As RadPropertyChangingEventArgs)
        If e.Property.Name = "IsMouseOver" Then
            e.Cancel = True
        End If
    End Sub

    Hope that helps
    Richard
Back to Top