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. Winforms Question

Winforms Question

Scheduled Pinned Locked Moved Visual Basic
helpcsharpwinformsdockerquestion
4 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.
  • B Offline
    B Offline
    batmike2000
    wrote on last edited by
    #1

    hi all, I'm having a bit of an issue here and maybe one of you guys can help me out :-D. I'm looking for a way to return all COMPONENTS in a form during run-time, and i mean components including all controls , menu's, custom controls etc. As you all now a control is a component but a component is not a control. You will probably think that i'm somesort of idiot , but i'm not ;-) (at least i think i'm not), and i've tried every possible way to reach my goal: 1) tried to convert the form as container -> didn't work 2) adding the component that needs to perform above actions and using it's own container as componentcollection holder doesn't work, bcause the container returned is the component itself. 3) returning a menu's container -> doesn't work -> it always returns nothing batmike2000

    L 1 Reply Last reply
    0
    • B batmike2000

      hi all, I'm having a bit of an issue here and maybe one of you guys can help me out :-D. I'm looking for a way to return all COMPONENTS in a form during run-time, and i mean components including all controls , menu's, custom controls etc. As you all now a control is a component but a component is not a control. You will probably think that i'm somesort of idiot , but i'm not ;-) (at least i think i'm not), and i've tried every possible way to reach my goal: 1) tried to convert the form as container -> didn't work 2) adding the component that needs to perform above actions and using it's own container as componentcollection holder doesn't work, bcause the container returned is the component itself. 3) returning a menu's container -> doesn't work -> it always returns nothing batmike2000

      L Offline
      L Offline
      Leeland
      wrote on last edited by
      #2

      There may be an easier answer than just digging up one for this. What's the final goal you're trying to reach?

      B 2 Replies Last reply
      0
      • L Leeland

        There may be an easier answer than just digging up one for this. What's the final goal you're trying to reach?

        B Offline
        B Offline
        batmike2000
        wrote on last edited by
        #3

        Hi leeland, the final goal to achieve is a complete component and control iteration of a form to disable /enable them and make them in-/visible if demanded. But this in a dynamic way, cause i never can tell in advance what will be on the Form. kr. batmike2000

        1 Reply Last reply
        0
        • L Leeland

          There may be an easier answer than just digging up one for this. What's the final goal you're trying to reach?

          B Offline
          B Offline
          batmike2000
          wrote on last edited by
          #4

          tnx Leeland, i've found the solution: i needed to use reflection strFormName = param_Form.Name Dim param_Form_type As Type = param_Form.GetType() Dim compFields As FieldInfo() = param_Form_type.GetFields(BindingFlags.Instance Or BindingFlags.NonPublic) For Each fiField As FieldInfo In compFields Dim strCtrl(1) As String strCtrl = ReturnCompName(fiField, param_Form) For Each dr As DataRow In myrs.Rows If strCtrl(0) = dr("SecAuthCtrl_Name") And fiField.FieldType.FullName = dr("SecAuthCtrl_Type") Then Select Case fiField.FieldType.FullName.ToLower Case "System.Windows.Forms.ToolBarButton".ToLower Dim cmp As ToolBarButton = DirectCast(fiField.GetValue(param_Form), ToolBarButton) cmp.Enabled = dr("SecAuthorized_Enabled") cmp.Visible = dr("SecAuthorized_Visible") Case "System.Windows.Forms.MenuItem".ToLower Dim cmp As MenuItem = DirectCast(fiField.GetValue(param_Form), MenuItem) cmp.Enabled = dr("SecAuthorized_Enabled") cmp.Visible = dr("SecAuthorized_Visible") Case Else End Select End If Next Next this works now, tnx for your effort batmike2000

          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