Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-06-12
2
Medium Priority
?
381 Views
Last Modified: 2012-06-27
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!                
0
Comment
Question by:babybird
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 500 total points
ID: 16890169
Assuming you have the control object then you'll just have to cast the tag properties' value back to a string array:

string[] array = (string[]) objCtrl.Tag;
0
 

Author Comment

by:babybird
ID: 16890208
Thank you so much! That worked!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

715 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