简体   繁体   中英

Showing formatted code in a textbox in C#

Does anyone know how I would show code in a textbox in c#? I am importing the code from a spreadsheet into sql server. Then I need to pull the code out of sql server and store it in a textbox but the spacing is off when I display it and it is hard to read.

Is there any controls or functions that help with this?

Any help is much appreciated.

Edit* This is for a windows form application.

Is this for a web application or a Windows application? There are plugins that do just that for web-based apps.

For instance, I use SyntaxHighlighter by Alex Gorbatchev. It uses javascript so it's not specific to C# or any other language. You can configure it to color different languages eg, in your case, SQL.

For a Windows Form application if you really need some formatting you should use a RichTextBox

With the RichTextBox control, the user can enter and edit text. The control also provides more advanced formatting features than the standard TextBox control. Text can be assigned directly to the control, or can be loaded from a rich text format (RTF) or plain text file. The text within the control can be assigned character and paragraph formatting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM