Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all!

i have an arraylist of string
"AAA"
"BBB"
"CCC"

and i have six buttons their names are

AAA
BBB
CCC
DDD
EEE
FFF

and their visibility is false

now from arraylist i want to show their visibility as true
only whose names are in arraylist
Posted

Where are you stuck ? Despite being weird, it's kind of trivial. You need to iterate over your buttons and compare their names to the strings you have in your array.
 
Share this answer
 
Comments
kami124 10-Aug-11 1:51am    
public static void create_button()
{
for (int i = 0; i < arrlist.Count; i++)
{
string value = arrlist[i] as string;
value.visible=true
}
MessageBox.Show(value);
}

now over here value and button name are same and i want to set visible like this
Christian Graus 10-Aug-11 2:27am    
OK, so you have no idea how to program at all ? I suggest you read a beginner book if you don't know how to compare two values.
It might help,

I assume all the Buttons have been created in design time,

C#
namespace ButtonsVisibilityTest
{
    using System;
    using System.Collections;
    using System.Windows.Forms;
    public partial class frmMain : Form
    {
        private ArrayList visibilityControlList = new ArrayList() { "AAA", "BBB", "CCC" };
        public frmMain()
        {
            InitializeComponent();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            AAA.Visible = GetVisibilityStatus(AAA.Text);
            BBB.Visible = GetVisibilityStatus(BBB.Text);
            CCC.Visible = GetVisibilityStatus(CCC.Text);
            DDD.Visible = GetVisibilityStatus(DDD.Text);
            EEE.Visible = GetVisibilityStatus(EEE.Text);
            FFF.Visible = GetVisibilityStatus(FFF.Text);
        }
        private bool GetVisibilityStatus(string buttonName)
        {
            return visibilityControlList.Contains(buttonName);
        }
    }
}


:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900