Предположим, у меня есть FlowLayoutPanel
с именем panel1
, с control1
, control2
, control3
внутри. Каждый элемент управления имеет метод .doSomething()
или сохраненную переменную .name
. Как мне получить к ним доступ?
Что-то вроде:
panel1.Controls[0].doSomething();
string name = panel1.Controls[0].name;
Мой код:
public partial class ChatItem : UserControl
{
public string username, description, mainUser; /// <summary>
/// mainUser este utilizatorul care foloseste in prezent aplicatia
/// </summary>
MySqlConnection basicConnection, chatUpdater, msgSender;
#region Properties
[Category("Custom Properties")]
public string user
{
get { return label1.Text; }
set { label1.Text = username = value; }
}
[Category("Custom Properties")]
public Image profilePicture
{
get { return pictureBox1.Image; }
set { pictureBox1.Image = value; }
}
public Image dot
{
get { return pictureBox2.Image; }
set { pictureBox2.Image = value; }
}
#endregion
public void doSomething()
{
MessageBox.Show("something");
}
}
Я хочу получить доступ к .doSomething()
и description
. Как можно Я так делаю?