can anyone provide me an sample to get the last 3 controls in a panel please
i want to get from the last 3 controls the 'Text' that's inside the control
Thanks
Re: How to get the 3 last controls in a panel?
Posted: Wed Jul 26, 2017 6:06 pm
by CodenStuff
Iterating through a panels controls starts from the last one anyway
Example:
For i = 0 To 2
Select Case i
Case 0
For Each ctl As Control In ITransactionControl1.IPanel1.Controls
If TypeOf ctl Is ITransaction Then
Label31.Text = CType(ctl, ITransaction).Description
' Exit Sub
End If
Next
Case 1
' MsgBox(CType(ITransactionControl1.IPanel1.Controls(2), ITransaction).Description)
For Each ctl As Control In ITransactionControl1.IPanel1.Controls
If TypeOf ctl Is ITransaction Then
Label4.Text = CType(ctl, ITransaction).Description
' Exit Sub
End If
Next
Case 2
For Each ctl As Control In ITransactionControl1.IPanel1.Controls
If TypeOf ctl Is ITransaction Then
Label27.Text = CType(ctl, ITransaction).Description
' Exit Sub
End If
Next
End Select
Next
For I As Integer = 0 To ITransactionControl1.IPanel1.Controls.Count - 1
If TypeOf ITransactionControl1.IPanel1.Controls.Item(I) Is ITransaction Then
Select Case I
Case 1
Label31.Text = CType(ITransactionControl1.IPanel1.Controls.Item(I), ITransaction).Description
Case 2
Label4.Text = CType(ITransactionControl1.IPanel1.Controls.Item(I), ITransaction).Description
Case 3
Label27.Text = CType(ITransactionControl1.IPanel1.Controls.Item(I), ITransaction).Description
End Select
End If
Next
not sure yet, but testing
EDIT:
pfff don't get it working, still don't get the last 3 controls
seems the case functions don't work the way we count it
hope someone can give me a better solution
Thanks
Re: How to get the 3 last controls in a panel?
Posted: Sat Jul 29, 2017 10:06 am
by CodenStuff
Which controls is it getting?
Instead of CASE 1/2/3 have you tried CASE 0/1/2 ...remember it starts from 0
For I As Integer = 0 To ITransactionControl1.IPanel1.Controls.Count - 1
If TypeOf ITransactionControl1.IPanel1.Controls.Item(I) Is ITransaction Then
Select Case I
Case 0
Label31.Text = CType(ITransactionControl1.IPanel1.Controls.Item(I), ITransaction).Description
Case 1
Label4.Text = CType(ITransactionControl1.IPanel1.Controls.Item(I), ITransaction).Description
Case 2
Label27.Text = CType(ITransactionControl1.IPanel1.Controls.Item(I), ITransaction).Description
End Select
End If
Next
what are we doing wrong :( why do i get only 1 record in the left column?
Edit:
I also needed the last 3 records that has been added as last
963,lol,pol
not from the last 3 bottoms