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 6352201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:09:31+00:00 2026-05-24T22:09:31+00:00

A GUI has a button that displays the event log, which is just another

  • 0

A GUI has a button that displays the event log, which is just another form with a rich text box.

I’m making an event log that tells the user what’s going on. The problem I have is that I don’t know why the event handler i set up is not being fired when a string changes. Basically, this form has a textbox and the textbox is set to a string called ‘activity’. This string gets added on to with various messages about status and errors.

However, when the string get concatenated with other messages, the event does not get triggered and it won’t automatically update itself. I’m looking for a real-time update as these events happen. Right now, I can close the form and then reopen it to get it to load the activity string again, and that works, but can someone shed some light on why the event i set up is not being triggered? Here is the code:
The first bit is the New form that I launch. The second bit is the class with the string activity.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StatusLog
{
    public partial class StatusLogForm : Form
    {
        public StatusLogForm()
        {
            InitializeComponent();
        }
        private StatusLog statuslog = StatusLog.Instance;


        private void StatusLogForm_Load(object sender, EventArgs e)
        {
            statuslog.ActivityChanged += new EventHandler(statuslog_ActivityChanged);
            richTextBox1.Text = statuslog.Activity;
        }

        void statuslog_ActivityChanged(object sender, EventArgs e)
        {
            richTextBox1.Text = statuslog.Activity;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GDCanada.LCSS.VMF.ProtoVmf;

namespace StatusLog
{
    public class StatusLog
    {
        private static StatusLog instance;
        private StatusLog()
        {
        }

        public static StatusLog Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new StatusLog();
                }
                return instance;
            }
        }

        public enum LogType
        {
            Error,
            Status,
            Information,
            Warning,
        }

        public event System.EventHandler ActivityChanged;
        private string activity = "Activity:";
        public string Activity
        {
            get
            {
                return activity;
            }
            set
            {
                activity = value;
                if (this.ActivityChanged != null)
                {
                    this.ActivityChanged(this, new System.EventArgs());
                }
            }
        }
        void activitychanged(object sender, System.EventArgs e)
        {
        }

        public void Log(string message, LogType type)
        {
            activity = activity + "\n" + type.ToString() + ": " + message;
        }
    }
}

I add the string via the ‘Log’ function. Any help is greatly appreciated, thanks!
My apologies if I missed any information. I will be happy to provide any if needed.

-tf.rz
.NET 3.5 SP1

  • 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-24T22:09:32+00:00Added an answer on May 24, 2026 at 10:09 pm

    Look at this method:

    public void Log(string message, LogType type)
    {
        activity = activity + "\n" + type.ToString() + ": " + message;
    }
    

    You’re changing the variable directly – which does nothing but change the variable’s value.

    If you want the property code to execute (and thus raise the event) you should do:

    public void Log(string message, LogType type)
    {
        // Note use of property
        Activity = Activity + "\n" + type.ToString() + ": " + message;
    }
    

    (You don’t have to use the property getter of course – it’s only the setter that’s important.)

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

Sidebar

Related Questions

I have a windows application which has a complex GUI that I would like
I have a c# windows form application that has a similar GUI functionality as
I have a PyGTK GUI that has a gtk.Table. Pressing one button will generate
I have a GUI app, that has a button added. Within several plugin dll's,
I have a GUI developed using pyqt4 which has a run button. on run
I'm attempting to write a basic Tkinter GUI that has a Text widget at
Or any other design that has the gui widgets as being the first port
I'm building a gui component that has a tree-based data model (e.g. folder structure
I have a project that has a GUI (written in QT) and a command-line
I have designed this gui in netBeans which has a canvas , a couple

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.