aewarnick Posted February 20, 2003 Posted February 20, 2003 If so, where is it? I can't find it. Quote C#
*Gurus* divil Posted February 20, 2003 *Gurus* Posted February 20, 2003 Can you elaborate? It's difficult to know what you mean. All .NET controls have a DoubleClick event, regardless of what language you are using. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted February 20, 2003 Author Posted February 20, 2003 In the designer, when you click on the lightning bolt for Events there is usually a Click event but I never see a DoubleClick event. I want to put DoubleClick events in my code (my program). Quote C#
*Gurus* divil Posted February 20, 2003 *Gurus* Posted February 20, 2003 Which control in particular? I found it for a textbox, for example, under the Action heading in the property grid. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted February 21, 2003 Author Posted February 21, 2003 This page: It is not there on mine. Quote C#
*Experts* DiverDan Posted February 21, 2003 *Experts* Posted February 21, 2003 Try this: Private Sub Your_Control_Name_Here_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Your_Control_Name_Here.DoubleClick 'Do something special End Sub All Controls respond to double clicks. btw: Divil, did you write the DotNetWidgets menu generator? If so you did a great job! Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
aewarnick Posted February 21, 2003 Author Posted February 21, 2003 I pretty much knew how to do it but I would think that double clicks are common and VS would have them like the rest of the Events. But I guess not. If anyone knows where that event would be please let me know. Maybe I have a cheap version of MSVC#? I got it from office max for 100 bucks. Quote C#
Cywizz Posted February 21, 2003 Posted February 21, 2003 (edited) I agree, the control your using is the richtextbox control, and i've checked both vb and c# - no DoubleClick from list of events (thunderbolt icon in c# and dropdowns in code from vb) It is, however available as a valid event via code. The help also doesn't show the event, but it does show that the control inherits from the Control class. (All Control objects have a doubleclick event) Any comments? Is this maybe a bug or is there some reason around this? EDIT: It might be in code but it doesn't work. Found a msdn artical about event sequence, confirming no double click event: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconwindowsformsarchitecture.asp It's just weird that its available in code (ide doesn't complain..):confused: Edited February 21, 2003 by Cywizz Quote Howzit??
aewarnick Posted February 21, 2003 Author Posted February 21, 2003 What about right click events, how can I configure those, the menu and everything. Quote C#
Heiko Posted February 21, 2003 Posted February 21, 2003 (edited) Should be in the mouse down event args. The menu - you'll have to do that on your own (snippet from my code) class ParameterDrivenTextbox ... Private mMenuAlternativeUnits As ContextMenu Private mAlternativeUnits As DataTable Public Function LoadAlternativeUnits() As Boolean Dim myBR As New BusinessRules.ParameterContainerBR() Dim aRow As DataRow Dim aMenuItem As MenuItem If Not Me.mMenuAlternativeUnits Is Nothing Then Me.mMenuAlternativeUnits = Nothing End If Me.mMenuAlternativeUnits = New ContextMenu() mAlternativeUnits = myBR.GetAlternativeUnits(me.GUID) If Not mAlternativeUnits Is Nothing Then If mAlternativeUnits.Rows.Count > 0 Then 'Build the popup menu ... For Each aRow In mAlternativeUnits.Rows aMenuItem = New MenuItem(Utility.ConvertToString(aRow("_AE_Bezeichnung"))) aMenuItem.RadioCheck = True AddHandler aMenuItem.Click, AddressOf Me.UnitsMenu_Clicked Me.mMenuAlternativeUnits.MenuItems.Add(aMenuItem) Next Return True Else Return False End If Else Return False End If End Function Private Sub UnitsMenu_Clicked(ByVal Sender As System.Object, ByVal e As System.EventArgs) Dim theMenuItem As MenuItem = CType(Sender, MenuItem) End Sub Private Sub btnUnit_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnUnit.MouseDown If (e.Button <> MouseButtons.Right) Then Exit Sub End If mMenuAlternativeUnits.Show(btnUnit, New System.Drawing.Point(e.X, e.Y)) End Sub end class Sure - this adds code always adds the same handler to the menu items, yopu could also add the individually, one by one, not in a loop. Edited February 21, 2003 by Heiko Quote .nerd
*Gurus* divil Posted February 21, 2003 *Gurus* Posted February 21, 2003 All controls have those events, because the base class has them. It is, however, possible that the inherited controls already have behaviour for those events and aren't calling them at all. In which case, they can't get rid of the events themselves (inheritance doesn't let you do that) but they can hide the events from the property browser using attributes. Bottom line - if the event doesn't show in the property browser, it's probably for a good reason. But it's still there, and you can always wire it up with code on the off-chance that it still works. DiverDan: Yes I did write them, thanks for the praise :) Look out for a designable Outlook Bar there in the next day or two. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted February 21, 2003 Author Posted February 21, 2003 Could I also put the right click in the Click event and even right click event? Quote C#
*Experts* Nerseus Posted February 21, 2003 *Experts* Posted February 21, 2003 If you just want a context menu, set the ContextMenu property of the control. It will override any built-in windows context menu, such as a TextBox's Copy/Cut/Paste - so you'll have to add them manually if you want those menus plus your own. If you want to do something special before showing the context menu, you'll have to use the MouseDown event. If you want to trigger the menu in the Click event, you'll need to manually keep track of which button was pressed in the MouseDown event (such as a bool variable bRightButtonDown) so that you'll know about it in the Click event (which doesn't give you which buttons are down). There is no right click event :) -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
aewarnick Posted February 23, 2003 Author Posted February 23, 2003 (edited) Why does this not work? ContextMenu C=new ContextMenu(); C=contextMenu1; if(MouseButtons==MouseButtons.Right) C.Show(); When I put the . in after C nothing pops up, it is not recognized. Something is wrong. Edited February 24, 2003 by aewarnick Quote C#
aewarnick Posted February 24, 2003 Author Posted February 24, 2003 Anyone know? I really want to use a Context menu in my program. Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.