Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Make all the controls inside a Groupbox unusable, without disabling them

Make all the controls inside a Groupbox unusable, without disabling them

Scheduled Pinned Locked Moved Visual Basic
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dilkonika
    wrote on last edited by
    #1

    Hello ! When a condition is true I want to make all the controls inside a groupbox not usable by users but without disabling them. This is the code I use :

    Class NW
    Inherits NativeWindow
    Public Sub New(hwnd As IntPtr)
    AssignHandle(hwnd)
    End Sub
    Const WM_NCHITTEST As Integer = &H84
    Protected Overrides Sub WndProc(ByRef m As Message)
    If m.Msg = WM_NCHITTEST Then
    Return
    End If
    MyBase.WndProc(m)
    End Sub
    End Class

    Dim nwss As List(Of NW) = Nothing

    Public Sub block_area(flag As Boolean)
    If flag = True AndAlso IsNothing(nwss) Then
    nwss = New List(Of NW)()
    For Each c As Control In GroupBox1.Controls
    nwss.Add(New NW(c.Handle))
    Next
    Else
    If flag = False And (Not IsNothing(nwss)) Then
    For Each nw As Object In nwss
    nw.ReleaseHandle()
    Next
    nwss = Nothing
    End If
    End If
    End Sub

    The problem is that this code works for all controls , except the TextBox and DateTimePicker. These 2 controls remain always clickable and editable. What's wrong ? Thank you !

    J 1 Reply Last reply
    0
    • D dilkonika

      Hello ! When a condition is true I want to make all the controls inside a groupbox not usable by users but without disabling them. This is the code I use :

      Class NW
      Inherits NativeWindow
      Public Sub New(hwnd As IntPtr)
      AssignHandle(hwnd)
      End Sub
      Const WM_NCHITTEST As Integer = &H84
      Protected Overrides Sub WndProc(ByRef m As Message)
      If m.Msg = WM_NCHITTEST Then
      Return
      End If
      MyBase.WndProc(m)
      End Sub
      End Class

      Dim nwss As List(Of NW) = Nothing

      Public Sub block_area(flag As Boolean)
      If flag = True AndAlso IsNothing(nwss) Then
      nwss = New List(Of NW)()
      For Each c As Control In GroupBox1.Controls
      nwss.Add(New NW(c.Handle))
      Next
      Else
      If flag = False And (Not IsNothing(nwss)) Then
      For Each nw As Object In nwss
      nw.ReleaseHandle()
      Next
      nwss = Nothing
      End If
      End If
      End Sub

      The problem is that this code works for all controls , except the TextBox and DateTimePicker. These 2 controls remain always clickable and editable. What's wrong ? Thank you !

      J Offline
      J Offline
      JR212
      wrote on last edited by
      #2

      Try enable and / or readonly

      D 1 Reply Last reply
      0
      • J JR212

        Try enable and / or readonly

        D Offline
        D Offline
        dilkonika
        wrote on last edited by
        #3

        Sorry , but I have posted a code. I have some reasons to not use disable / readonly. Can you give me a solution for my code ? Thank you !

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups