Dynamically Controlling form controls.

Posted on 2004-11-03
Last Modified: 2010-04-23
I have all the names of the controls in an DataTable in my application. I need to enable/disable, set textboxes to readonly, set password characters etc from a section of code based on the data in this datatable.
The data will appear the datatable like this:


Can anyone tell me how to do this?

Question by:alfonzocarson
    1 Comment
    LVL 4

    Accepted Solution

    Well, you can do something like this:

    dim ctl as control
    dim rows() as datarow
    for each ctl in me.controls
      rows = YourTable.Select("[CONTROL_NAME] = '" & ctl.Name & "'")
      if rows.length > 0
        ctl.readonly = rows(0)("Read") 'I suppose that Read = Ture is a read only control
      end if

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now