Results 1 to 3 of 3

Thread: [RESOLVED] ControlStyle.Selectable not functioning properly?

  1. #1

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Resolved [RESOLVED] ControlStyle.Selectable not functioning properly?

    Well the title says it all. I have my own control which inherit System.Windows.Forms.Control

    The only functionality that this control requires is the capability of losing and gaining focus. I learned this requires the control style of selectable to be applied which is descriptive as exactly what I'm in need of, "If true, the control can receive focus.".

    However after applying this style in my code, the control still refuses to have anything to do with gaining or losing focus.

    Other styles I have applied to this particular control are as fallowed
    UserPaint, AllPaintingInWmPaint, and SupportsTransparentBackColor. I'm not sure but perhaps one of these other styles interferes with the one that's not working properly.


    Thanks and hope someone has some insight here for me!
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,458

    Re: ControlStyle.Selectable not functioning properly?

    try this. the control is selectable both in code + onMouseDown:

    vb Code:
    1. Public Class myControl
    2.     Inherits Control
    3.  
    4.     Public Sub New()
    5.         MyBase.SetStyle(ControlStyles.Selectable, True)
    6.         MyBase.SetStyle(ControlStyles.StandardClick, True)
    7.     End Sub
    8.  
    9.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
    10.         MyBase.OnMouseDown(e)
    11.         If Not MyBase.Focused Then MyBase.Focus()
    12.     End Sub
    13.  
    14. End Class

  3. #3

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: ControlStyle.Selectable not functioning properly?

    Quote Originally Posted by .paul. View Post

    MyBase.SetStyle(ControlStyles.StandardClick, True)

    End Class[/HIGHLIGHT]

    Exactly what I was missing, thanks!

    I wasn't aware that StandardClick and Selectable work jointly, like UserPaint and AllPaintingInWmPaint.


    Rate
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width