Skip to content

Is this possible?, regarding Tables

Shane Sandwith

Asked Mar 22, 2006, 9:55 PM EST1 answer
Share
LinkedInX

I have ten tables on a form, all tables are run at server, what i want to do is instead of creating ten if statements to check if the tables are visible i want to create a while loop and then use a var to move from one table to the next. My tables are named tbl1, tbl2, tbl3 etc. eg

int x = 1;

string tablename = "tbl";

while (x < 10)
{
tablename = tablename + x;
 if (tablename.Visible == true)
{
//do something
}
x = x + 1
}

Can someone please help me, please bear in mind, i am still classified as a junior, so keep the code relatively simple....please.

Thanks
Shane

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Well... Based on the simple layout you gave us I don't think your current setup is very correct. You don't want to have ten tables with simalir names. You want ten tables in an array(A collection in C#). If for some reason you dont you have control over this or you dont know what arrays are(if not you should look into them for the future) there is another way I can think of to do this. this is some psueduo C# code so bar with me: foreach(Control co in this.Controls) { if(co.GetType() == typeof(table) && co.visible == true) { //do something } }
    0