0

I save a long string in the DB, and I want to show it in a text area in my Winforms application.

I want to highlight letters in my string values, and save it in the database, and show the value in text area.

How can I do this?

My code:

insert into table (Description)
    select '<b>ערך אחד: <b>' + convert(NVARCHAR, t1.MonthlyReturnAmount) + nchar(13) + nchar(10) +
'<b> ערך שני: <b>' + convert(NVARCHAR, t1.LastPaymentDate) + nchar(13) + nchar(10) +
'<b> ערך שלישי: <b>' + case WHEN t2.IsActive=0 then 'לא' else 'כן' END
    from table1 t1
    join table2 t2 on t1.id = t2.filed
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ayal
  • 133
  • 1
  • 1
  • 11
  • `textarea` is html element. For windows forms you need to use `TextBox` or `RichTextBox`. If by highlighting you mean different segments of texts which have been highlighted using a color e.g. yellow, then you need to save rtf in database. – Reza Aghaei Apr 28 '19 at 06:25
  • @RezaAghaei - I in WinForm C#, not windows forms. What am I need to write? Can you give me an example?? – Ayal Apr 28 '19 at 06:31
  • Maybe you mean *WebForms*? because *WinForms* means windows forms. – Reza Aghaei Apr 28 '19 at 07:31
  • I mean win Forms - this have textBox with MultiLines – Ayal Apr 28 '19 at 07:34
  • You cannot highlight multiple segments in `TextBox` in Windows Forms. You may want to use `RichTextBox`. – Reza Aghaei Apr 28 '19 at 07:54
  • So what is `FontStyle.Bold`?? – Ayal Apr 28 '19 at 08:06
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/192515/discussion-between-ayal-and-reza-aghaei). – Ayal Apr 28 '19 at 08:13
  • See the examples here: [How to highlight wrapped text in a control using the graphics?](https://stackoverflow.com/a/48257170/7444103). Note that it's an example, read the **warning** section: if you want to have that code working as expected, you need to use a custom control (a control derived from TextBox or RichTextBox). That code is using `Control.CreateGraphics()`, which is used just to show how to select and highlight text. In a real application, you need to override `OnPaint`, because a TextBox doesn't allow to subscribe to the Paint event. – Jimi Apr 28 '19 at 11:45
  • Your question has nothing with T-SQL statement. You should explore System.Drawing namespace. –  Apr 28 '19 at 15:13

0 Answers0