简体   繁体   English

如何将链接标签添加到同步融合控件中的textBox控件

[英]how to add link label to textBox control in syncfusion controls

I have developed a application using win forms. 我已经使用获胜表格开发了一个应用程序。 UI contains one Rich Textbox control which displays information what process is going on at background. UI包含一个Rich Textbox控件,该控件可显示有关后台正在进行的进程的信息。 And I save that information in notepad at specified location. 然后将该信息保存在记事本中的指定位置。 I want to open that notepad from Rich Textbox control, for that I need to provide a link label in Rich Textbox along with text. 我想从Rich Textbox控件中打开该记事本,为此我需要在Rich Textbox中提供一个链接标签以及文本。

you can Add LinkLabel to your RichTextBox and handle the linkLabel_LinkClicked event. 您可以将LinkLabel添加到RichTextBox并处理linkLabel_LinkClicked事件。

Step 1: 第1步:

Add LinkLabel to your RichTextBox Control as below: 如下所示将LinkLabel添加到RichTextBox控件中:

 this.linkLabel1 = new System.Windows.Forms.LinkLabel();

Step 2: Set few Properties as below: 第2步:设置一些属性,如下所示:

this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Text = "Open File";

Step 3: 第三步:

Add an Event Handler for LinkClick Event as below: LinkClick事件添加事件处理程序,如下所示:

this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);

Step 4: Add your LinkLabel to Form as below: 步骤4:将您的LinkLabel添加到Form ,如下所示:

this.Controls.Add(this.linkLabel1);

Step 5: Create a function linkLabel1_LinkClicked() to handle the LinkClick event as below: 步骤5:创建一个函数linkLabel1_LinkClicked()来处理LinkClick事件,如下所示:

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process process = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName = "cmd.exe";
            startInfo.Arguments = "/C notepad.exe c:\\Data.txt";
            process.StartInfo = startInfo;
            process.Start();
        }

I don't quite understand what you mean, but I take it that after you save the information to your text file, you want that "link label" or just label to open your textfile? 我不太理解您的意思,但是我认为在将信息保存到文本文件之后,您是要使用“链接标签”还是仅使用标签来打开文本文件?

Just create an on-click event on that label and use Process.Start. 只需在该标签上创建一个单击事件,然后使用Process.Start。

System.Diagnostics.Process.Start("PathTotxtfile.txt");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM