Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding and populating controls on a tab control

Status
Not open for further replies.

JungleMonkey

Programmer
Aug 18, 2002
19
0
0
US
Hi,

I am new to C#. I have a form that has three buttons and a tab control which has three different pages. On each of the three pages, I have a listbox. I would like to populate the listbox on the first page with an array of numbers, however I am having difficulty. In the onclick event I tried writing the following line:

tabControl.Page(0).lstBox.DataSource = anNumbers;

Please provide an example for me on how to populate my listbox contained in a tabcontrol residing on the first page.

Thank you
 
can you not just load it with a loop?

Code:
int counter = 0, NumberOfArrayItems = 10;
int[] arr = new int [] {0,1,2,5,7,8,11};

foreach (int i in arr) 
{
   //Assuming your list box is named "lstBox"
   this.lstBox.Items.Add(Arr[counter].ToString());
}
[\code]




- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
can you not just load it with a loop?

Code:
int counter = 0, NumberOfArrayItems = 10;
int[] arr = new int [] {0,1,2,5,7,8,11};

foreach (int i in arr) 
{
   //Assuming your list box is named "lstBox"
   this.lstBox.Items.Add(Arr[counter].ToString());
}

Good Luck,
Kevin



- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
I forgot to add that there is a list box on the form itself. That listbox is being populated with random numbers. The list box contained in the tabcontrol is contain the sorted numbers. From my understanding in the Form.btnOne.On_Click event, I can simply use this command
this.lstBox.Items.Add(Arr[counter].ToString());
as opposed to
this.tabControl.Page(1).lstBox.Items.Add(Arr[counter].ToString());

Thanks in advance
 
That is correct, you do not have to reference the tab itself, just using the this.listboxname, you should have access to it.

Good luck,
Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top