Hi all,
So I have an application that makes a web service call to a website to get some text to display in a text box.
My application is a win forms application.
I have a few questions:
#1: There is a link that comes through in the text that I want to make clickable in my winforms app textbox. Can I do this with a normal textbox? If not, can I do this using a rich text box?
#2: This text that I get from the web service is originally displayed on a webpage, so the text comes back with HTML tags. Currently, I use a regex to strip the HTML tags. Is there a way in winforms to display HTML?
thanks
Clickable link in winforms textbox
Page 1 of 18 Replies - 13630 Views - Last Post: 16 August 2011 - 12:21 PM
Replies To: Clickable link in winforms textbox
#2
Re: Clickable link in winforms textbox
Posted 16 August 2011 - 10:33 AM
Don't use a textbox unless you want the user to be able to type in it.
Too often people use textboxes just to display text and that isn't the right use of a tool.
Consider a LinkLabel. That's its job in life.
Too often people use textboxes just to display text and that isn't the right use of a tool.
Consider a LinkLabel. That's its job in life.
This post has been edited by tlhIn`toq: 16 August 2011 - 10:33 AM
#3
Re: Clickable link in winforms textbox
Posted 16 August 2011 - 11:04 AM
I've been hearing about a WebBrowser control that can display HTML in a winform. Would this work, does anyone have experience with this control?
#4
Re: Clickable link in winforms textbox
Posted 16 August 2011 - 11:30 AM
Yes, the purpose of a WebBrowser control is to display HTML/Webpages.
You've been 'hearing' about it?
Just look in the Toolbox. Its right there.
Also, look it up on MSDN and learn about it before you just drop it on a form and try to figure it out.
Though, personally, it sounds more and more like you should be working your way through tutorials before you try to build a scratch project.
Just an observation. If you had gone through a "Learn C# in 21 days" type of self-teaching book you would have picked this up. So I am guessing you are trying to teach yourself without first going through a book or tutorial: Just jumping in and trying to design and build a program right off the bat. That really is the hard way to go.
Don't try to create a useful working program to fit a need of yours (or a for-pay contract) as your introduction to coding project. When you are learning to code you don't know enough to code a program, let alone know how to engineer the architecture of a program. It would be like saying "I don't know how to read sheet music, or play an instrument. I think I'll write a 3 act opera as my first learning experience."
We don't say this to be mean. We've seen lots of new coders take this approach and we know it doesn't work. Trying to design your own programs before you understand the basics of the code language you've chosen just leads to problems, frustrations, and 'swiss-cheese' education (lots of holes).
Resources, references and suggestions for new programmers. - Updated Aug 2011
You've been 'hearing' about it?
Just look in the Toolbox. Its right there.
Also, look it up on MSDN and learn about it before you just drop it on a form and try to figure it out.
Though, personally, it sounds more and more like you should be working your way through tutorials before you try to build a scratch project.
Just an observation. If you had gone through a "Learn C# in 21 days" type of self-teaching book you would have picked this up. So I am guessing you are trying to teach yourself without first going through a book or tutorial: Just jumping in and trying to design and build a program right off the bat. That really is the hard way to go.
Don't try to create a useful working program to fit a need of yours (or a for-pay contract) as your introduction to coding project. When you are learning to code you don't know enough to code a program, let alone know how to engineer the architecture of a program. It would be like saying "I don't know how to read sheet music, or play an instrument. I think I'll write a 3 act opera as my first learning experience."
We don't say this to be mean. We've seen lots of new coders take this approach and we know it doesn't work. Trying to design your own programs before you understand the basics of the code language you've chosen just leads to problems, frustrations, and 'swiss-cheese' education (lots of holes).
Resources, references and suggestions for new programmers. - Updated Aug 2011
Spoiler
This post has been edited by tlhIn`toq: 16 August 2011 - 11:31 AM
#5
Re: Clickable link in winforms textbox
Posted 16 August 2011 - 11:39 AM
Uh, im not new to coding or to C#. I am a software developer at a major securities firm. I just have never had to display HTML in a desktop application before. I'm aware that the webbrowser control is already available for me to use, I just feel like I learn better from forum posts than I do MSDN documentation.
#6
Re: Clickable link in winforms textbox
Posted 16 August 2011 - 11:50 AM
Everyone learns differently, that's for sure.
I have this tendency to search, get a little guidance or an example, then drop a component on a form in a test project then work the living daylights out of it. That's me: I learn by doing.
I see you've been here a couple years, certainly by now you know you can search DIC for instances of such questions coming up in the past.
Going to the C# tutorials and doing a search of that forum gets you this WebBrowser tutorial in about 10 seconds.
http://www.dreaminco..._hl__webbrowser
I have this tendency to search, get a little guidance or an example, then drop a component on a form in a test project then work the living daylights out of it. That's me: I learn by doing.
I see you've been here a couple years, certainly by now you know you can search DIC for instances of such questions coming up in the past.
Going to the C# tutorials and doing a search of that forum gets you this WebBrowser tutorial in about 10 seconds.
http://www.dreaminco..._hl__webbrowser

#7
Re: Clickable link in winforms textbox
Posted 16 August 2011 - 11:54 AM
Well then I apologize for this thread. I am pretty new to Visual Studio/.NET... and UI stuff in general. For some reason, I tend to learn more by reading specific responses to my specific questions than I do reading tutorials/documentation. Next time, I'll search DIC b4 I post
#8
Re: Clickable link in winforms textbox
Posted 16 August 2011 - 12:10 PM
Don't take it personally. Some people do learn differently.
One thing I've found is that I'm good at researching. I didn't start out knowing all the answers I gave. Somehow I was able to find answers to questions people had. I wasn't any smarter than them, I just know how to use google/msdn to find what I need.
I suggest always hitting the MSDN for pages about a control/class that you're using or looking at using. They'll always, at the bare minimum, have all the methods/properties/fields/events on an object, and usually have a description and sample usage. That's where I'd start.
One thing I've found is that I'm good at researching. I didn't start out knowing all the answers I gave. Somehow I was able to find answers to questions people had. I wasn't any smarter than them, I just know how to use google/msdn to find what I need.
I suggest always hitting the MSDN for pages about a control/class that you're using or looking at using. They'll always, at the bare minimum, have all the methods/properties/fields/events on an object, and usually have a description and sample usage. That's where I'd start.
#9
Re: Clickable link in winforms textbox
Posted 16 August 2011 - 12:21 PM
A snippet from that resources text I gave you earlier expands on what Curtis is saying.
When someone, anyone, gives you resources don't get offended even if it says 'for new people'. You said yourself you are new to VS and .NET and UI design. If someone gives you resources you already know, then great because you can skim them quickly for any new little tips/tricks. Leaving you more time to concentrate on the areas that are new to you.
If you know an area then working the tutorial doesn't take long.
If working a tutorial does take a while, then its teaching you something new.
Either way its not a waste of time.
Quote
Finding answers to specific problems:
Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word: "MSDN Picturebox", "C# Custom Events", "MSDN timer" etc.
How to do a good search that will get you targeted answers.
Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word: "MSDN Picturebox", "C# Custom Events", "MSDN timer" etc.
How to do a good search that will get you targeted answers.
When someone, anyone, gives you resources don't get offended even if it says 'for new people'. You said yourself you are new to VS and .NET and UI design. If someone gives you resources you already know, then great because you can skim them quickly for any new little tips/tricks. Leaving you more time to concentrate on the areas that are new to you.
If you know an area then working the tutorial doesn't take long.
If working a tutorial does take a while, then its teaching you something new.
Either way its not a waste of time.
Page 1 of 1