473,396 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

accessing control collection in tabcontrol

Hi,
I have an tab control in one of the forms and it has two tab strips. Now I
have written an general function that accepts form name as parameter and
iterates through all the controls in the form and re-initialises that.
Now in this context, i have around 15 controls on one of the tab strips page
1 and 5 controls in tab strip 2.
now when i iterate through the controls, i am getting the control collection
as 3 as there are two more button on the page.
Can anyone please help me how do i access all the controls on the tabstrip.
Here is the code that i am using for the same.

Public Sub ClearFormElements(ByVal sForm As Form)
Dim vControl As System.Windows.Forms.Control

For Each vControl In sForm.Controls
If TypeOf vControl Is System.Windows.Forms.TextBox Then
vControl.Text = ""
End If

If TypeOf vControl Is System.Windows.Forms.ComboBox Then
vControl.Text = ""
End If

If TypeOf vControl Is System.Windows.Forms.DateTimePicker Then
vControl.Text = Convert.ToDateTime(Now()).ToString
End If

If TypeOf vControl Is
System.Windows.Forms.TabControl.ControlCollection Then

End If
Next
End Sub

Regards
Sudhakara.T.P.
Nov 21 '05 #1
7 1905
Sudhakara,

I did not completly try this routine, however I think that it fullfils your
needs.

\\\
doset(MyTabControl)
///
\\\
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
ctr.Text = Nothing
doSet(ctr)
Next
///
This should set every control in your tabcontrol to its initial state.
(Assuming that you did not set something using the designer)

Every control inherits from control from which text is a property.

I hope this helps,

Cor

End Sub
Nov 21 '05 #2
Hi Cor Lighert,

Bravo !!!! That worked like a Bullseye. Thanks for the information.

Thanks & Regards
Sudhakara.T.P.

"Cor Ligthert [MVP]" wrote:
Sudhakara,

I did not completly try this routine, however I think that it fullfils your
needs.

\\\
doset(MyTabControl)
///
\\\
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
ctr.Text = Nothing
doSet(ctr)
Next
///
This should set every control in your tabcontrol to its initial state.
(Assuming that you did not set something using the designer)

Every control inherits from control from which text is a property.

I hope this helps,

Cor

End Sub

Nov 21 '05 #3
Hi,
In continuation with our discussion, with this generic function, as we clear
the text box like vControl.text="", how can we uncheck a check box. Because
when I say this vControl.checked=false, it gives an error. Any idea about
this. If possible, can you let me know where I can find these type of
information.

Regards
Sudhakara.T.P.
"Cor Ligthert [MVP]" wrote:
Sudhakara,

I did not completly try this routine, however I think that it fullfils your
needs.

\\\
doset(MyTabControl)
///
\\\
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Controls
ctr.Text = Nothing
doSet(ctr)
Next
///
This should set every control in your tabcontrol to its initial state.
(Assuming that you did not set something using the designer)

Every control inherits from control from which text is a property.

I hope this helps,

Cor

End Sub

Nov 21 '05 #4
Sukhakara,

In this case does the text set the text from that box. The checkstate is

if typeof ctr Is checkbox then
ctr.CheckState = CheckState.Unchecked
End if

I hope this helps,

Cor

Nov 21 '05 #5
Hi Cor,
As I have declared ctr as system.windows.forms.control, the moment I type
ctr.checkState, it gives an compile error saying that checkstate is not a
member of system.windows.forms.control. Any updates on this.

I had tried this earlier, but had the same problem.

Regards
Sudhakara.T.P.

"Cor Ligthert [MVP]" wrote:
Sukhakara,

In this case does the text set the text from that box. The checkstate is

if typeof ctr Is checkbox then
ctr.CheckState = CheckState.Unchecked
End if

I hope this helps,

Cor

Nov 21 '05 #6
Sukhakara,

Sometimes I type things direct in the message and see than that I do crazy
things, I do it now again however assume it is now right.

Text is a property from Control, however checkstate not that is added with
the created checkbox which inherits from control. And therefore should be
told that it is a checkbox

\\\
if typeof ctr Is checkbox then
directcast(ctr,checkbox).CheckState = CheckState.Unchecked
End if
///

I hope that this goes better.

Cor
Nov 21 '05 #7
Hi Cor,

Thanks. That worked the way it should have.

Thanks once again and that is the reason why I always rely on this site.

Thanks
Sudhakara.T.P.

"Cor Ligthert [MVP]" wrote:
Sukhakara,

Sometimes I type things direct in the message and see than that I do crazy
things, I do it now again however assume it is now right.

Text is a property from Control, however checkstate not that is added with
the created checkbox which inherits from control. And therefore should be
told that it is a checkbox

\\\
if typeof ctr Is checkbox then
directcast(ctr,checkbox).CheckState = CheckState.Unchecked
End if
///

I hope that this goes better.

Cor

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mark Denardo | last post by:
Hi I have a TabControl object that I need to insert new TabPages into. To append them to the end of the Controls Collection I can do: tc.controls.add(tp) (tc - tabcontrol object) (tp -...
3
by: Jack Russell | last post by:
I want to add navigation buttons to a tabcontrol (somewhat like excel) How do I get the "tabs" to offset to the right so that I can draw the buttons on the left? TIA -- Remove norubbish to...
0
by: Juan Pedro Gonzalez | last post by:
Hi, I'm running mad with this issue, hope I can explain it correctlly. I've been developping a user control wich is very similar to the TabControl... Basically my control has two panels that...
2
by: Paul Bromley | last post by:
I am using a tabcontrol alled for example:- TabPage There are several tabs on this tabcontrol with command buttons on them. I want to loop through them but the following code does not work:- ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.