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

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.name 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.EventArgs) Handles btnDelCtl.Click
Dim ctlThisCtl As String = ActiveControl.Name
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 2081
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.name 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.EventArgs) Handles btnDelCtl.Click
Dim ctlThisCtl As String = ActiveControl.Name
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
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...
3
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...
9
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...
0
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...
0
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...
4
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...
2
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...
5
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...
7
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. ...
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
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
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,...
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...
0
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...

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.