List Info

Thread: How to access controls made at runtime




How to access controls made at runtime
user name
2006-11-10 16:04:11
Ok, I am sure I am doing something wrong. Here is the quick
and dirty pseudo
code:

MainForm{
        Declare menus;
        menuItem1_click handler{
                Drawing Functions DF = new
DrawingFunction();
                DF.DrawCircuit1(this);
        }
        ButtonName_Click handler(
                String x;
                x = TextBoxName.Text
        }
}

DrawingFunctions
        DrawCircuit1(Form f){
                Graphics g = new Graphics;
                g = f.CreateGraphics();
                DrawResistor(100,100,g);
                DrawResistor(100,150,g);
                AddLabel(150,100,f);
               
AddTextBox(160,100,f,"TextBoxName");
                AddButton(170,200,f,"ButtonName");
        }

This will not compile and the error is in the
ButtonName_Click handler as
TextBoxName.Text does not exisit so the complier doesn't
know what to do
with it. So how should this be written as I have many text
boxes and
listboxes that are created for each of the 40 or circuits
that will be
drawn?
All the examples I have researched so far just show you how
to add the
controls to the forms via code, but not a single one shows
you how to use it
once it is there.
Thanks
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )