473,394 Members | 1,737 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,394 software developers and data experts.

Reference to added user control

adh
Hello,
How do I get the referebce to the last added UserControl:
Me.Controls.Add(myUserControl)
When I add one after another?

Return CType(Me.Controls(.Controls.Count - 1), _ myUserControl)
doesn't go.

Thanks, adh

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
3 948
Just check it back ways up in the place your added it, if it is direct on a
form by instance roughly typed in this message

\\\
for i as integer = me.controls.count - 1 to 0
if TypeOf me.controls(i) Is myUserControl then
return me.controls(i)
end if
next
///

I hope this helps,

Cor

"adh" <ad*@devx.com> schreef in bericht
news:eX*************@TK2MSFTNGP15.phx.gbl...
Hello,
How do I get the referebce to the last added UserControl:
Me.Controls.Add(myUserControl)
When I add one after another?

Return CType(Me.Controls(.Controls.Count - 1), _ myUserControl)
doesn't go.

Thanks, adh

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #2
adh
Thanks Cor,
I Thought about it, but I still need a Ctype when trying to access or
copy emmbeded controls.

Two Questions are left:
1) Why doesn't Me.Controls.Add(uctl) return a reference (like all "Add"s
do)?
2) Why are we going backwards, things of 1 codding line are becomming a
whole routine?

Thanks, adh

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #3
> Thanks Cor,
I Thought about it, but I still need a Ctype when trying to access or
copy emmbeded controls.
You need a CType or a directcast if you need a property that you have
yourself added.

dim mytext as string = ctr(x).text
dim mySpecial as string = directcast(ctr(x),mycontrol).myproperty

Two Questions are left:
1) Why doesn't Me.Controls.Add(uctl) return a reference (like all "Add"s
do)?
I don't know what you mean by this.
2) Why are we going backwards, things of 1 codding line are becomming a
whole routine?

How do you know that a usercontrol is the last. If you are sure of that,
than it is just

me.controls(me.controls.count-1)

I hope this helps,

Cor
Nov 21 '05 #4

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

Similar topics

2
by: Steve Harclerode | last post by:
Hi all, I've been doing web service development for a year, with a break for the last few months. What I remember is how easy it is to reference a web service using Visual Studio. So today, I...
1
by: Martine | last post by:
Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the Page_Load), the object is instantiated, I have...
7
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb --...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
16
by: Paul S. Natanson | last post by:
What is a Null Reference error and how do I fix it? My newly installed VB.Net2003 gives me a "Microsoft Development Environment" error message box EVERY time I try to run/start ANY project -...
0
by: tony | last post by:
Hello! I have a Window control library developed in C++.Net called test but it doesn't behave as expected. Assume also that this Window control library test is dependent of some other user...
35
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an...
1
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my...
4
by: Randy | last post by:
My situation is that I have a form on which a number of textboxes and comboboxes are added dynamically based on interaction with the user. As these controls are added, they are given names based on...
2
by: sravan_reddy001 | last post by:
I created a tabcontrol toolin my application.(actually i am creating a tabbed browser) when the user clicks on the newtab button(provided by me) the new tab is added and the webbrowser control...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.