vsto 中有两个 myCustomTaskPane即时改变对方内部控件属性

rustic_erphone 2019-05-29 12:15:43
各位大神,我做一个vsto 项目的一个addin,其中有两个 myCustomTaskPane,
myCustomTaskPane1和2都各是一个forms.usercontrol。
要在myCustomTaskPane1的中的combobox1值改变时,去改变myCustomTaskPane2的lable1.
也就是让myCustomTaskPane2的lable2的值随着myCustomTaskPane1的combobox1的值而即时地改变。

我原来模仿一个窗体的值给另一个窗体的控件赋值,但是不行,
请问正确的设置方式,最好拜托能给个示例。
3Q

...全文
239 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
耗子哭死猫 2019-05-30
  • 打赏
  • 举报
回复

    public Form1()
        {
            InitializeComponent();
            userControl1.comboBox1.SelectedIndexChanged += ComboBox1_SelectedIndexChanged;
        }

        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

          
            switch (userControl31.comboBox1.SelectedItem)
            {
                case "1":
                    userControl41.TextOfTextBox = "11111";
                    break;
                case "2":
                    userControl41.TextOfTextBox = "22222";
                    break;
                case "3":
                    userControl41.TextOfTextBox = "33333";
                    break;
                case "4":
                    userControl41.TextOfTextBox = "44444";
                    break;
            }
        }
public System.Windows.Forms.ComboBox comboBox1;

    public string LabelText
        {
            get { return this.label1.Text; }
            set { this.label1.Text = value; }
        }
耗子哭死猫 2019-05-30
  • 打赏
  • 举报
回复
-----邮箱发过来
rustic_erphone 2019-05-30
  • 打赏
  • 举报
回复
引用 1 楼 耗子哭死猫 的回复:
ComboBox1_SelectedIndexChanged事件中写,或者委托comboBox1.SelectedIndexChanged +=ComboBox1_SelectedIndexChanged
在方法实例化myCustomTaskPane2 my2=new myCustomTaskPane2 ();

my2.lable2="hello"; lable2设置public访问


https://download.csdn.net/download/u010457371/6569469
请帮我看看好吗
rustic_erphone 2019-05-30
  • 打赏
  • 举报
回复
引用 10 楼 耗子哭死猫的回复:
[quote=引用 8 楼 rustic_erphone 的回复:] [quote=引用 5 楼 耗子哭死猫的回复:]

    public Form1()
        {
            InitializeComponent();
            userControl1.comboBox1.SelectedIndexChanged += ComboBox1_SelectedIndexChanged;
        }

        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

          
            switch (userControl31.comboBox1.SelectedItem)
            {
                case "1":
                    userControl41.TextOfTextBox = "11111";
                    break;
                case "2":
                    userControl41.TextOfTextBox = "22222";
                    break;
                case "3":
                    userControl41.TextOfTextBox = "33333";
                    break;
                case "4":
                    userControl41.TextOfTextBox = "44444";
                    break;
            }
        }
public System.Windows.Forms.ComboBox comboBox1;

    public string LabelText
        {
            get { return this.label1.Text; }
            set { this.label1.Text = value; }
        }
不是form里面的呀[/quote]
     public UserControl3()
        {
            InitializeComponent();
        }
        public event Action<string> SubmitEvent;
        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedItem)
            {
                case "1":
                    SubmitEvent("1111");
                    break;
                case "2":
                    SubmitEvent("2222");
                    break;
                case "3":
                    SubmitEvent("3333");
                    break;
                case "4":
                    SubmitEvent("4444");
                    break;
            }
        }



  public Form2()
        {
            InitializeComponent();
            userControl31.SubmitEvent += new Action<string>(labelTextEvent);
     
        }

        void labelTextEvent(string obj)
        {
            userControl41.LabelText = obj;
        }
     public UserControl4()
        {
            InitializeComponent();
        }
        public string LabelText
        {
            get { return this.label1.Text; }
            set { this.label1.Text = value; }
        }
[/quote] 收到 我先结贴 等会儿再研究 委托的办法 我搞了很久就是有些问题 真是太感谢你了 努力向你学习
耗子哭死猫 2019-05-30
  • 打赏
  • 举报
回复
引用 8 楼 rustic_erphone 的回复:
[quote=引用 5 楼 耗子哭死猫的回复:]

    public Form1()
        {
            InitializeComponent();
            userControl1.comboBox1.SelectedIndexChanged += ComboBox1_SelectedIndexChanged;
        }

        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

          
            switch (userControl31.comboBox1.SelectedItem)
            {
                case "1":
                    userControl41.TextOfTextBox = "11111";
                    break;
                case "2":
                    userControl41.TextOfTextBox = "22222";
                    break;
                case "3":
                    userControl41.TextOfTextBox = "33333";
                    break;
                case "4":
                    userControl41.TextOfTextBox = "44444";
                    break;
            }
        }
public System.Windows.Forms.ComboBox comboBox1;

    public string LabelText
        {
            get { return this.label1.Text; }
            set { this.label1.Text = value; }
        }
不是form里面的呀[/quote]
     public UserControl3()
        {
            InitializeComponent();
        }
        public event Action<string> SubmitEvent;
        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedItem)
            {
                case "1":
                    SubmitEvent("1111");
                    break;
                case "2":
                    SubmitEvent("2222");
                    break;
                case "3":
                    SubmitEvent("3333");
                    break;
                case "4":
                    SubmitEvent("4444");
                    break;
            }
        }



  public Form2()
        {
            InitializeComponent();
            userControl31.SubmitEvent += new Action<string>(labelTextEvent);
     
        }

        void labelTextEvent(string obj)
        {
            userControl41.LabelText = obj;
        }
     public UserControl4()
        {
            InitializeComponent();
        }
        public string LabelText
        {
            get { return this.label1.Text; }
            set { this.label1.Text = value; }
        }
耗子哭死猫 2019-05-30
  • 打赏
  • 举报
回复
引用 7 楼 rustic_erphone 的回复:
[quote=引用 4 楼 耗子哭死猫的回复:]-----邮箱发过来
由于查不到你邮箱,我想发给你也不知怎么发[/quote]给你发了
rustic_erphone 2019-05-30
  • 打赏
  • 举报
回复
引用 5 楼 耗子哭死猫的回复:

    public Form1()
        {
            InitializeComponent();
            userControl1.comboBox1.SelectedIndexChanged += ComboBox1_SelectedIndexChanged;
        }

        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

          
            switch (userControl31.comboBox1.SelectedItem)
            {
                case "1":
                    userControl41.TextOfTextBox = "11111";
                    break;
                case "2":
                    userControl41.TextOfTextBox = "22222";
                    break;
                case "3":
                    userControl41.TextOfTextBox = "33333";
                    break;
                case "4":
                    userControl41.TextOfTextBox = "44444";
                    break;
            }
        }
public System.Windows.Forms.ComboBox comboBox1;

    public string LabelText
        {
            get { return this.label1.Text; }
            set { this.label1.Text = value; }
        }
不是form里面的呀
rustic_erphone 2019-05-30
  • 打赏
  • 举报
回复
引用 4 楼 耗子哭死猫的回复:
-----邮箱发过来
由于查不到你邮箱,我想发给你也不知怎么发
rustic_erphone 2019-05-30
  • 打赏
  • 举报
回复
引用 4 楼 耗子哭死猫的回复:
-----邮箱发过来
erphone@163.com
rustic_erphone 2019-05-29
  • 打赏
  • 举报
回复
引用 1 楼 耗子哭死猫 的回复:
ComboBox1_SelectedIndexChanged事件中写,或者委托comboBox1.SelectedIndexChanged +=ComboBox1_SelectedIndexChanged
在方法实例化myCustomTaskPane2 my2=new myCustomTaskPane2 ();

my2.lable2="hello"; lable2设置public访问


还是不行呀
耗子哭死猫 2019-05-29
  • 打赏
  • 举报
回复
ComboBox1_SelectedIndexChanged事件中写,或者委托comboBox1.SelectedIndexChanged +=ComboBox1_SelectedIndexChanged 在方法实例化myCustomTaskPane2 my2=new myCustomTaskPane2 (); my2.lable2="hello"; lable2设置public访问

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧