Is there any patch or source code to detect a special language's keyword(i want SQL Query detector) and color it ?
Except searching for each keyword and color it manually ! like this link
At least the most simple solution.
Related
How do I add "styled" (bold, italic etc.) tips in C#? Or is there any way to do this?
PS: That code on image doesn't work.
The "styling" in your image is not part of the C# specification. It's just your editor (Sublime?) that does some basic parsing, and sets the text color of items it recognizes.
You can see for yourself if you open your so-called "styled" source code in a plain text editor such as TextEdit or Notepad. Even if you can see colors again, they are assigned by that software in turn.
I am working in a RichTextBox and I need to highlight certain text as incorrect (by my own checking). I have crawled all over the web trying to find something- preferably a package or library that I can use to achieve this...
I'm very surprised that this format isn't a default style in the RTB font style settings...
I'm currently developing a C# desktop application which is a simple virtual keyboard with word prediction facility.
The prediction process will start after typing the first three letters of the word, then provide the suggestions. I need to track the caret while typing, and I tried to use richTextBox events such as SelectionChanged but it requires regular expression check and position tracking manually ( declaring variables ... ).
My questions: is there any suggestions that can help me in doing this task ? What about Listeners? are they helpful?
Note: I have no long experience with .NET framework and I didn't use Listeners before.
Also note that the input method is eye gaze ! which means non of key- events will work !
Thank you.
Will this be in WPF or WinForms? I would tackle this problem as follows. Maybe not the fastest way but worth to try until you have something else.
OnKeyDown event of your RTB check if the last char was a space. If not get whole word from last space and check against list of words and update the list on screen.
to check where the cursor is at the time in your word just do the same as above and try to get the current word and than the indexof specific key.
i have "search TextBox" to search in treeview, i give result very well. But i want to get those parts get Bold which i typed in "search TextBox" of my winform.
Ex: i Typed Ram then it gives *Ram*esh .
The TreeNode class doesn't support that, its Text is always drawn with one font, the TreeView.Font. Making parts of the text bold is technically possible but very hard to get right. You need to enable custom drawing with the TreeView.DrawMode property and DrawItem event, there's a good example of it in the MSDN Library article.
That's the easy part, the hard problem is that the node is too small to fit the text after you draw parts of it in a bold font. TreeView is missing a "MeasureNodeText" event that would allow you to ask for enough space. The only workaround for that is to lie about the node text and make it artificially wider by prefixing characters. Which you then don't draw in the DrawItem event. Very hard to get consistently right, you'll want to consider a fixed pitch font instead.
I cannot recommend you pursue this unless the feature is really important to you. This otherwise explains why you never see this feature in other programs. Consider changing the color instead of the font weight too. Still hard to glue the pieces together btw.
Question A.
Given
A string in rich text format that may have paragraph, tabs, space, line break, indentation, (or even image?)
A width for the word wrapping rich text control/editor
How do I know the height of the content after it have performed all the word wrapping?
Is there something like
int MeasureRichTextHeightAfterWordWrap(string aRichTextContent, int aWidth)?
Otherwise how does those rich text control know how much to autosize?
Do I have to actually place the content on a dummy rich text control, set it's width and get its height with GetPositionFromCharIndex(TextLength-1) afterwards?
Although this does work, it seems to be "wasteful"
Question B.
If I draw plain text onto a plain text memo/control/editor,
and manually draw string with manually calculated indentations, breaks, word wrappings to pretend the RTF.
Is it easier or harder?
Edited to make it look clearer
and sorry if my English looks like a student cause it's not my native language.
Sorry about my bad first attempt at an answer. I DID find an answer for measuring inside a RichTextBox. Apparently you have to use Win32 GDI API calls.
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.framework.windowsforms.controls/2004-09/0574.html
I found this by changing my search after running across this nugget, which explains why there's not a pure .NET way to do it:
http://www.developmentnow.com/g/38_2005_10_0_0_626243/I-dont-believe-this-code-gives-the-correct-RichTextBox-string-size.htm