C
C#13mo ago
mrVinicius

❔ event handler not being triggered

I'm having difficulty making this event works, can someone more experienced point me what im doing wrong? I have a user control that has a button, and when i click this button i want my form to do something, but when i click the button it does not reach the method in the form.
8 Replies
mrVinicius
mrVinicius13mo ago
Anchy
Anchy13mo ago
if this is winforms then typically you would use the designer to register your events so that the designer can auto generate the event handler for you
JakenVeina
JakenVeina13mo ago
yeah, the onClick() method? where are you attaching that to the button?
jcotton42
jcotton4213mo ago
onClick is actually registering the handler Rather odd
JakenVeina
JakenVeina13mo ago
oh, derp that's what I get for assuming conventions yeah, that's very much not what "OnXXX" conventionally means so, from that snippet, everything appears to be in order what is the specific problem? Console.WriteLine("Button clicked"); should be running, no problem if it's really not, I'm going to have to say that saveBtn isn't the button you're clicking
mrVinicius
mrVinicius13mo ago
Console.WriteLine("Button clicked") is being triggered, but the problem is the whole event is not being triggered. When i click the saveBtn, it has should trigger a event that RegisterUC_SaveBtn_Clicked is listening to, and when this happen a message should be displayed on screen. My initial idea was having a button on User Control that when clicked triggered a method in Form via events. I couldn't make it work and i have a deadline by tomorrow so i changed my approach to work with tabs, thus not needing to pass data around. Oddly enough i managed to make the events work between Form and Presenter layer, but not between Form and User Control, thanks anyway.
JakenVeina
JakenVeina13mo ago
if Console.WriteLine("Button clicked"); is running, SaveBtn_Clicked is being triggered if RegisterUC_SaveBtn_Clicked is not running, then it's not listening to SaveBtn_Clicked
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Is it possible to create a augment reality system in windows form in visual studio.I have looked on stack overflow and other resources to try to find out if it is possible to make a a❔ I want to only have hours, minutes, secs, on my count up for my music:here code: ```c private async Task UpdateSongPositionAndDuration(string accessToken) { ❔ I wrote a program that calculates the shortest path to move fridge to a certain place but its slowI wrote a program that calculates the shortest path to move fridge to a certain place but the runtim❔ Razor pages - Filtering data (shown in table) by some random filtersAs mentioned in title, I am showing some data in table, and I need some filters, like `serialNumberWpf RichTextBox stylingGuys any idea how to disable automatic styling in WPF richtextbox For example i have toggle button ❔ Just beginning the stuffI found that c# is what I need basically, because I can do a lot of funny stuff with it. I need to kThis project is not supported in C# Dev Kit.I've problem when load my project in vscode. i want to change code from Microsoft Visual Studio to VQueryParameter .NET MAUIthe query parameter Id is not being set correctly in my viewmodel .when using breakpoints I am able ❔ Making charts in .net core mvcI want to create a linechart showing daily income and expense transactions. I have created in my BLL❔ Building a location search engine (airbnb/booking style)What is more common here? To text match locations (i.e. search USA, grab anything in the DB in the U