Search Results

Search found 10381 results on 416 pages for 'delegate and events'.

Page 81/416 | < Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >

  • Pass an event into a constructor

    - by Vaccano
    I have a class that I want to be able the handle the mouse up event for a grid. I tried to create it with a static method call like this: MyDataBinding.BindObjectsToDataGrid(ListOfObjectsToBind, myGrid.MouseUp); The end goal being that in the method I would assign a delegate to the MouseUp PassedInMouseUp += myMethodThatWillHandleTheMouseUp; Looks good here (to me) but the compiler chokes on the first line. It says that I can only use MouseUp with a += or a -=. Clearly I am going about this the wrong way. How can I get a different class to handle the mouse up with out having to: Pass in the whole grid Expose the method that will be handling the mouse up as a public method. Or, is this just a limitation and I will have to do one of the above?

    Read the article

  • Can I use a single instance of a delegate to start multiple Asynchronous Requests?

    - by RobV
    Just wondered if someone could clarify the use of BeginInvoke on an instance of some delegate when you want to make multiple asynchronous calls since the MSDN documentation doesn't really cover/mention this at all. What I want to do is something like the following: MyDelegate d = new MyDelegate(this.TargetMethod); List<IAsyncResult> results = new List<IAsyncResult>(); //Start multiple asynchronous calls for (int i = 0; i < 4; i++) { results.Add(d.BeginInvoke(someParams, null, null)); } //Wait for all my calls to finish WaitHandle.WaitAll(results.Select(r => r.AsyncWaitHandle).ToArray()); //Process the Results The question is can I do this with one instance of the delegate or do I need an instance of the delegate for each individual call? Given that EndInvoke() takes an IAsyncResult as a parameter I would assume that the former is correct but I can't see anything in the documentation to indicate either way.

    Read the article

  • Explicit Event add/remove, misunderstood?

    - by Hammerstein
    I've been looking into memory management a lot recently and have been looking at how events are managed, now, I'm seeing the explicit add/remove syntax for the event subscription. I think it's pretty simple, add/remove just allows me to perform other logic when I subscribe and unsubscribe? Am I getting it, or is there more to it? Also, while I'm here, any advice / best practices for cleaning up my event handles.

    Read the article

  • How do I link up a button click event between a class and a module automatically?

    - by CowKingDeluxe
    I have this code (which doesn't work): Public Class Form1 End Class Public Module test1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Form1.Button1.Click MsgBox("HI") End Sub End Module I know I could handle the button click event in Form1, and then call a function in test1, but I would like to handle the button click event directly in the test1 module. Is there a way to automatically send UI events from the Form1 class to another module?

    Read the article

  • IE firing anything else but click

    - by shabunc
    I just wonder is there's any way to fire any event via IE's event-triggering implementation - fireEvent. I've tried to use it but failed with all event except click. The only reason i've get interested with this issue it curiousity, thus, any answers like "just do not trigger events, it is a bad idea" - all such answers would be considered, well...not full))) thanks in advance

    Read the article

  • Gain Access to Mouse Clicks in C# Component

    - by Jason
    I am using the ScintillaNET component and I am attempting to capture clicks in the margin, as this will determine how I respond. Unfortunately, the margins capture the mouse events (and don't provide a way, from what I can see, to get the click information - number of clicks, mouse button clicked, etc). If this is indeed the case (I am not able to get that info directly), what is another way of capturing what the mouse is doing before the MarginClick event is fired? Thanks for any help!

    Read the article

  • Delegate Method only Firing after 5 or so Button Presses?

    - by CoDEFRo
    I'm having the most bizarre problem which I'm not even close to figuring out. I have a button which fires a delegate method. Once upon a time it was working fine, but after making some changes to my code, now the delegate method only fires after I push the button x amount of times (the changes I made to the code had nothing to do with the infrastructure that connects the delegate together). It varies, it can be 5 times to 10 times. I used the analyzer to check for memory leaks and there aren't any. There is too much code for me to paste here (I don't even know where to start or where the problem could be), but I'm wondering if anyone has experienced this problem before, or what could be causing it? This is very odd and have no clue what could be causing it.

    Read the article

  • Why is there a large gap between Begin PreRenderComplete and End PreRenderComplete on my page?

    - by Middletone
    I'd like to know what can cause this kind of disparity between the begin and end PreRendercomplete events or how I migh go about locating the bottleneck. aspx.page End PreRender 0.193179639923915 0.001543 aspx.page Begin PreRenderComplete 0.193206263076064 0.000027 aspx.page End PreRenderComplete 1.96926008935549 1.776054 aspx.page Begin SaveState 2.13108461902679 0.161825

    Read the article

  • C# Event Handlers Using an Enum

    - by Jimbo
    I have a StatusChanged event that is raised by my object when its status changes - however, the application needs to carry out additional actions based on what the new status is. e.g If the new status is Disconnected, then it must update the status bar text and send an email notification. So, I wanted to create an Enum with the possible statuses (Connected, Disconnected, ReceivingData, SendingData etc.) and have that sent with the EventArgs parameter of the event when it is raised (see below) Define the object: class ModemComm { public event CommanderEventHandler ModemCommEvent; public delegate void CommanderEventHandler(object source, ModemCommEventArgs e); public void Connect() { ModemCommEvent(this, new ModemCommEventArgs ModemCommEventArgs.eModemCommEvent.Connected)); } } Define the new EventArgs parameter: public class ModemCommEventArgs : EventArgs{ public enum eModemCommEvent { Idle, Connected, Disconnected, SendingData, ReceivingData } public eModemCommEvent eventType { get; set; } public string eventMessage { get; set; } public ModemCommEventArgs(eModemCommEvent eventType, string eventMessage) { this.eventMessage = eventMessage; this.eventType = eventType; } } I then create a handler for the event in the application: ModemComm comm = new ModemComm(); comm.ModemCommEvent += OnModemCommEvent; and private void OnModemCommEvent(object source, ModemCommEventArgs e) { } The problem is, I get a 'Object reference not set to an instance of an object' error when the object attempts to raise the event. Hoping someone can explain in n00b terms why and how to fix it :)

    Read the article

  • Call event from original thread ??

    - by user311883
    Hi all, Here is my problem, I have a class which have a object who throw an event and in this event I throw a custom event from my class. But unfortunately the original object throw the event from another thread and so my event is also throw on another thread. This cause a exception when my custom event try to access from controls. Here is a code sample to better understand : class MyClass { // Original object private OriginalObject myObject; // My event public delegate void StatsUpdatedDelegate(object sender, StatsArgs args); public event StatsUpdatedDelegate StatsUpdated; public MyClass() { // Original object event myObject.AnEvent += new EventHandler(myObject_AnEvent); } // This event is called on another thread private void myObject_AnEvent(object sender, EventArgs e) { // Throw my custom event here StatsArgs args = new StatsArgs(..........); StatsUpdated(this, args); } } So when on my windows form I call try to update a control from the event StatsUpdated I get a cross thread exception cause it has been called on another thread. What I want to do is throw my custom event on the original class thread, so control can be used within it. Anyone can help me ?

    Read the article

  • Event consumption in WPF

    - by webaloman
    I have a very simple app written in Silverlight for Windows Phone, where I try to use events. In my App.xaml.cs code behind I have implemented a GeoCoordinateWatcher which registers a gCWatche_PositionChanged method. This works ok, method is called after the position has been changed. What I want to do is fire an other event lets say DBUpdatedEvent after DB has been updated in the gCWatche_PositionChanged method. For this i delclared in the App.xaml.cs public delegate void DBUpdateEventHandler(object sender, EventArgs e); and I have in my App class: public event DBUpdateEventHandler DBUpdated; the event is fired like this in the end of gCWatche_PositionChanged method like this: OnDBUpdateEvent(new EventArgs()); and also I have declared : protected virtual void OnDBUpdateEvent(EventArgs e) { if (DBUpdated != null) { DBUpdated(this, e); } } Now I need to consume this event in my other Windows Phone app page which is a separate class PhoneApplicationPage. So I declared this method in this other Phone Page: public void DBHasBeenUpdated(object sender, EventArgs e) { Debug.WriteLine("DB UPDATE EVENT CATCHED"); } And in the constructor of this page I declared: DBUpdateEventHandler dbEH = new DBUpdateEventHandler(DBHasBeenUpdated); But when I test the application event is fired (OnDBUpdateEvent is called, but DBUpdated is null, therefore DBUpdated is not called - strange) and I have a problem that the other Phone Page is not catching the event at all... Any suggestions? How to catch that event. Thanks.

    Read the article

  • Paste Event in a WPF TextBox

    - by code-zoop
    I have created a custom control inheriting TextBox. This custom control is a numeric TextBox, only supporting numbers. I am using OnPreviewTextInput to check each new character being typed to see if the character is a valid input. This works great. However, if I paste the text into the TextBox, OnPreviewTextInput is not fired. What is the best way to capture pasted text in a TextBox? Also, I have a problem when the back space is pressed, I can't figure out what event this will fire. OnPreviewTextInput is not fired! any ideas how to capture pasted text and back space events in WPF TextBox? Thanks

    Read the article

  • Notifying iFrame page from Firefox extension?

    - by Crashalot
    I'm writing a Firefox extension and need to notify an iFrame page of certain events. The iFrame page is contained within a sidebar created by the extension, and this iFrame page is controlled by me. When I load the iFrame page, the extension code needs to send a notification and trigger something to happen within the iFrame page. To accomplish this, I'm creating an event from the extension Javascript and firing the event, which the iFrame page is listening to. Unfortunately, when invoking document.createEvent(), this error pops up (copied, with the quotes, straight out of Firebug): Operation is not supported" code: "9 Any clues on the error, or suggestions on how to trigger something in an iFrame page from the extension Javascript? Thanks!

    Read the article

  • WinForms Taskbar Icon - Click Event not firing

    - by Greycrow
    I have created a non-form c# program that uses the NotifyIcon class. The text "(Click to Activate)" shows up when I hover the mouse. So I am getting some events handled. However, The "Click" event does not fire and the Context menu doesnt show up. public class CTNotify { static NotifyIcon CTicon = new NotifyIcon(); static ContextMenu contextMenu = new ContextMenu(); static void Main() { //Add a notify Icon CTicon.Icon = new Icon("CTicon.ico"); CTicon.Text = "(Click to Activate)"; CTicon.Visible = true; CTicon.Click += new System.EventHandler(CTicon_Click); //Create a context menu for the notify icon contextMenu.MenuItems.Add("E&xit"); //Attach context menu to icon CTicon.ContextMenu = contextMenu; while (true) //Infinite Loop { Thread.Sleep(300); //wait } } private static void CTicon_Click(object sender, System.EventArgs e) { MessageBox.Show("Clicked!"); } }

    Read the article

  • Event Capturing vs Event Bubbling

    - by Rajat
    I just wanted to get the general consensus on which is a better mode of event delegation in JS between bubbling and capturing. Now I understand that depending on a particular use-case, one might want to use capturing phase over bubbling or vice versa but I want to understand what delegation mode is preferred for most general cases and why (to me it seems bubbling mode). Or to put it in other words, is there a reason behind W3C addEventListener implementation to favor the bubbling mode. [capturing is initiated only when you specify the 3rd parameter and its true. However, you can forget that 3rd param and bubbling mode is kicked in] I looked up the JQuery's bind function to get an answer to my question and it seems it doesn't even support events in capture phase (it seems to me because of IE not support capturing mode). So looks like bubbling mode is the default choice but why?

    Read the article

  • Android Custom View to Activity communication

    - by Blumer
    I have a custom control/view that observes the direction of a gesture within its bounds. I would like to send a different message back to the Activity hosting the View depending on the direction of the gesture. I'm having a hard time determine what the right way to do this is. I would think I could raise a custom event in the control and then stick a listener on the control in the activity, but I cannot find any information on custom events in Android. Any help would be appreciated. Thanks.

    Read the article

  • AS3 Event Bubbling outside of the Scenegraph/DisplayList

    - by Brian Heylin
    Hi just wondering if it is possible to take advantage of event bubbling in non display list classes in AS3. For example in the model of an application where there is a City class that contains many Cars. What methods are there to attach an event listener to a City object and receive events that bubble up from the child Cars. To clarify The City and Car objects are not part of the display list, they are not DisplayObjects. So can bubbling be implemented outside of the display list somehow? As far as I know, this is not possible without manually attaching event listeners to each Car object and re dispatching the event from the City object. Anyone else have a cleaner solution?

    Read the article

  • How do I pan the contents of a div when the right mouse button is dragged?

    - by Shaunwithanau
    I need a cross browser way of capturing the right mouse click, preventing the default context menu and making it where when the user drags the mouse they can pan the contents of a div. This is largely similar to Google maps in that they will grip the contents and drag to see what they want. No external libraries please. I am already capturing the events, and know that this will prevent default actions: if (evt.preventDefault) { evt.preventDefault(); } else { evt.returnValue = false; } But this doesn't prevent the context menu AFAIK. Edit: I really am unsure about how to prevent the context menu and what the best way to manipulate the scroll bars would be? examples would be great

    Read the article

  • Call a function by its name, given from string java

    - by Joao
    Hello, I would like to be able to call a function based on its name provided by a string. Something like public void callByName(String funcName){ this.(funcName)(); } I have searched a bit into lambda funcions but they are not supported. I was thinking about going for Reflection, but I am a bit new to programming, so I am not so familiar with the subject. This whole question was brought up on my java OOP class, when I started GUI (Swing, swt) programming, and events. I found that using object.addActionCommand() is very ugly, because I would later need to make a Switch and catch the exact command I wanted. I would rather do something like object.attachFunction(btn1_click), so that it would call the btn1_click function when the event click was raised. Thank you Joao

    Read the article

  • How can I update an expression in a Runt::Schedule object?

    - by Reid Beels
    Runt provides a Schedule class for managing collections of events, each represented by a temporal expression. The Schedule class provides an update method, cited in the release notes as "allowing clients to update existing expressions". The implementation of this method, however, simply calls a supplied block, providing the temporal expression for the specified event (as shown). # From lib/runt/schedule.rb:61 # # Call the supplied block/Proc with the currently configured # TemporalExpression associated with the supplied Event. # def update(event,&block) block.call(@elems[event]) end How is one expected to use this method to update an expression?

    Read the article

  • WYSIWYG iframe editor and oninput event.

    - by teehoo
    I'm writing a simple WYSIWYG editor in an iframe, but having trouble registering the "oninput" event to detect when the user modifies the text field such as pasting in data etc. var txtArea = document.getElementById('txtArea'); txtArea.contentWindow.document.designMode="on"; txtArea.contentWindow.document.open(); txtArea.contentWindow.document.write("<head><style type='text/css'>body{font-size:13px;}</style></head><body>"+data.document+"</body>"); txtArea.contentWindow.document.close(); $([txtArea.contentWindow.document]).bind("click", updateCaretPosMouse); //fires $([txtArea.contentWindow.document]).bind("keyup", updateCaretPosKeyboard); //fires $([txtArea.contentWindow.document]).bind("input", textChanged); //doesn't fire If I create a plain old element, and add the "input" event to this, then it works. Do 'input" events not work with iframes WYSIWYG editors?

    Read the article

  • Keyboard input for a game in Java

    - by hmp
    I'm writing a game in Java, right now it's Swing + JOGL - a JFrame with a GLCanvas. I handle input using keyPressed etc. events (jframe.addKeyListener(...)) and it doesn't seem to work properly: when I have 3+ keys down at the same time, they don't register properly after the window loses, then regains focus, input stops working completely... What am I doing wrong? Is there a better way of handling keyboard input in Java? (I'd rather not switch to another library, like LWJGL... unless I have no choice).

    Read the article

  • jQuery event handler queue

    - by resopollution
    Overview of the problem In jQuery, the order in which you bind a handler is the order in which they will be executed if you are binding to the same element. For example: $('#div1').bind('click',function(){ // code runs first }); $('#div1').bind('click',function(){ // code runs second }); But what if I want the 2nd bound code to run first? . My current solution Currently, my solution is to modify the event queue: $.data(domElement, 'events')['click'].unshift({ type : 'click', guid : null, namespace : "", data : undefined, handler: function() { // code } }); . Question Is there anything potentially wrong with my solution? Can I safely use null as a value for the guid? Thanks in advance. .

    Read the article

< Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >