?
Solved

Alerting a main application form that a user setting has been changed

Posted on 2005-02-25
3
Medium Priority
?
195 Views
Last Modified: 2010-04-16
Hi experts,
  I am writing an application using MS Visual C# Express Beta, that has a modeless configuration form so that the user can change various application settings.  These settings modify the state of the values contained in 'Properties.Settings1.Value.xxx'.
  Is there any way to alert the main form to any changes that have been made to the user settings so that it can change its behaviour of say the com port used for the serialPort class?
  By the way I would describe myself as a relative beginner to C#.Net

Cheers
0
Comment
Question by:Millamba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
gioni_go earned 600 total points
ID: 13411894
using System;
/*Ok for this u have to use events . If u dont know what they are
 * I'll try to eplain to u a little bit .First of all there
 * are three componets in programming event driven apps.
 *First ---is  of them is YourEventArgs (the arguments passed by
 *your event)
 *Second---is the event handler (wich is a delegate)
 *Third --- is the actual event
 *OK let's start
 *
*/
namespace Proj
{
      //////////////////////////////////////////////////////////////////
      public class CustomEventArgs:EventArgs //always must derive from
      {                                                            //this base class
            public CustomEventArgs(string type_OfChange,string value_ofch)
            {//the class constructor
                  this.type_change = type_OfChange;
                  this.value_change= value_ofch;
            }
            public readonly string type_change,value_change;
            //they must be readonly so that they can only be read
      }
      //////////////////////////////////////////////////////////////////
      
      //////////////////////////////////////////////////////////////////
      public delegate void CustomEventHandler(CustomEventArgs args);
      //we defined our delegate = pointer to a function (in c++)
      //////////////////////////////////////////////////////////////////
      
      public class Test//:Form
      {
            //let's say this is the Form class u're gonna use
            //u're gonna define a custom event like this
            public event CustomEventHandler EventYouWaitFor;
            public Test()
            {
                  
            }
            public void TheGuyCheckedTheBox()
            {
                  OnCustomEvent(new CustomEventArgs("BlackCheckBox","Checked"));
            }
            //Now we're gonna make the function that fires the event
            protected void OnCustomEvent(CustomEventArgs args)
            {
                  if(EventYouWaitFor != null)
                  {
                        EventYouWaitFor(args);
                  }
            }
      }

      public class Tester
      {
            public static void Main(String[] args)
            {
            //ok now we test app
                  Test tst = new Test();
                  tst.EventYouWaitFor += new CustomEventHandler(doOnEvent);

                  //Now when the guy presses the checkbox u get the values
                  // I already put them for u in the function
                  tst.TheGuyCheckedTheBox();
            //and voila the result
                  // U really must read a little bit about delegates and events
                  // they are scary but they are easy to understand

                  Console.ReadLine();
            }

            public static void doOnEvent(CustomEventArgs args)
            {
            Console.WriteLine(args.type_change);
                  Console.WriteLine(args.value_change);
            }
      }
}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question