0

I have to display multiline messages in any control in C#, which provides me the following 3 possibilities:

  1. Scrolling
  2. Text cannot be modified
  3. Click event

I tried the following options and faced problems:

Labels: Label is perfect for me but I couldn't find the scrolling property

TextBox: I tried to use textbox, which provided me scrolling but then the user can change the text. And if I set TextBox.Enable = False, then the scrollbar cannot be moved an shown the image below:

enter image description here

skm
  • 5,015
  • 8
  • 43
  • 104
  • 2
    TextBoxes also have a `ReadOnly` property – JayV May 30 '18 at 09:13
  • @JayV: I set the `ReadOnly = True` but still the user can click it and then the Cursor shows up (I don't want to show Cursor). – skm May 30 '18 at 09:16
  • Removing the cursor means no keyboard based navigation - mouse only. Is that what you really want to do given that lots of people prefer or like to navigate using the keyboard? No highlighting or copying of the text from the text box – JayV May 30 '18 at 09:21
  • @JayV: It's just showing messages on a TouchScreen. I want to show this TextBox as a label (with Scrolling feature). As I said in my post, Label is perfect for me if I could enable Scrolling in it. – skm May 30 '18 at 09:25
  • Or, take a look at this SO question/answer: https://stackoverflow.com/questions/3730968/how-to-disable-cursor-in-textbox – JayV May 30 '18 at 09:26
  • I would go for the [ListView](https://msdn.microsoft.com/en-us/library/windows/desktop/bb774735(v=vs.85).aspx) control. It's more flexible that the ListBox, supports graphics, different view etc. – Jimi May 30 '18 at 16:21

2 Answers2

0

On Textbox property you can add new lines on Text property by clicking the dropdown arrow(see image below) and pressing enter on your keyboard.

enter image description here

After adding new lines and setting Textbox.Readonly = false and setting prefered scroll will solved your problem. Then just adjust textbox to show scroll bar only.

P. Pat
  • 488
  • 4
  • 13
0

Use a List box if your showing a message. It gives you scrolling, you cannot edit the message, and it's more professional looking. Most of the applications you install and you see the Terms and Agreements. It's usually in a List box.

Halonic
  • 405
  • 2
  • 12