eventargs

What is the type of MouseEventArgs.X?

我只是一个虾纸丫 提交于 2019-12-12 05:16:32
问题 Working with C# in Visual Studio 2008 (.NET 3.5). Looking into System.Windows.Forms.MouseEventArgs . I'm seeing strange behavior with long Panel when I intercept handle the MouseMove event. It appears that MouseEventArgs.X goes from 0 to 32767, and wraps around to -32768. When I watch the variable in Visual Studio, it claims that it's of type int . Apparently it's a 16-bit signed integer the way it's behaving. Is this true? Is this a hard limit? Thanks! 回答1: This probably comes from the fact

how to deal with multiple event args

陌路散爱 提交于 2019-12-11 14:26:10
问题 I am in the process of creating a small game. The engine will have a number of events that the GUI can subscribe to. The events are: ballselected balldeselected ballmoved ballremoved This would all be fine if I only had one type of ball, but there are X number ball types. They all derive from an abstract Ball class. Each ball type has its own actions that happen when this event happens for them. They will all need to pass different information back to the GUI. For example I have these two

Can someone please explain to me in the most layman terms how to use EventArgs?

隐身守侯 提交于 2019-12-11 00:46:45
问题 I know they have something to do with delegates. I've tried but I still don't comprehend how to use those either. I know a little about event handlers but what I really want to know is how I can use plain old eventargs that are part of most methods. example below void Page_Load(object sender, EventArgs e) { myText.Value = "Hello World!"; } Thanks for your time & consideration, I am just trying to be the best coder I can be. Mike 回答1: EventArgs classes are used as data carriers when raising

Why no constraint on EventHandler<TEventArgs>?

北城余情 提交于 2019-12-08 19:41:36
问题 I just figured out by accident (when something compiled that I didn't think would compile) that EventHandler is not constrained to the type System.EventArgs. Here's the inline docs: #region Assembly mscorlib.dll, v4.0.0.0 // C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll #endregion namespace System { // Summary: // Represents the method that will handle an event. // // Parameters: // sender: // The source of the event. // // e: // An System

EventArgs.Empty clarification?

梦想的初衷 提交于 2019-12-06 00:18:58
I have a method protected void Item_Click(object sender, EventArgs e) { } I wanted that other code to call this method. ( didn't really need the sender nor e ) something like : Item_Click(null, null) But then I remembered I can use EventArgs.Empty instead. Mouse hovering over it shows : Wait...What ? EventArgs.Empty represents an event ? it is not. it should represent empty argument not an event. just like string.empty represent empty string . Am I missing something here? It's just poor documentation, conflating two concepts in one word. The latest documentation seems a little better: Provides

Pass object in click/tapped event handler in Xamarin Forms

梦想的初衷 提交于 2019-12-05 03:39:17
Here is my job class: public class Job { public string Id{ get; set;} public string Name{ get; set;} } And here is my ListView: public class JobListePage:ContentPage { // Members private ListView lstView; // Constructor public JobListePage () { // Set members lstView = new ListView (); // Create job objects Job[] jobs = {new Job(){Id="1", Name="Benny"}, new Job(){Id="2", Name="Lukas"}}; // Fill listview with job objects lstView.ItemsSource = jobs; // HOW CAN I PASS THE TAPPED OBJECT HERE??? lstView.ItemTapped += async (o, e) => { await DisplayAlert("Tapped", "HERE I WANT TO SHOW THE ID", "OK")

How wrong is it to create an event handler delegate with out the standard (Obj sender, EventArgs args) signature?

只愿长相守 提交于 2019-12-04 09:26:51
问题 I understand the benefits of using the standard MS event handler delegate signature as it allows you to easily expand on the information passed through the event with out breaking any old relationships that are based on the old delegate signature. What I'm wondering is in practice how often do people follow this rule? Say I have a simple event like this public event NameChangedHandler NameChanged; public delegate void NameChangedHandler(Object sender, string oldName, string newName); It's a

How wrong is it to create an event handler delegate with out the standard (Obj sender, EventArgs args) signature?

自古美人都是妖i 提交于 2019-12-03 02:14:47
I understand the benefits of using the standard MS event handler delegate signature as it allows you to easily expand on the information passed through the event with out breaking any old relationships that are based on the old delegate signature. What I'm wondering is in practice how often do people follow this rule? Say I have a simple event like this public event NameChangedHandler NameChanged; public delegate void NameChangedHandler(Object sender, string oldName, string newName); It's a simple event, and I'm nearly positive that the only arguments I'm ever going to need to know from the

how to access Custom EventArgs class in Button click event?

拥有回忆 提交于 2019-12-02 06:31:31
As a follow up to: access values within custom eventargs class How do I access public variables within custom Eventargs class, using button click or any other method? Example Custom Event Args class: public class TraderEventArgs: EventArgs { private int _shares; private string _symbol; public TraderEventArgs(int shs, string sym) { this._shares = shs; this._symbol = sym; } public decimal Price { get {return _prices;} } public int Shares { get { return _shares; } } } Code behind button_click event: public partial class _Default : System.Web.UI.Page { protected void Button1_Click(object sender,

Jquery - Pass asp button command argument with jquery

为君一笑 提交于 2019-11-30 08:48:16
问题 I have asp button: <asp:button ID="btn1" runat="server" CommandArgument="" CssClass="btn1" OnClick="button_click"></asp:button> and script: $("a").click(function () { var val = $(this).attr('id').toString(); $('.btn1').attr('CommandArgument',val); alert($('.btn1').attr('CommandArgument').toString()); $('.btn1').click(); }); after click it alerts me command argument. But on next step - when i trigger btn1 click with jquery it goes to codebehind and command argument is empty. Can i pass somehow