Modify Windows Forms Control from another Project

前端 未结 3 891
广开言路
广开言路 2021-01-19 02:48

I have a Control lblDate in User Control MainScreen. I would like to modify it in a method in class Date, which is in another project

3条回答
  •  悲&欢浪女
    2021-01-19 03:12

    the propertie LabelDate is from the class of your userControl MainScreen, but you're not instatiating any userControl.. Which instance of MainScreen do you expect to modify then?

    you should do

    this.controlMainScreen.LabelDate = GameDate;
    

    considering that you say in your comments, that you have

     FormMain.Designer.cs there is: this.controlMainScreen = new Adventurers_of_Wintercrest.UserControls.MainScreen();
    

提交回复
热议问题