All Questions
Tagged with eventhandler c#
335
questions
0
votes
1
answer
103
views
How to Handle Incoming Messages in TelegramBotClient in C#?
I'm trying to develop my first Telegram bot using C# in Visual Studio. I've been following tutorials, and everything seems to be going smoothly. However, when I try to handle incoming messages using ...
0
votes
1
answer
38
views
C# Event Handler Issue Updating Control
So, here is the layout:
frmClient = uses frmLogin (LoginWindow) which has OnLoginEvent
this event is received by frmClient, and will update the statusbar (doesn't have invoke)
frmClient also uses ...
0
votes
0
answers
47
views
C# EventHandler invoke in class A, action to run in class B
I have implemented an eventhandler that should be invoked when "OpenProject" is completed. The event is listened from another class.
What I see testing the code is that the "work inside&...
1
vote
2
answers
100
views
Passing C# function in constructor to be used as a subscriber to EventHandler delegate
I've been spending some time learning about Delegates in C# and have wired up a small Windows Form app containing two forms to test them out.
My goal is to have the AddContactForm push new Contact ...
0
votes
1
answer
128
views
How to get data from a static event-handler for serial port
I'm currently write a method that read data consecutively from serial port in C# winform for .NET framework.
I write an event handler for it, but since its static, i cannot call variable from outside.
...
0
votes
0
answers
11
views
MVVM Error Message Handling in Subclasses: Seeking Input
I'm looking for input on a MVVM design-decision. I want to send error messages from my subclasses to my MainWindowViewModel. Is this a good way to go about it or are there simpler or better ways to ...
0
votes
0
answers
206
views
C# - Serializing to XML information as to which function to bind a delegate too
I need to be able to save a delegate with the information of which function it is connected to. Something like this:
In C#:
public class Skill
{
[XmlAttribute("SkillFunction")]
...
-2
votes
1
answer
217
views
Is the following code in c# cause memory leak issue?
I was wondering if the following code create a memory leak:
using System;
namespace ConsoleApplicationTest
{
internal class Program
{
static void Main(string[] args)
{
...
1
vote
0
answers
112
views
DataGrid Event Handler has an error that prevents the live view from being updated
I am having an interesting issue. I am using Visual Studio 2022. In my XAML code, I have a DataGrid with EventSetter. The Handler is alerting on "Invalid value for property 'Handler'. This error ...
2
votes
1
answer
277
views
NullReferenceException thrown but the object passed the null check, how is that possible?
I'm using the AddEventHandler method from that answer, but when doing it on an EventHandler with a value type argument that happens:
using System.Reflection;
public class Program
{
public static ...
0
votes
1
answer
248
views
How do you change the value to an acceptable value after a NumberBox's ValueChanged event is triggered using WinUI3?
I have a list of Images with corresponding NumberBoxes in a GridView. This is the XAML:
<DataTemplate
x:Key="CardListView_ItemTemplate"
x:DataType="local:CardItem">
...
3
votes
2
answers
1k
views
How to pass EventHandler as parameter in Blazor
Trying to pass an EventHandler to a Blazor component. Error I'm getting:
The event AppState.IntegerChanged can only appear on the left hand side of +=
Seems like this should work, is it a blazor ...
0
votes
1
answer
588
views
Task.Run invoking an EventHandler. Is it correct?
I am writing unit tests for an async method and I think I should avoid .Invoke inside Task.Run in the next function.
Here is the current code under test:
public class Foo
{
public event EventHandler&...
1
vote
1
answer
249
views
Why don't we create an Event Handler delegate for binding a handler with an event when programmatically creating an event handler?
I am creating a Windows Form application in Visual Studio using C#. I am having trouble understanding the concept of Event Handler Delegates.
If I create an event handler for an event using the ...
-1
votes
1
answer
407
views
How do I change the text of a System.Windows.Forms.Label from a public static void button_click event?
More details:
Assume I am creating a form and a button and a label in the main function, and I want the label text to change when I click on the button. I am getting an error that the label is outside ...