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
Solved

How to make multi-dimensional, untyped array?

Posted on 2008-06-24
1
574 Views
Last Modified: 2013-11-07
I would like to store a key with 4 associated controls to it so I can make changes to several controls within a loop. For example, this is what I'm trying to store into an array:

1.) header, (Literal)headerLiteral, (TextBox)headerTextbox, (DropDown)headerDropdown, (CheckBox)headerCheckbox;

2.) content, (Literal)contentLiteral, (TextBox)contentTextbox, (DropDown)contentDropdown, (CheckBox)contentCheckbox;

3.) footer, (Literal)footerLiteral, (TextBox)footerTextbox, (DropDown)footerDropdown, (CheckBox)footerCheckbox;

This way, I can do something like:
for (int i = 0; i < someArray.Count; i++)
{
    (Literal)someArray[i][1].Text = someArray[i][0] + " Section";
    (TextBox)someArray[i][2].Text = String.Empty;
    (DropDown)someArray[i][3].SelectedIndex = 0;
    (CheckBox)someArray[i][4].Checked = false;
}

Also, it might be too much to ask, but I also would like to reference the array element by the associative key name, like: (Literal)someArray["footer"][1].Text = "Footer Section";

Can anybody help me with choosing the right C# array/collection for this type of usage?
0
Comment
Question by:bemara57
1 Comment
 
LVL 7

Accepted Solution

by:
nsanga earned 500 total points
ID: 21856962
if the sub items in the array ( i.e. controls ) are predefined or known earlier you can do this...

1) define a class with the required types (header, Literal, TextBox,DropDown,CheckBox)
2) for each row create an object of above class type and set the members
3) add the above created objects to a hashtable or other collection dictionary typed collection with required keys....

It is always better to program things in systematic manner with required userdefined types.......

let me know if this is not you are looking for....
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 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