473,654 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help: Control loops & properties in VB .Net 2005

Hi all,

I'm using Visual Basic 2005. I would like to loop through the controls
and wite or get some properties based on the controls.

This is the following piece of code in Visual Basic 6.0

For Each ctl In frm.Controls
sCtlType = TypeName(ctl)
If sCtlType = "Label" Then
ctl.Caption = objLocalizer.Ge tResourceString (CInt(ctl.Tag))
ElseIf sCtlType = "CommandBut ton" Then
nVal = 0
nVal = Val(ctl.Tag)
ElseIf sCtlType = "Menu" Then
ctl.Caption =
objLocalizer.Ge tResourceString (CInt(ctl.Capti on))
ElseIf sCtlType = "TabStrip" Then
For Each obj In ctl.Tabs
obj.Caption =
objLocalizer.Ge tResourceString (CInt(obj.Tag))
obj.ToolTipText =
objLocalizer.Ge tResourceString (CInt(obj.ToolT ipText))
Next
ElseIf sCtlType = "Toolbar" Then
For Each obj In ctl.Buttons
obj.ToolTipText =
objLocalizer.Ge tResourceString (CInt(obj.ToolT ipText))
Next
ElseIf sCtlType = "ListView" Then
For Each obj In ctl.ColumnHeade rs
obj.Text =
objLocalizer.Ge tResourceString (CInt(obj.Tag))
Next
ElseIf sCtlType = "ctList" Then
ctl.HeaderFont = fnt
Count = ctl.ColumnCount
For Index = 1 To Count
ctl.ColumnText( Index) =
objLocalizer.Ge tResourceString (CInt(ctl.Colum nText(Index)))
Debug.Print ctl.ColumnText( Index)
Next Index
ElseIf sCtlType = "SSTab" Then
For Index = 0 To ctl.Tabs
ctl.TabCaption( Index) =
objLocalizer.Ge tResourceString (CInt(ctl.TabCa ption(Index)))
Next Index
ElseIf sCtlType = "ActiveBar" Then
Dim i As Integer
Dim J As Integer
Dim BandCount As Integer
Dim ToolsCount As Integer
BandCount = ctl.Bands.Count
For i = 0 To BandCount
ToolsCount = ctl.Bands(Index ).Tools.Count
For J = 0 To ToolsCount
nVal = 0
nVal = Val(ctl.Bands(i ).Tools(J).Tag)
If nVal > 0 Then
ctl.Bands(i).To ols(J).Caption =
objLocalizer.Ge tResourceString (nVal)
End If
nVal = 0
nVal = Val(ctl.Bands(i ).Tools(J).Tool TipText)
If nVal > 0 Then
ctl.Bands(i).To ols(J).ToolTipT ext =
objLocalizer.Ge tResourceString (nVal)
End If
Next J
Next i
Else
nVal = 0
nVal = Val(ctl.Tag)
If nVal > 0 Then ctl.Caption =
objLocalizer.Ge tResourceString (nVal)
nVal = 0
nVal = Val(ctl.ToolTip Text)
If nVal > 0 Then ctl.ToolTipText =
objLocalizer.Ge tResourceString (nVal)
End If
Next

When the same code is to be converted to Visual Basic 2005, i would
like to know how to access
1. ctl.HeaderFont in case of "ctList"
2. ctl.ColumnCount in case of "ctList"
3. ctl.ColumnText( Index) in case of "ctList"
4. ctl.Tabs in case of ctl is a SSTab
5. ctl.TabCaption( Index) in case of a Tab in SSTab

Any Help in this regard would be appreciated
Thanks in advance,
Sugan

May 22 '06 #1
1 1937
For Each theControl As Control In Me.Controls

If TypeOf theControl Is Label Then
MessageBox.Show ("Its a label")

ElseIf TypeOf theControl Is ListBox Then
MessageBox.Show ("Its a list box")

ElseIf TypeOf theControl Is ListView Then
MessageBox.Show ("Its a listview")

End If

Next

"Sugan" <vs****@gmail.c om> wrote in message
news:11******** **************@ i39g2000cwa.goo glegroups.com.. .
Hi all,

I'm using Visual Basic 2005. I would like to loop through the controls
and wite or get some properties based on the controls.

This is the following piece of code in Visual Basic 6.0

For Each ctl In frm.Controls
sCtlType = TypeName(ctl)
If sCtlType = "Label" Then
ctl.Caption = objLocalizer.Ge tResourceString (CInt(ctl.Tag))
ElseIf sCtlType = "CommandBut ton" Then
nVal = 0
nVal = Val(ctl.Tag)
ElseIf sCtlType = "Menu" Then
ctl.Caption =
objLocalizer.Ge tResourceString (CInt(ctl.Capti on))
ElseIf sCtlType = "TabStrip" Then
For Each obj In ctl.Tabs
obj.Caption =
objLocalizer.Ge tResourceString (CInt(obj.Tag))
obj.ToolTipText =
objLocalizer.Ge tResourceString (CInt(obj.ToolT ipText))
Next
ElseIf sCtlType = "Toolbar" Then
For Each obj In ctl.Buttons
obj.ToolTipText =
objLocalizer.Ge tResourceString (CInt(obj.ToolT ipText))
Next
ElseIf sCtlType = "ListView" Then
For Each obj In ctl.ColumnHeade rs
obj.Text =
objLocalizer.Ge tResourceString (CInt(obj.Tag))
Next
ElseIf sCtlType = "ctList" Then
ctl.HeaderFont = fnt
Count = ctl.ColumnCount
For Index = 1 To Count
ctl.ColumnText( Index) =
objLocalizer.Ge tResourceString (CInt(ctl.Colum nText(Index)))
Debug.Print ctl.ColumnText( Index)
Next Index
ElseIf sCtlType = "SSTab" Then
For Index = 0 To ctl.Tabs
ctl.TabCaption( Index) =
objLocalizer.Ge tResourceString (CInt(ctl.TabCa ption(Index)))
Next Index
ElseIf sCtlType = "ActiveBar" Then
Dim i As Integer
Dim J As Integer
Dim BandCount As Integer
Dim ToolsCount As Integer
BandCount = ctl.Bands.Count
For i = 0 To BandCount
ToolsCount = ctl.Bands(Index ).Tools.Count
For J = 0 To ToolsCount
nVal = 0
nVal = Val(ctl.Bands(i ).Tools(J).Tag)
If nVal > 0 Then
ctl.Bands(i).To ols(J).Caption =
objLocalizer.Ge tResourceString (nVal)
End If
nVal = 0
nVal = Val(ctl.Bands(i ).Tools(J).Tool TipText)
If nVal > 0 Then
ctl.Bands(i).To ols(J).ToolTipT ext =
objLocalizer.Ge tResourceString (nVal)
End If
Next J
Next i
Else
nVal = 0
nVal = Val(ctl.Tag)
If nVal > 0 Then ctl.Caption =
objLocalizer.Ge tResourceString (nVal)
nVal = 0
nVal = Val(ctl.ToolTip Text)
If nVal > 0 Then ctl.ToolTipText =
objLocalizer.Ge tResourceString (nVal)
End If
Next

When the same code is to be converted to Visual Basic 2005, i would
like to know how to access
1. ctl.HeaderFont in case of "ctList"
2. ctl.ColumnCount in case of "ctList"
3. ctl.ColumnText( Index) in case of "ctList"
4. ctl.Tabs in case of ctl is a SSTab
5. ctl.TabCaption( Index) in case of a Tab in SSTab

Any Help in this regard would be appreciated
Thanks in advance,
Sugan

May 22 '06 #2

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

Similar topics

15
1632
by: chahnaz.ourzikene | last post by:
Hi all, This is the first i post in this newsgroup, i hope my english is not too bad... Let's get straight to the point ! I have a little probleme using threads in my little training example : I wish to create two threads in my application, one thread (the subject) will increment a variable, and another thread (the controller) will print a message saying "i am waiting..." or someting like that, until the counter of the first thread...
53
4653
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code, and .Net2005 code. I'm developing in vb.net 2005. This test sub just reads an input text file, writing out records to another text file, eliminating records that have a '99' in them (it is similar to a CSV file). Some of my concerns are:
15
2569
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to determine who needs to receive the text message then send the message to the address. Only problem is, the employee may receive up to 4 of the same messages because each thread gets the recors then sends the message. I need somehow to prevent...
9
1978
by: Paulers | last post by:
Hello, I have a log file that contains many multi-line messages. What is the best approach to take for extracting data out of each message and populating object properties to be stored in an ArrayList? I have tried looping through the logfile using regex, if statements and flags to find the start and end of each message but I do not see a good time in this process to create a new instance of my Message object. While messing around with...
0
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7306
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.