ScrollControlIntoView c#

P

piotr.smolenski

Hi

I have a problem with displaying textBoxes in a tabPage on a form. I
have 3 tabs, the 2nd tab 'tab2' the user enter the number of textBoxes
required to be displayed in 'tab3', when they leave 'tab2' and click
on 'tab3' the code place the textboxes at the bottom of 'tab3' adding
additional ones above them. This requires the 'AutoScroll' to start at
the bottom of 'tab3'. I'm using 'ScrollControlIntoView' to display the
textBox. When you first click on 'tab3' from 'tab2', the scroll bars
do not go to the bottom of the 'tab3' where the text boxes are added.
However this works the 2nd time you click 'tab3' and the scroll bars
start at the bottom of 'tab3' where the textboxes are placed.

Can anyone help?

I have supplied the basic code I'm using.

Thanks in advance

Cyclone

////////////////////////////////////////////////////////////////////////////////
using System;
using System.Globalization;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Diagnostics;

namespace Example
{
public partial class MainForm : Form
{
private TextBox txtBx_Val00 = new TextBox();
int N_val2 = 0;

private void tab2_Leave(object sender, EventArgs e)
{
//Variable is populated by a text box on tab2
N_val2 = int.Parse(txtBx_N2a.Text);//No. of textBoxes to
be displayed

FloorData_Method();
}

private void FloorData_Method()//displays floor rows
{
//Row 00
this.txtBx_Val00.Text = "0";
this.txtBx_Val00.Size = new Size(56, 20);
this.txtBx_Val00.Location = new Point(27, 3597)//places
textBox at the very bottom of the tab

//Adds Row00
this.tab3.Controls.Add(txtBx_Val00);
this.tab3.ScrollControlIntoView(this.txtBx_Val00);

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
}
}
}
//////////////////////////////////////////////////////////////////////////
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top