473,398 Members | 2,343 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,398 software developers and data experts.

VB.Net Problem Passing A Control To A Routine and retrieving the ctrls index

Hello Everyone,
I am having a problem when I pass a control to a routine and I want to
set properties for the control I cannot determine a way to retrieve the

passed in controls index so that I can set the properties for the
specific index. The routine blows up after the first time through. The
If idx = statement is screwed up. Any help would be appreciated.
Thanks, Jim
My code is as follows:

' I create the control here
' Add Recipe Step Number Panels 1 thru 12
pnlSteps1thru12.Controls.Add(recipeStepNumberLabel (panelIdx))
recipeStepNumberLabel(panelIdx).Left = 3
recipeStepNumberLabel(panelIdx).Top = 34 + (26 * (panelIdx - 1))
recipeStepNumberLabel(panelIdx).Width = 26
recipeStepNumberLabel(panelIdx).Height = 22
' I call the routine here!!
Call SetPanelFontAndColor(recipeStepNumberLabel)
' ROUTINE
Public Sub SetPanelFontAndColor(ByVal passedInControl() As Control)
Dim idx As Integer
Try
' Loop Through The Controls And Look For The Passed In
Index, Then Set The Control Properties
For idx = 1 To MAX_PLC_RECIPE_STEPS
If idx =
passedInControl(idx).Controls.IndexOf(passedInCont rol(idx)) Then
passedInControl(idx).Font = SystemDefaultFont '
Set The Font
passedInControl(idx).BringToFront()
' Bring Control To Front
passedInControl(idx).BackColor = Color.Wheat '
Set The BackColor
End If
Next idx
Exit Sub
Catch ex As Exception
If MsgExceptionFlag = 1 Then
MessageBox.Show("Center Form" + ex.Message) ' Display
During Testing
Else
SystemExceptionHandler(ex) ' Write
To File In Live Mode
End If
End Try
End Sub

May 26 '06 #1
2 1446
I am not understanding what you are trying to do here but it would seem from
the code you posted that you could just do...

Public Sub SetPanelFontAndColor(ByVal passedInControl() As Control, Index
ToChange as Integer)
passedInControl(IndexToChange).Font = SystemDefaultFont
'
Set The Font
passedInControl(IndexToChange).BringToFront()
' Bring Control To Front
passedInControl(IndexToChange).BackColor = Color.Wheat
'
Set The BackColor
Next idx

Note that you would need to add error checking for the index etc.

Or am I missing something?

Cheers,

Greg Young
MVP - C#
"squigster" <js*********@corefurnace.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Hello Everyone,
I am having a problem when I pass a control to a routine and I want to
set properties for the control I cannot determine a way to retrieve the

passed in controls index so that I can set the properties for the
specific index. The routine blows up after the first time through. The
If idx = statement is screwed up. Any help would be appreciated.
Thanks, Jim
My code is as follows:

' I create the control here
' Add Recipe Step Number Panels 1 thru 12
pnlSteps1thru12.Controls.Add(recipeStepNumberLabel (panelIdx))
recipeStepNumberLabel(panelIdx).Left = 3
recipeStepNumberLabel(panelIdx).Top = 34 + (26 * (panelIdx - 1))
recipeStepNumberLabel(panelIdx).Width = 26
recipeStepNumberLabel(panelIdx).Height = 22
' I call the routine here!!
Call SetPanelFontAndColor(recipeStepNumberLabel)
' ROUTINE
Public Sub SetPanelFontAndColor(ByVal passedInControl() As Control)
Dim idx As Integer
Try
' Loop Through The Controls And Look For The Passed In
Index, Then Set The Control Properties
For idx = 1 To MAX_PLC_RECIPE_STEPS
If idx =
passedInControl(idx).Controls.IndexOf(passedInCont rol(idx)) Then
passedInControl(idx).Font = SystemDefaultFont '
Set The Font
passedInControl(idx).BringToFront()
' Bring Control To Front
passedInControl(idx).BackColor = Color.Wheat '
Set The BackColor
End If
Next idx
Exit Sub
Catch ex As Exception
If MsgExceptionFlag = 1 Then
MessageBox.Show("Center Form" + ex.Message) ' Display
During Testing
Else
SystemExceptionHandler(ex) ' Write
To File In Live Mode
End If
End Try
End Sub

May 27 '06 #2
Thanks, I got it to work.

Jim

May 30 '06 #3

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

Similar topics

5
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
2
by: Tamarack | last post by:
I have a simple function which loops through all the controls on a form searching for a specific one: Public Function FindControl(ByVal ctrls As Control.ControlCollection, ByVal ctrlName As...
31
by: jcrouse | last post by:
Is there a quick and easy way to change the color of a label controls border from the default black to white? Thank you, John
0
by: Rene Aichinger | last post by:
Hi, I've created a server control (it inherits from WebControl) wich has a property of genertic collection type. The type of the generic collection is NavigationItem, a little class I've...
4
by: Peter Newman | last post by:
im trying to write a global function to set controls up throughout a project. ive managed to create a procedure to set the the basics on each form but want to expand it to be able to set properties...
1
by: krishnasamy | last post by:
Hi, I am retrieving the image from DLL through vc++ dll. Actually Image is retrieving in Callback function of main function. When I writing that image file inside of the Callback function then...
7
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
i have a master page and aseries of controls labeled fn1, fn2, fn3 , ... i want ot loop and use find control but i'm finding them. i'm using the following w/o luck ContentPlaceHolder cph =...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.