How to give link to a text which is typed in scintillaNET editor? Is it possible. Any suggestion would be appreciable. Thanks in advance
Asked
Active
Viewed 292 times
0
-
possible duplicate of [link from webbrowser to ScintillaNET editor in a same c# form?](http://stackoverflow.com/questions/27498332/link-from-webbrowser-to-scintillanet-editor-in-a-same-c-sharp-form) – ekhumoro Dec 17 '14 at 18:23
1 Answers
0
IMHO, I think it is not a duplicate of link from webbrowser to ScintillaNET editor in a same c# form.
To define a part of a document as a link, you could apply a Style to it (See link).
ScintillaCtlName.StartStyling(5);
//Being 5 the start position of the link
ScintillaCtlName.SetStyling(6, 40);
//Being 6 the lenght of the link and 40 the style number that you are using as a link.
You can use any style between 40 and 255. For example, if you choose style #40 to mark a part of text as a link, you could define it in this manner...
ScintillaCtlName.Styles[40].ForeColor = Color.Blue;
ScintillaCtlName.Styles[40].BackColor = Color.White;
ScintillaCtlName.Styles[40].Bold = false;
//The "Hotspot" property allows you to raise an event when you click on the text where style # 40 is applied
ScintillaCtlName.Styles[40].Hotspot = true;
ScintillaCtlName.Styles[40].Visible = true;
ScintillaCtlName.Styles[40].Underline = true;
You should attach an event handler to Scintilla control:
ScintillaCtlName.HotspotClick +=
new System.EventHandler<ScintillaNET.HotspotClickEventArgs>this.ScintillaCtlName_HotspotClick);
Then, when you capture this event, code as needed:
private void ScintillaCtlName_HotspotClick(object sender, HotspotClickEventArgs e)
{
//Your code...
MessageBox.Show("Link Clicked!!!");
//e.Modifiers: gets the modifier keys (SHIFT, CTRL, ALT) held down when clicked.
//e.Position: gets the zero-based document position of the text clicked.
}

Ignotus
- 564
- 5
- 17