Movatterモバイル変換


[0]ホーム

URL:


Wayback Machine
8 captures
10 Sep 2009 - 28 Feb 2017
MayAUGJun
Previous capture30Next capture
201020112012
success
fail
COLLECTED BY
Organization:Alexa Crawls
Starting in 1996,Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to theWayback Machine after an embargo period.
Collection:Alexa Crawls
Starting in 1996,Alexa Internet has been donating their crawl data to the Internet Archive. Flowing in every day, these data are added to theWayback Machine after an embargo period.
TIMESTAMPS
loading
The Wayback Machine - https://web.archive.org/web/20110830073211/http://www.codeproject.com:80/KB/edit/LinkedTextBox.aspx
Click here to Skip to main content
8,050,240 members and growing! (50,619 online)
EmailPassword Lost password?
Home
Search within:




Licence CPOL
First Posted 7 Sep 2009
Views 7,658
Downloads 51
Bookmarked 18 times

Linked TextBox

ByPaw Jershauge | 7 Sep 2009
How to make the textbox act as a hyperlink when the Control key is pressed.
 
See Also
Print Article
add
Add to your CodeProject bookmarks
Discuss
Discuss this article
1
  4.69 (6 votes)

1

2
1 vote, 16.7%
3
1 vote, 16.7%
4
4 votes, 66.7%
5
4.69/5 - 6 votes
μ 4.69, σa 1.46 [?]
Sponsored Links

LinkedTextBox_new.jpg

Introduction

This is a short demo on how to make a textbox act as a hyperlink when the CTRL key is pressed and the control has the focus.

Background

I needed aLinkedTextBox control for a customer.

Using the code

The control has three additional properties:

  • CltrHyperLink
  • HyperLinkColor
  • HyperLinkVisitedColor

A new Event:

  • HyperLinkClicked

And a new Virtual method:

  • OnHyperLinkClicked

Setting theCtrlHyperLink property totrue activates all the other properties and events.

HyperLinkColor is the color of the hyperlink when it is in the default state.HyperLinkVisitedColor is the color of the hyperlink in its visited state. Listening to theHyperLinkClicked event will result in the event being fired when the user holds down the Control key and clicks the left mouse button.OnHyperLinkClicked can be overridden if needed.

Overridding some of the features of the TextBox

protectedoverridevoid OnKeyUp(KeyEventArgs e){base.OnKeyUp(e);    FormatTextBox(false);//Set the decoration of the textbox to standard}protectedoverridevoid OnKeyDown(KeyEventArgs e){base.OnKeyDown(e);    FormatTextBox(e.Control);//if true Set the decoration of the textbox//to an hyperlink else standard.}protectedoverridevoid OnMouseClick(MouseEventArgs e){base.OnMouseClick(e);if (_IsHyperLink && e.Button == MouseButtons.Left)//If the the control is in hyperlink mode//and the left mouse button was clicked...    {        OnHyperLinkClicked(new EventArgs());        FormatTextBox(false);    }}privatevoid FormatTextBox(bool ShowAsLink){if (!_CltrHyperLink)return;if (ShowAsLink)    {        Font =new Font(Font, FontStyle.Underline);        ForeColor = (!_HyperLinkVisited ? _HyperLinkColor :                       _HyperLinkVisitedColor);        Cursor = Cursors.Hand;        _IsHyperLink =true;    }else    {        Font =new Font(Font, FontStyle.Regular);        ForeColor = SystemColors.WindowText;        Cursor = Cursors.Default;        _IsHyberLink =false;    }}protectedvirtualvoid OnHyperLinkClicked(EventArgs e){    _HyperLinkVisited =true;if (HyperLinkClicked !=null)        HyperLinkClicked(this, e);}

History

  • 7 Sep. 2009 - First release.

License

This article, along with any associated source code and files, is licensed underThe Code Project Open License (CPOL)

About the Author

Paw Jershauge

Software Developer

Denmark Denmark

Member
ListView Group Sorter
An Code Generator, for making SQL table into .Net Classses (2nd place in theCode Generation 2008 Competition)
A Class for getting the Rss feed list of a website
Seagate Date Code Calculator
DNSBL lookup Class
Base N converter (N = 10-62)
Lightweight Directory Access Protocol Uniform resource identifier (LDAPUri)
LoginHours from DirectoryEntry into boolean array

Sign Up to vote for this article
Add a reason or comment to your vote:x
Votes of 3 or less require a comment

Comments and Discussions

 
 RefreshFirstPrevNext
General[Message Deleted]memberDavid Sleeckx2:12 7 Sep '09  
Last Visit: 19:00 31 Dec '99     Last Update: 22:32 29 Aug '111

General General   News News   Suggestion Suggestion   Question Question   Bug Bug   Answer Answer   Joke Joke   Rant Rant   Admin Admin   

Permalink |Advertise |Privacy |Mobile
|Web22 |2.3.110826.1
Article Copyright 2009 by Paw Jershauge
Everything elseCopyright ©CodeProject, 1999-2011
Terms of Use
Layout:fixed|fluid

The Daily Insider

[8]ページ先頭

©2009-2025 Movatter.jp