gpt4 book ai didi

c# - 从另一个 userControl c# 访问 userControl 上的对象

转载 作者:太空宇宙 更新时间:2023-11-03 19:21:53 28 4
gpt4 key购买 nike

我有一个包含 ListBoxuserControl。我想从另一个 userControl 访问那个 ListBox

例如:

UserControl1.ListBox1.Items.Count;

最佳答案

在用户控件中添加公共(public)属性 ItemsCount

public int ItemsCount 
{
get { return ListBox1.Items.Count; }
}

or

public ListBox MyListBox
{
get { return ListBox1; }
}

访问整个列表框

关于c# - 从另一个 userControl c# 访问 userControl 上的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11666607/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com