Winform学习(6)--杂项

C# richTextBox控件中 点击超链接 自动调用系统浏览器打开 三步解决
1、把 RichTextBox控件的属性中的 DetectUrl 设成 true,这样就会自动将 http://这样的URL设成链接形式
2、选中RichTextBox,右击->属性->事件选项卡->找到事件:LinkClicked,双击,即可自动生成并转到对应的事件函数rtbAbout_LinkClicked代码处
3、在事件函数里面加入一句话,调用浏览器,如下所示:

  1.      private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
    
  2.      {
    
  3.          // Call Process.Start method to open a browser, with link text as URL
    
  4.          System.Diagnostics.Process.Start(e.LinkText); // call default browser
    
  5.      }
    

其中,如果指定IExplore.exe,就是调用IE打开,否则就是调用系统所设置的默认的浏览器打开此链接。
2.获取生成可执行文件的路径

string path = Application.StartupPath;

(需要用到system.Windows.Forms命名空间,若无,则可以在添加引用中点击浏览,搜索System.Windows.Forms.dll添加再引用即可)
[2019.7.26]
A
//在界面找控件

Control[] c = Design_Window.Controls.Find("controlname", false);

//使用控件

(控件类型)c[0]

B
//跨窗体传值(一种方法)

Form fr = Application.OpenForms [ formName ]; 
if(fr!=null)
{
    Form1 f1=(Form1)fr
    //就可以操控已打开的Form1窗体了
}

你可能感兴趣的:(Winform,C#)