Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
独立项目中的访问方法,C#,VB_C#_Vb.net - Fatal编程技术网

独立项目中的访问方法,C#,VB

独立项目中的访问方法,C#,VB,c#,vb.net,C#,Vb.net,我有一个C#解决方案中的表单,其中我有一个切换表单示例代码中元素可见性的方法: namespace formplace.formlocation.Ui { public class Form1: Mainform { ... public void activatepanel() { this.panel.visible = true; } } } 在另一个解决方案中,我有一个处理事件的VB解决方案。我希望能够从第二个解决方案中的第一个解决方

我有一个C#解决方案中的表单,其中我有一个切换表单示例代码中元素可见性的方法:

namespace formplace.formlocation.Ui
{
 public class Form1: Mainform
  {
   ...
    public void activatepanel()
    {
     this.panel.visible = true; 
    }
  }
}
在另一个解决方案中,我有一个处理事件的VB解决方案。我希望能够从第二个解决方案中的第一个解决方案调用该方法:

Private Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button.Click
  ...
  Call activatepanel somehow here
  ...
End Sub
目前,当我引用C#解决方案时,格式1。(此处的建议)不显示“方法激活”面板。我该怎么做才能做到这一点?

你为什么要这么做(至少对我来说)有点不清楚。要隐藏在C#projects窗体中的控件在运行时显示,因此,当两个程序都在运行时,您可能希望通过一些进程间通信对VB程序隐藏它。 无论如何,在访问activatepanel()方法之前,您需要拥有该类的实例,或者创建它,或者以其他方式获取它

大概是这样的:

Imports formplace.formlocation.Ui

....

  Private Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles Button.Click
      ...
      Dim csf As formplace.formlocation.Ui.Form1
      csf = New formplace.formlocation.Ui.Form1()
      csf.activatepanel()
      ...
    End Sub

如果我理解正确,您想从Vb表单访问C#方法吗?您是在创建
Form1
的实例,还是在尝试使用类名访问该方法,即尝试使用默认实例?向我们展示您尝试使用的实际代码。