Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 713257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:56:27+00:00 2026-05-14T04:56:27+00:00

Total n00b to C# and events although I have been programming for a while.

  • 0

Total n00b to C# and events although I have been programming for a while.

I have a class containing a text box. This class creates an instance of a communication manager class that is receiving frames from the Serial Port. I have this all working fine.

Every time a frame is received and its data extracted, I want a method to run in my class with the text box in order to append this frame data to the text box.

So, without posting all of my code I have my form class…

public partial class Form1 : Form
{
    CommManager comm;

    public Form1()
    {
        InitializeComponent();
        comm = new CommManager();

    }

    private void updateTextBox()
    {
        //get new values and update textbox
    }
    .
    .
    .

and I have my CommManager class

class CommManager 
{
     //here we manage the comms, recieve the data and parse the frame
}

SO… essentially, when I parse that frame, I need the updateTextBox method from the form class to run. I’m guessing this is possible with events but I can’t seem to get it to work.

I tried adding an event handler in the form class after creating the instance of CommManager as below…

 comm = new CommManager();
 comm.framePopulated += new EventHandler(updateTextBox);

…but I must be doing this wrong as the compiler doesn’t like it…

Any ideas?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:56:27+00:00Added an answer on May 14, 2026 at 4:56 am

    Your code should look something like:

    public class CommManager()
    {
        delegate void FramePopulatedHandler(object sender, EventArgs e);
    
        public event FramePopulatedHandler FramePopulated;
    
        public void MethodThatPopulatesTheFrame()
        {
            FramePopulated();
        }
    
        // The rest of your code here.
    }
    
    public partial class Form1 : Form      
    {      
        CommManager comm;      
    
        public Form1()      
        {      
            InitializeComponent();      
            comm = new CommManager();      
            comm.FramePopulated += comm_FramePopulatedHander;
        }      
    
        private void updateTextBox()      
        {      
            //get new values and update textbox      
        }
    
        private void comm_FramePopulatedHandler(object sender, EventArgs e)
        {
            updateTextBox();
        }
    }
    

    And here’s a link to the .NET Event Naming Guidelines mentioned in the comments:

    MSDN – Event Naming Guidelines

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Total newb to .NET programming (and AJAX) but I've been working on this program
I realize this is a total n00b question, but I'm curious and I thought
I have very little experience with MySQL/SQL in general - total n00b really! I
Forgive me, I am a total n00b with javascript! I have a complicated request
Total OO noob question here. I have these two methods in a class private
G'day, I'm a total n00b when it comes to SQL Server reports and my
Total noob here with javascript. I'm trying to alter a function. This is the
Total noob here. This is my first c# attempt, its a console application that
total n00b question here but I can't seem to find the answer searching around
I'm a total F# n00b, so I hope i give you enough information. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.