Jeff Roe
Jeff Roe

Reputation: 3214

How to implement a "fully viewed" multi-line TextBox?

I am trying to create a form with a multi-line TextBox with the following requirements:

So I'm trying to make a "fully viewed" multi-line TextBox.

This picture should make it clear what I'm trying to do:

enter image description here

If they check the checkbox before they've scrolled through the whole thing, I'll know not to believe them.

I think I need to know:

Any ideas about how to achieve this?

Upvotes: 1

Views: 159

Answers (1)

Olivier Jacot-Descombes
Olivier Jacot-Descombes

Reputation: 112712

The TextBox has no scrolling event but the RichTextBox has. Also it has a method that allows you to get the index of the character closest to a point position.

private readonly Point _lowerRightCorner;

public frmDetectTextBoxScroll()
{
    InitializeComponent();
    _lowerRightCorner = new Point(richTextBox1.ClientRectangle.Right,
                                  richTextBox1.ClientRectangle.Bottom);
}

private void richTextBox1_VScroll(object sender, EventArgs e)
{
    int index = richTextBox1.GetCharIndexFromPosition(_lowerRightCorner);
    if (index == richTextBox1.TextLength - 1) {
        // Enable your checkbox here
    }
}

Upvotes: 2

Related Questions