Icemanind
Icemanind

Reputation: 48686

Scrolling all but the top line in a multiline textbox

I have a multiline textbox in a WinForms application. What I'd like to do is always have the top line visible, even if it scrolls. Is there some trick someone knows to do this?

Upvotes: 0

Views: 288

Answers (2)

Rob P.
Rob P.

Reputation: 15071

The simple answer; depending on the appearance you are going for is to use existing windows controls to get the effect you want.

You can use a label control above a textbox and allow the textbox to scroll. You can use two textbox - the top with it's .multiline property set to false, while the bottom allows scrolling.

You could encapsulate this all into a user control for reuseability.

Beyond that, I think you'd be looking at a fairly large project to implement your control (or at least overriding the onPaint() event of the textbox) with the desired behavior.

Upvotes: 0

Trisped
Trisped

Reputation: 6003

Fake it. Use two TextBox objects, draw your own borders. You will need to deal with wrapping to the next line yourself.

You could also copy the first X characters to a label so when the TextBox scrolls they can see the first line in the label.

Unless it is an essential feature I would try to cut it.

Upvotes: 2

Related Questions