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.
Related
Hello I am creating a c# code editor application with ScintillaNet control. I am implementing a functionality where syntax errors are shown while typing. I wanted an X image to be shown on lines with errors.
For this, I used MarkerSymbol.RgbaImage(bitmap);
The problem is that I can ot find any margin mask that worked with it.
The masks Marker.MaskAll and Marker.MaskFolders show the x image but also show folding symbols that I dont want. The rest of the masks dont even show the image. I found that the rgbaimage marker’s index is 30, but I tried (1<<30) for the mask and still nothing was shown. The image only show in maskall and maskfolders but also folding symbols are shown over it.
I don’t know how to solve this. Also though of using text instead of symbols for the MarginType but I cannot find on internet any tutorial or documentations on how to implement it, especially on C# for scintillaNet. Can you help me?
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...
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.
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