|
-
Jul 16th, 2003, 04:42 PM
#1
How to know when a control is selected at designtime
Ok this is kind of a wierd one, I have a control i made which inherits from ComboBox but creates a label to show over top of itself. Everything works fine EXCEPT that you can't click on the control at designtime to select it, you have to drag over it to select it. I think this is happening because you are actually selecting the label in front of it which doesn't actually belong to the form or have a site. I tried to catch any events in either the label or the combo itself at designtime to just have the label forward the selection to the combo, but I don't know the right event. I can't get the enter, gotfocus, click, mousedown, mousemove events to fire on either control at designtime. About the only event that I can get to work is ChangeUI but that doesn't do what I need or fire when i need. So now that I have bored you, anyone know how to catch an event or know when a control is selected at designtime?
Last edited by Edneeis; Jul 17th, 2003 at 10:16 AM.
-
Jul 16th, 2003, 05:57 PM
#2
you could try casting each control ( DirectCast ) then adding a handler to a universal Click sub , all control's click events ( or not all if you choose to ) will be handled and captured , here's a quick example i knocked up :
VB Code:
Private WithEvents ctl As Control '/// this will handle all click events ( or other events if chosen.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objctl(Me.Controls.Count) As Control
Dim x As Integer
For x = 0 To Me.Controls.Count - 1
objctl(x) = DirectCast(Me.Controls(x), Control)
AddHandler objctl(x).Click, AddressOf ctl_Click
Next
End Sub
Private Sub ctl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctl.Click
MessageBox.Show("clicked by :" & sender.Name)
End Sub
hope it helps
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jul 16th, 2003, 06:41 PM
#3
Except that this needs to be done from within a control (so there is no form) and at designtime. I tried catching the click event but it doesn't fire at designtime apparently. Thanks though.
-
Aug 4th, 2003, 07:45 AM
#4
Had the same problem...
Hi.
I had the same problem, when I had multiple controls in my usercontrol.
I used as listview with some other controls on top.
I found that, on my UserControl_Load event, I could check the DesignMode property of my usercontrol.
If that property was TRUE then all my other child-controls should have their Enabled = FALSE.
This means that my controls will have a boring grey backcolor, but
at least I'm able to select my control.
I hope you can use this.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Aug 4th, 2003, 11:07 AM
#5
Damn I thought that would work but I'm inheriting from a combobox so there is no UserControl_Load event.
I overrode the OnCreateControl method and that seems to work, now if there is only a way to make it show enabled still. Thanks.
Last edited by Edneeis; Aug 4th, 2003 at 02:28 PM.
-
Aug 4th, 2003, 02:28 PM
#6
Or does anyone know how to select a control at designtime? I tried the Select and Focus methods but they didn't do anything at designtime. I also tried calling the OnChangeUIClues method of the base type but that didn't work either.
-
Aug 4th, 2003, 03:14 PM
#7
How about a designer.
Hi Edneeis.
I'm not really sure, since I haven't tried this before, but what
about making a designer, just like the helpprovider, or the tooltip
controls. They have a class that implements IDesigner
(or something like that) that allows them to execute code at
designtime. There should be some way to access the focus event or something like that, and also
access the IDE like a macro to select the control.
I think there is a sample included in VS .Net. that uses a designer.
Something with a helplabel, if I'm not mistaken.
I don't know if this helps at all, but maybe it's worth looking into.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|