Link to home
Start Free TrialLog in
Avatar of babybird
babybird

asked on

passing array in tag property of control (C#.net winforms)

I am dynamically building controls on a screen and need to attach some values for later reference to each control.  I attached an array of 2 values to each control through the Tag property.  So now I'm where I need to get those values out but I cannot figure out the syntax to access them.  Sorry if this is a lame question...I'm new at C#.net.  This is how I attached them:

                string[] strCtrlArray = new string[2];
                strCtrlArray[0] = strReportParameterName;
                strCtrlArray[1] = strParmCtrlProperty;

                    Type ctype = Type.GetType(strClsName);
                    objCtrl = Activator.CreateInstance(ctype);

                    strProp = "Tag";
                    pinf = ctype.GetProperty(strProp);
                    pinf.SetValue(objCtrl, strCtrlArray, null);
                   
                    this.Controls.Add(objCtrl as Control);

I know the values are there in an array because I can see them in debug.    But I can't figure out the syntax to get them out.

Thank you so much for your help!                
ASKER CERTIFIED SOLUTION
Avatar of Ravi Singh
Ravi Singh
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of babybird
babybird

ASKER

Thank you so much! That worked!