none
Control Properties RRS feed

  • Question

  • I am trying to figure out what property, if any, that I can use with checkboxes and radio buttons.

    I have a set of checkboxes in a panel container and radio buttons that are placed in either of two panel containers.  To use the checkboxes or radio buttons the panels must be enabled.  The panels are set to enabled = False when the form is in view only of what I call the SetState. (A method that sets the formats, etc. for the form)

    The first form is view only and as can be seen, the panels are disabled and the checkboxes and radio buttons are faded, instead of clearly visible as in the edit, SetState, where the panels are enabled.

    So what property controls being able to override and make the checkboxes and radio buttons look like they do in the second form?  

    Note, there is black text for the checkboxes and radio buttons in the view form.  I know what to do with this, I just haven't gotten to it yet.



    gwboolean

    Tuesday, April 23, 2019 5:15 PM

Answers

  • Seems it would be easier to not have panels disabled, instead do this to CheckBox and RadioButton controls.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by gwboolean Tuesday, April 23, 2019 6:29 PM
    Tuesday, April 23, 2019 5:54 PM
    Moderator

All replies

  • Hi

    Not sure what you are asking for.

    Do you want the controls inside the disabled panel to look like they are enabled despite them being disabled through the parent panel being disabled?


    Regards Les, Livingston, Scotland

    Tuesday, April 23, 2019 5:33 PM
  • That is exactly what I am looking for.  What property would control that?

    gwboolean

    Tuesday, April 23, 2019 5:37 PM
  • Seems it would be easier to not have panels disabled, instead do this to CheckBox and RadioButton controls.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by gwboolean Tuesday, April 23, 2019 6:29 PM
    Tuesday, April 23, 2019 5:54 PM
    Moderator
  • That is exactly what I am looking for.  What property would control that?

    gwboolean

    Hi

    I don't think it is as simple as finding a Property to do the job.  I certainly don't know of any Property combinations that will override the parent Panel painting (including child controls). Maybe Overriding the Panel Paint event holds a way to do it?


    Regards Les, Livingston, Scotland

    Tuesday, April 23, 2019 6:04 PM
  • Karen, Leshay

    I disabled the panels because that was the easy way to deny access to the checkboxes and radio buttons.  The easy way never works.  Anyway, what Karen suggested works perfectly.

    Thanks


    gwboolean

    Tuesday, April 23, 2019 6:29 PM
  • Hello,

    Since that works for you check out the following demo I slapped together.

    https://1drv.ms/u/s!AtGAgKKpqdWjjR_SM09M04O86k22

    Public Module ControlExtensions
        ''' <summary>
        ''' Provides access to all controls on a form including
        ''' controls within containers e.g. panel and group-box, Panel etc.
        ''' </summary>
        ''' <typeparam name="T"></typeparam>
        ''' <param name="control"></param>
        ''' <returns></returns>
        <Runtime.CompilerServices.Extension>
        Public Iterator Function Descendants(Of T As Class)(control As Control) As IEnumerable(Of T)
            For Each child As Control In control.Controls
    
                Dim currentChild = TryCast(child, T)
                If currentChild IsNot Nothing Then
                    Yield currentChild
                End If
    
                If child.HasChildren Then
                    For Each descendant As T In child.Descendants(Of T)()
                        Yield descendant
                    Next
                End If
            Next
        End Function
    End Module

    Usage

    Public Class Form1
        Private Sub enableCheckBoxesButtons_Click(sender As Object, e As EventArgs) _
            Handles enableCheckBoxesButtons.Click
    
            checkBoxPanel.Descendants(Of CheckBox).ToList().ForEach(
                Sub(currentCheckBox)
                    currentCheckBox.AutoCheck = True
                End Sub)
        End Sub
    
        Private Sub disableCheckBoxesButton_Click(sender As Object, e As EventArgs) _
            Handles disableCheckBoxesButton.Click
    
            checkBoxPanel.Descendants(Of CheckBox).ToList().ForEach(
                Sub(currentCheckBox)
                    currentCheckBox.AutoCheck = False
                End Sub)
        End Sub
    
        Private Sub enableRadioButtonButton_Click(sender As Object, e As EventArgs) _
            Handles enableRadioButtonButton.Click
    
            radioButtonPanel.Descendants(Of RadioButton).ToList().ForEach(
                Sub(currentRadioButton)
                    currentRadioButton.AutoCheck = True
                End Sub)
        End Sub
    
        Private Sub disableRadioButtonButton_Click(sender As Object, e As EventArgs) _
            Handles disableRadioButtonButton.Click
    
            radioButtonPanel.Descendants(Of RadioButton).ToList().ForEach(
                Sub(currentRadioButton)
                    currentRadioButton.AutoCheck = False
                End Sub)
        End Sub
    End Class
    One button is mis-labeled but not the code


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Tuesday, April 23, 2019 7:20 PM
    Moderator
  • Karen,

    Now that is truly cool!  And I actually understand it.  

    Thanks


    gwboolean

    Tuesday, April 23, 2019 7:35 PM
  • Karen,

    Now that is truly cool!  And I actually understand it.  

    Thanks


    gwboolean

    I Think it's the right way to go :-)

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Tuesday, April 23, 2019 7:46 PM
    Moderator