Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
I want to create custom control linkbutton from the linklabel for the windows form application.
how it can be possible.
Posted 11-Jan-13 7:02am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Surely, you didn't mention any specific worries, so perhaps start by reading this: Developing Custom Windows Forms Controls with the .NET Framework[^]
 
and few examples:
- Divider Panel - A tutorial on creating a custom Windows Forms control from Start to Toolbox[^]
- Writing your Custom Control: step by step[^]
 
Addition:
To use the same event handler for multiple link labels you could have something like:
linkLabel1.LinkClicked += new LinkLabelLinkClickedEventHandler(AllLinkLabels_LinkClicked);
linkLabel2.LinkClicked += new LinkLabelLinkClickedEventHandler(AllLinkLabels_LinkClicked);
linkLabel3.LinkClicked += new LinkLabelLinkClickedEventHandler(AllLinkLabels_LinkClicked);
 
And the event handler itself could be modified from the following:
private void AllLinkLabels_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
   System.Diagnostics.Process.Start((string)e.Link.LinkData);
}
Of course it needs more logic, exception handling etc, but that would be a start.
  Permalink  
v2
Comments
Marcus Kramer at 11-Jan-13 12:24pm
   
+5. Well put.
Mika Wendelius at 11-Jan-13 12:51pm
   
Thanks Marcus :)
tusharkaushik at 11-Jan-13 14:11pm
   
but i want that if user clicked at newly created inherited control linkbutton , the given url will open in an browser.
can it possible!
Marcus Kramer at 11-Jan-13 14:47pm
   
Of course it is possible. Just write the code to do that in the click handler.
Mika Wendelius at 11-Jan-13 15:00pm
   
Based on the description, do you really need an inherited control for this? Why not just set the links on each linklabel and then register the same eventhandler for all linklabels. See the updated answer.
tusharkaushik at 11-Jan-13 15:23pm
   
ya! I i really need inherited control.
But i wanna create link button inherited from button control.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100