473,761 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Active Control Name via Button.Click

I have a form on which various controls are added dynamically
depending on actions of the user. One of these actions allows the
user to click a delete button that will remove various other
controls. I was trying to accomplish this Click procedure by
capturing the active contold using activecontrol.n ame and then
removing it, but as soon as I click on the Delete button, the active
controls changes to the delete button, not the control that I want to
remove. Here is the code:

Private Sub btnDelCtl_Click (ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnDelCtl.Click
Dim ctlThisCtl As String = ActiveControl.N ame
MessageBox.Show (ctlThisCtl) 'to confirm deletion of the
correct control
End Sub

When I run this, the value of ctlThisCtl is "btnDelCtl" , which is not
what I want to delete. Anybody have a suggestion as to how I can
capture the control that was active immediately prior to clicking the
btnDelCtl button?

Thanks,
Randy

Jun 13 '07 #1
2 2111
On Jun 13, 4:49 pm, Randy <spam.eastl...@ gmail.comwrote:
I have a form on which various controls are added dynamically
depending on actions of the user. One of these actions allows the
user to click a delete button that will remove various other
controls. I was trying to accomplish this Click procedure by
capturing the active contold using activecontrol.n ame and then
removing it, but as soon as I click on the Delete button, the active
controls changes to the delete button, not the control that I want to
remove. Here is the code:

Private Sub btnDelCtl_Click (ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnDelCtl.Click
Dim ctlThisCtl As String = ActiveControl.N ame
MessageBox.Show (ctlThisCtl) 'to confirm deletion of the
correct control
End Sub

When I run this, the value of ctlThisCtl is "btnDelCtl" , which is not
what I want to delete. Anybody have a suggestion as to how I can
capture the control that was active immediately prior to clicking the
btnDelCtl button?

Thanks,
Randy
Perhaps a search in the archives would help:

http://groups.google.com/group/micro...rch+this+group

If you can't find something that works, let me know and I'll take a
better look.

Thanks,

Seth Rowe

Jun 13 '07 #2
Thanks, Seth. I had done numerous searches prior my post, but not on
"last" active control. It was easy once I found a post that suggested
using LostFocus.

Thanks for the suggestion!

Randy

Jun 14 '07 #3

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

Similar topics

2
6610
by: Technical Group | last post by:
Friends, Can anybody help me out by sending a piece of C# code showing how to add an active directory user to a particular user group? If the group does not exist, then create it. Thanks in advance -Hari
3
3602
by: felecha | last post by:
I'm something of a rookie at .Net. I know I can set TabIndex for controls in a GroupBox, and tab my way over to a button so it's "Active" and will be clicked by hitting the Enter key. But isn't there some way of setting it to the same state? I've built a very simple login for a tabpage in a tab control, so you enter a name and password and click the "login" button, which queries a database to validate you. someone told me it's...
9
20185
by: Charles Law | last post by:
I have a form on which user controls are placed at runtime. When a control is added to the form a handler is added for an event that a high-level object raises, which must be handled by the new control. When I close the form I am expecting that the control ceases to be. However, if my object raises the event after the form has been closed, I find that there is still a user control object that handles it. Clearly the user control has not...
0
2470
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls which are not behaving as I would expect. Specifically, if there is a command button external to the usercontrol which is activated by a shortcut key (eg Alt-B), the command button Click event handler code 'executes' even though the textbox set...
0
2742
by: jakobsgaard | last post by:
It is possible to Map a certificate to a Active Directory User Account from DotNet? Please provide an example. Best regards, Ejnar Jakobsgaard ------------------------------------------------- To map a certificate to a user account Open Active Directory Users and Computers.
4
2357
by: Sarita Sai Bhushan | last post by:
Hi, While I was developing a active desktop web page in ASP.Net using server controls I faced a problem with the autopostback property of server control. The sever control I used in my aspx page is a dropdown box. After deploying the page as a active desktop page whenever the selected index of the dropdown box changes an autopopstback takes place and a new browser window opens. But when the "autopost back" was replaced by the...
2
5983
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could use the System.DirectoryServices.ActiveDirectory namespace. I don't even know if this is the right way to go as I can't seem to find anything in that namespace that would help me query active directory for names. I can't use an LDAP query...
5
1327
by: =?Utf-8?B?U2NhbmJveQ==?= | last post by:
Guyz, Whatever happened to the 'Index' property for a control, that used to be present in VB 3.0 / 4.0 / 5.0 / 6.0 and which now seems to be missing from VBE 2005? I need to be able to make 4 command buttons behave in the same way, the 'Index' property indicating which command button I clicked on.
7
2251
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm new to Visual Studio 2005. I'm creating a windows application using Visual Basic. After I added a control to a form and added some codings to the control, I want to rename the control. However, I notice that after I rename the control, the codings inside it are still using the old name. Is there a setting that I can set to replace the old name with the new name automatically (for the entire form or all coding within the same...
0
9336
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
10111
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
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...
1
9902
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
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...
1
7327
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.