473,466 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

controls cut/paste

553 Contributor
If you have many controls on a Tab Control and all of them have code written for them.

Now if you want to move these controls from Tab Control to some other part of the form then the code for them will be dis-associated from them.

If you want to associate the code again with the control, it has be done manually by clicking on control's event and it will be done.

but this way, each control has to be done one by one... is there any one when you cut/paste controls from TabControl to some other place, the code remain associated with them ?
Aug 4 '07 #1
16 3676
missinglinq
3,532 Recognized Expert Specialist
Sorry, no! You can select multiple controls and do a some of things to them, such a change the font/color/attributes, but you can't multi-select and change properties that involve going into the code editor, which is what yu need to do to re-associate them with their code.

Linq
Aug 4 '07 #2
ADezii
8,834 Recognized Expert Expert
If you have many controls on a Tab Control and all of them have code written for them.

Now if you want to move these controls from Tab Control to some other part of the form then the code for them will be dis-associated from them.

If you want to associate the code again with the control, it has be done manually by clicking on control's event and it will be done.

but this way, each control has to be done one by one... is there any one when you cut/paste controls from TabControl to some other place, the code remain associated with them ?
Try modifying the OnClick() Event of all Controls on the Form as in:
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As Control
  2.  
  3. For Each ctl In Me.Controls
  4.   If ctl.OnClick = "" Then
  5.     ctl.OnClick = "[Event Procedure]"
  6.   End If
  7. Next
Aug 4 '07 #3
missinglinq
3,532 Recognized Expert Specialist
Excellent hack, ADezii! I'll put it in my references and give you credit if I post it anywhere!

Linq ;0)>
Aug 4 '07 #4
ADezii
8,834 Recognized Expert Expert
Excellent hack, ADezii! I'll put it in my references and give you credit if I post it anywhere!

Linq ;0)>
Still bumping into each other, old pal. Of course the previous code is only good for the Click() Event, and it doesn't Filter for Control Type or anything else. It was just meant to possibly point the OP in the right direction. See you around town!
Aug 4 '07 #5
NeoPa
32,556 Recognized Expert Moderator MVP
If you have many controls on a Tab Control and all of them have code written for them.

Now if you want to move these controls from Tab Control to some other part of the form then the code for them will be dis-associated from them.

If you want to associate the code again with the control, it has be done manually by clicking on control's event and it will be done.

but this way, each control has to be done one by one... is there any one when you cut/paste controls from TabControl to some other place, the code remain associated with them ?
Question asked well.
I may not be very helpful as I'm not sure of this, but I would try selecting them all and dragging them to where you want them on the main part of the form. That may well leave the links associated which wouldn't happen with a cut or copy.
Good luck.
Aug 4 '07 #6
ADezii
8,834 Recognized Expert Expert
Question asked well.
I may not be very helpful as I'm not sure of this, but I would try selecting them all and dragging them to where you want them on the main part of the form. That may well leave the links associated which wouldn't happen with a cut or copy.
Good luck.
Hello NeoPa. I don't think that dragging individual Controls from Pages within a Tab Control to a Main Form will work. It's the same concept as attempting to drag Option Buttons out of their Group Container - they are confined to the Container Area and cannot escape it. Just some useless information you may want to know.
Aug 5 '07 #7
missinglinq
3,532 Recognized Expert Specialist
Understood, ADezii! A lot of people have learned how to loop thru controls, but I see mistakes all the time where they haven't specified what kind of controls to loop thru! Still an excellent template for changing these types of properties in this situation. BTW, vis a vis "bumping into each other;" we're both in the same time zone! I'm down the road in Richmond (Virginia, that is, not England!)

And he's right, NeoPa. If you select the controls and try to drag them to the main body of the form, all you do is increase the size of the tabbed pages, because they are, in fact, contained by the tab control.

Linq ;0)>
Aug 5 '07 #8
NeoPa
32,556 Recognized Expert Moderator MVP
Thanks for coming back with those boys. I don't intend to mislead and I'd rather know if I get things wrong :)
QuestionIt, let us know if you manage to get the other (ADezii) suggested method to work for you (and how much that helped).
Aug 5 '07 #9
questionit
553 Contributor
Thanks for your answers

But being a beginner in VB, i am not very sure how to use the suggested code.

The code is just assigning same event procedure to each control on the form !?

and you meant to say that code would need to be added in every event procedure seperately?


Thanks for coming back with those boys. I don't intend to mislead and I'd rather know if I get things wrong :)
QuestionIt, let us know if you manage to get the other (ADezii) suggested method to work for you (and how much that helped).
Aug 5 '07 #10
missinglinq
3,532 Recognized Expert Specialist
After you've moved your command buttons from the tabbed page to where ever you want them:
Place a button on your form
When the wizard pops up hit Cancel
Goto Properties - Events and double-click to the right of the OnClick box
Click on the ellipsis (...)
In the Command_Click sub that comes up for the button you just made, paste in ADezii's code.
Exit the code window
Run your form
Click on the button you just made.
If you've followed all of these instructions, all of the buttons you've moved should now be functioning.
Delete the button you just made from your form.
Aug 5 '07 #11
questionit
553 Contributor
That thing is good !!

but in the code line:
Expand|Select|Wrap|Line Numbers
  1.     ctl.OnClick = "[Event Procedure]"
  2.  
we are assigning "[Event Procedure]" to all the controls. Whats the value of "[Event Procedure]" ?

it looks like that sameevent procedure is being assigned to all the controls, but actually not... how does that work then?



After you've moved your command buttons from the tabbed page to where ever you want them:
Place a button on your form
When the wizard pops up hit Cancel
Goto Properties - Events and double-click to the right of the OnClick box
Click on the ellipsis (...)
In the Command_Click sub that comes up for the button you just made, paste in ADezii's code.
Exit the code window
Run your form
Click on the button you just made.
If you've followed all of these instructions, all of the buttons you've moved should now be functioning.
Delete the button you just made from your form.
Aug 6 '07 #12
NeoPa
32,556 Recognized Expert Moderator MVP
What you say makes sense - but in this case is actually wrong. The string "Event Procedure" is actually the exact value for that property. This is what it contains when the event procedure is linked to that event. Otherwise it could be empty, or have a macro as its value.
Does this make sense?
Aug 6 '07 #13
questionit
553 Contributor
NeoPa

that makes sence..

so the string " Event Procedure" is like a buffer.. whenevr we associate any procedure to any control ... the link to that code is stored in "Event Procedure" .. is this what it is ?

but even it is working like this... it is strange that assigning just "Event Procedure" to controls actually associated the right code with every control !



What you say makes sense - but in this case is actually wrong. The string "Event Procedure" is actually the exact value for that property. This is what it contains when the event procedure is linked to that event. Otherwise it could be empty, or have a macro as its value.
Does this make sense?
Aug 6 '07 #14
NeoPa
32,556 Recognized Expert Moderator MVP
Not quite right there.
The string "Event Procedure" is stored in the property of the object with the same name as the event. So, a CommandButton would have a Click event (to handle what happens when it is clicked), so it would also have a Click property (Look in design view and see in the properties various properties with the names of events). When there is VBA code for a particular event (in this case Click), that similarly named property contains the string "Event Procedure".
Does that make more sense. It's an ADezii Clever. He's a clever chap and comes up with various work-arounds that most of us have never thought of :)
Aug 6 '07 #15
ADezii
8,834 Recognized Expert Expert
Not quite right there.
The string "Event Procedure" is stored in the property of the object with the same name as the event. So, a CommandButton would have a Click event (to handle what happens when it is clicked), so it would also have a Click property (Look in design view and see in the properties various properties with the names of events). When there is VBA code for a particular event (in this case Click), that similarly named property contains the string "Event Procedure".
Does that make more sense. It's an ADezii Clever. He's a clever chap and comes up with various work-arounds that most of us have never thought of :)
Hello NeoPa:
Not being critical or nit-picky but clarifying something. For Events having corresponding Event Properties, the Event Properties are prefaced by On as in:
Expand|Select|Wrap|Line Numbers
  1. Event            Associated Property
  2. Click            On Click
  3. MouseDown        On MouseDown
  4. KeyPress         On KeyPress
  5. ...                       ...
  6.  
BTW, like the clever chap comment - only wish it were true! See you around, Old Chap!
Aug 6 '07 #16
NeoPa
32,556 Recognized Expert Moderator MVP
Hello NeoPa:
Not being critical or nit-picky but clarifying something. For Events having corresponding Event Properties, the Event Properties are prefaced by On as in:
Expand|Select|Wrap|Line Numbers
  1. Event            Associated Property
  2. Click            On Click
  3. MouseDown        On MouseDown
  4. KeyPress         On KeyPress
  5. ...                       ...
  6.  
BTW, like the clever chap comment - only wish it were true! See you around, Old Chap!
Hi ADezii.

I'm going to be critical and nit-picky here (:D) and say that while that is true for a number of events it is not true for all (Before/After Update et al). It was a point worth making but I would say that, if the property is not named exactly the same then it should at least be recognisably similar.

Now don't argue with me. You ARE a clever chap :)
Aug 7 '07 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mike D | last post by:
I have been able to in the past, copy and paste Windows Form controls. I no longer get the copy or paste active on my right click menu. I am working on tab pages if that matters. How can I get...
5
by: Damian H | last post by:
I have an form that I want to reorganise by putting some of the existing controls onto a new tab control (using Access 2K) When I drag a control onto a specific page of the new tab control,...
3
by: winshent | last post by:
I have copied approx 20 controls from a form to a tab control for reasons of space. i now cannot run code triggered by the events of these controls. for example, the following will not trigger...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
0
by: timbobd | last post by:
I have a Windows Form project with a TabControl-based window. After adding a second tab, I can no longer copy/paste/delete controls, either on the original tab or after they have been added to any...
15
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
8
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
0
by: Beemer Biker | last post by:
I finally discoved why controls are not getting pasted into my multiview "view". The position attribute (absolute, normal, offset) is being set to absolute. I assume this is a "feature" of the...
3
by: teo | last post by:
When I Cut and Paste controls (ie: from a 'Form' to a 'Tab control' that I just put on the Form) the pasted controls regularly arrive with their properties, but the code behind them remains...
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
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,...
1
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...
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.