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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:52:32+00:00 2026-06-17T07:52:32+00:00

I have a groupbox with a background of a certain color containing a textbox.

  • 0

I have a groupbox with a background of a certain color containing a textbox. I was thinking of ways to help the user see that the textbox was dirty, and thought perhaps changing the background groupbox color and/or adding a “*” to the name of the groupbox and/or Form Text would be nice. But I can’t get the event to even change the property of _isDirty. Let alone implement this idea. I’m sure that someone has done something similar and Hope that you could help me. I’m working with C# .Net framework 2.0 (it should also work in 4.0 but that’s backwards compatible I believe). IDE is Visual Studios 10.

The idea is when the textbox is changed, the _isDirty “flag”/”property” will be changed, as well as when it has been saved:

_isDirty = true when textbox has been changed

_isDirty = false when textbox has been saved

This is what I have at the moment.. though I’ve tried different things including the INotify which wasn’t working for me at all…

    public static bool _isDirty = false;

    private void textBox1_TextChanged(object sender, EventArgs e)
    {
        string newtext = textBox1.Text;
        if (currentText != newtext)
        {
            // This solves the problem of initial text being tagged as changed text
            if (currentText == "")
            {
                _isDirty = false;
            }
            else
            {
                //OnIsDirtyChanged();
                _isDirty = true; //might have to change with the dirty marker
            }
            currentText = newtext;
        }
    }

     public bool IsDirty
    {
        get { return _isDirty; }
        set
        {
            if (_isDirty != value)
            {
                _isDirty = value;
                OnIsDirtyChanged(_isDirty);
            }
        }
    }

    protected void OnIsDirtyChanged(bool _isDirty)
    {
        if (_isDirty == true)
        {
            this.Text += "*";
        }
    }

If someone has a different suggestion to how I go about this, or a nicer user friendly way of doing this, I’m open for suggestions.. Thanks!

EDIT: The answer is actually in 2 parts! The correction to make the property change event WORK was given by BRAM.
If you want to know how to change background color, then look at ZARATHOS’S answer.
Unfortunately I can only mark ONE answer, so going to mark the one that got the main bit working.

  • 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-06-17T07:52:34+00:00Added an answer on June 17, 2026 at 7:52 am

    You are setting _isDirty so the event does not fire.
    You need to set IsDirty.

        if (currentText != newtext)
        {
            // This solves the problem of initial text being tagged as changed text
            if (currentText == "")
            {
                IsDirty = false;
            }
            else
            {
                //OnIsDirtyChanged();
                IsDirty = true; //might have to change with the dirty marker
            }
            currentText = newtext;
        }
    

    And this line is wrong

    OnIsDirtyChanged(_isDirty);
    

    Needs to be

    OnIsDirtyChanged(IsDirty);
    

    Assuming that is the notification event.

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

Sidebar

Related Questions

I have a GroupBox that contains a stackpanel holding a textbox and a datagrid.
I have a groupBox that I have put three RadioButtons and one TextBox in
I have a groupbox that holds a flowlayout panel and the flowlayout panel holds
I am using .NET winforms. I have a groupBox that contains a set of
I have this Markup: <GroupBox BorderThickness=2> <GroupBox.BorderBrush> <SolidColorBrush x:Name=Border> <SolidColorBrush.Color> <MultiBinding Converter={StaticResource ConnectionAndLoggedInToBorderBrush}> <Binding
I have a composite control that is includes a groupbox control. The problem is
I have a form that containts 2 groupbox, each groupbox contain a radiobutton call
I have a textbox in a groupbox, both with double click events. When I
I have a Windows Forms app that contains a groupbox with about 30 controls.
I have a groupbox that contains nested stack panels that aren't filling in the

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.