I am trying to break out of vb into c# and needed a personal project to get some c# practice in to cement the syntax differences in my mind.
I decided (for want of something better) to write a little twitter client, only something basic.
I have designed a user control to contain the info about each tweet (the tweet itself, the user that tweeted, the date and time etc). As we know tweets can contain embedded links in their text and I was wondering how you handle this in a windows form.
There seems to be a Linklabel control, but you don't seem to be able to have normal text in it, the Label control similarly doesn't support clickable links.
Would I have to embed a link label inside a normal label control and parse the tweet text for url's?
Or am I approaching this in completely the wrong way? :)
You can (sort of) combine normal and linked text in a LinkLabel:
this.linkLabel1.Text = "Here is some text";
this.linkLabel1.LinkArea = new LinkArea(0, 4);
Problem is, there can only (AFAIK) be one link destination, which is obviously not going to work for your purposes.
One possibility may be to use the RichTextBox, and handle the LinkClicked event. I'm not sure if that will give you enough information, but if nothing else, will provide some good practice, since that's the goal anyhow!
Related
I believe am in need of creating custom RichTextBox in C#. One kind of like that:
I admit it might not even have to be RichTextBox, but after some research I decided it's gonna be the easiest way. Functionality I need are icons at each row, checkboxes and text formatting. My program will process each line of the text and mark lines that are correct, incorrect, and strike out lines not necessary in further work, while showing line that's currently processed and allowing user to edit some lines freely (here: lines before Around 3 000 won't be editable, but those under the line will).
What's the problem then? I have no idea how to get it done. I've seen tutorial on how to make single-line textBox with icon or checkbox nearby, but I have no idea how to make both, and for multiline textBox (so I could freely scroll and everything would work fluently). I've read some questions on SO as well, but neither helped me.
I just don't know how to get started, I realize it won't be 5 min work, but I'm willing to do it. Until now I've been only able to create custom control deriving from RichTextBox, but I have no idea which methods and how to override. Any help appreciated.
Try to use WebBrowser control instead RichTextBox.
You can add CheckBoxes and editable content by setting a correct HTML code to it.
Set each TextBox or CheckBoxes ids and use GetElementsByTagName or GetElementById to access inner elements to get or set its attributes or values.
I'm pretty sure you all know what I'm referring to. It's like a textarea, and lets you enter stuff, and a little slide up menu will appear (kind of like an intellisense thing - displaying different words that it thinks you're going to type), and when u click it, or hit enter, it creates a little box inside the textarea with that word inside it. I need to find one of these (or make it myself), and I also need to grab those words entered and to some data stuff in Javascript before inserting them into the database. The "textarea" thing I'm talking about, incase I've got you completely lost, looks something like this:
Does anyone know if there are libraries/plugins etc that are available? Any help will be much appreciated!
Thank you :)
The correct term for it is a tag input. Google has lots of results for them.
Here's one I've used before: http://levycarneiro.com/projects/tag-it/example.html
Facebook style Tag input
AutoComplete Examples
this is not a textarea or input box, Contenteditable allows you to do this.
<div contenteditable="true"><span class="tag">tag1</span></div>
just like an input box you can write in a conteneditable div.
I'm looking for a Textbox control that works similar to the email recipient textboxes in Outlook (the To, Cc and Bcc inputs). It shall have below characteristics.
Allow user text inputs with auto complete based on history
Word/Phrase identification, separation, underlining (like links)
Keep a list of objects represented by these words/phrases
Once click on a work/phrase fire an event to show the corresponding object related to that entry.
If nothing is out there, I may look to develop one by my own. Any help to direct me either on existing controls or how to do it, is highly appreciated.
Tks,
- Eranga
I don't know of products out there but i'd approach this problem by having a look at the code in the richtextbox WPF Extended toolkit (you can nuget it but i'd download the code)
In there is a formatter which will allow you to markup flowdocuments in the rtb. if each address is stored as a run in the rtb you have your list of separate items which you can process as you like. there also a bunch of events you can hook into as well.
All this assumes you are using WPF.
I already did some research and ended up with several autocomplete boxes which have one thing in common: they all match the whole expression which has been entered. Sometimes, they seem to be easily expandable, but at the end, they aren't.
However, I need a Textbox which allows the user to enter a word (e.g. "tag1"), displays a popup with some suggestions based on this single word, accept the suggestion with the return key and type in a new word (e.g "tag1 tag2") in the same textbox, with the popup popping up again. (I like the way CintaNotes handles this)
I need this for a tagging interface. It's often faster for the user to write the tags into a simple box, but sometimes, he needs assistance. This is what the autocomplete is for.
I've found some results, which don't work for my purpose (imho):
http://www.wpfpedia.com/item/details/743/wpf-autocomplete-textbox-control
http://www.codeproject.com/KB/WPF/WPF_Autocomplete.aspx
http://www.codeproject.com/KB/WPF/autocomplete_textbox.aspx
http://weblogs.thinktecture.com/cnagel/2011/01/autocomplete-textbox-with-wpf.html
Btw, I really like the way the Tag-Box for SO operates.
Does anyone have an idea? Is there a "out-of-the-box" - solution somewhere, which suits my needs but I didn't find? Or do I have to build one myself?
Thanks! :)
I think you mean a textbox which autocomplete for multiple words.
Like TokenizedTexbox on WPF Extended Toolkit.
this is the page: http://wpftoolkit.codeplex.com/wikipage?title=TokenizedTextBox&referringTitle=Home
Probably you would need to create your own Dictionary object of Key and Value pairs and hook that Dictionary to the textbox events and popup a suggestions dialog that displays the Value(s) from your Dictionary
Check this implementation out: http://code.google.com/p/kocontrols/downloads/list
You may inject your own Search algorithm and your own converter which converts the selected element to text, which you display in the TextBox. You will have to modify it slightly but I think that you might be able to solve your problem by basing your control on this implementation.
I never thought about this type of use case.
Can't you use different textboxes for the different tags? Something similar to how goole code does it?
If you have time, you can use the RichEditControl or TextBox and apply the same pattern used in Intellisense engine or Code Completation enabled editors: Hook the text changes events, Recogize context (last/current word) and display the options list on popup control. And optionally, on commit (detect acceptation or space key), apply the format to the word.
i was wondering if it is possible in c# to set to a text box a list of strings that are clickable links? at the moment i can set the text box like this
txtBox.Lines = values.ToArray();
ideally though i would like them as links if possible? maybe link labels or something?
(I'm assuming you're using Windows Forms; the answer for WPF/Silverlight may be slightly different.)
A textbox just contains text - it's not "rich" enough to have links.
If you want a list you might want to consider using a ListBox of some description - or possibly a RichTextBox; I haven't tried creating links in a RichTextBox, so I don't know whether it's possible.
Of course, you haven't specified what you want to happen when the user clicks on the links, either...
Use RichTextBox and check this - http://www.codeproject.com/KB/edit/RichTextBoxLinks.aspx
You can try using Windows.Forms.Controls.LinkLabel. It allows storing multiple links along with the text in it.