Solved

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

Posted on 2006-06-12
2
375 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 125 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

627 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