473,761 Members | 3,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make it so if i change the checkbox in runtime it will take effect on form1?

69 New Member
I created a new form and added split container and then on the left side a treeview and on the treeview i added nodes and on the right side of the split container i added a groupbox.

Now in the groupbox i added a checkbox and what i wanted to do is when its checked it will activate voices on my program i mean SpeechSynthesiz er()

And its working when i check in the checkbox it says "Voices are now enabled" and when uncheck it says " Voices now disabled".

The problem is im using on my form1 in few places from the new form to hear voices and when i check in the checkbox on the new form and it says " Voices are now enabled" if im doing it in runtime when my program is running i need to exit the program run it again and only then it will take effect on the voices in form1. And if i disable the voices in the new form uncheck the box it will say the voices disabled but they will still be enabled only if ill exit the program and run it again it will take effect and will be disabled.

My problem how to make it so if i change the checkbox in runtime it will take effect on form1 in runtime? Without exiting the program all the time.

Here is the code on the new form:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Net;
  10. using System.IO;
  11. using AboutIt;
  12. using General_utility;
  13. using DannyGeneral;
  14. using System.Runtime.InteropServices;
  15. using System.Diagnostics;
  16. using System.Threading;
  17. using System.Net.NetworkInformation;
  18. using statistic;
  19. using ZedGraph;
  20. using System.Management;
  21. using System.Security;
  22. using System.Security.AccessControl;
  23. using System.Security.Principal;
  24. using System.Net.Mail;
  25. using System.Net.Mime;
  26. using Microsoft.Win32;
  27. using System.Web;
  28. using MyWebBrowser;
  29. using System.Speech.Synthesis;
  30. using System.Resources;
  31. using System.Reflection;
  32. using System.Globalization;
  33.  
  34. namespace WindowsFormsApplication1
  35. {
  36.     public partial class SettingsMenu : Form
  37.     {
  38.         public bool voices_on_off;
  39.         string path_exe;
  40.         string settings_dir;
  41.         string settings_file;
  42.         OptionsFile setting_file;
  43.         public SpeechSynthesizer speaker;
  44.         public SettingsMenu()
  45.         {
  46.             InitializeComponent();
  47.             voices_on_off = false;
  48.             path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);
  49.             settings_file = "\\settings.txt";
  50.             settings_dir = path_exe + @"\settings";
  51.             setting_file = new OptionsFile(settings_dir + settings_file);
  52.             speaker = new SpeechSynthesizer();
  53.             groupBox1.Visible = false;
  54.             groupBox1.Enabled = false;
  55.             bool b = false;
  56.             string key = setting_file.GetKey("Voices");
  57.             if (key == null)
  58.             {
  59.             }
  60.             else
  61.             {
  62.                 bool.TryParse(key.Trim(), out b);
  63.                 EnableVoices.Checked = b;
  64.             }
  65.         }
  66.  
  67.         private void SettingsMenu_Load(object sender, EventArgs e)
  68.         {
  69.  
  70.         }
  71.  
  72.         private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
  73.         {
  74.             if (treeView1.SelectedNode.Name.Equals(treeView1.Nodes["Main"].Name))
  75.             {
  76.                 if (treeView1.SelectedNode.IsExpanded == false)
  77.                 {
  78.                     groupBox1.Visible = false;
  79.                     groupBox1.Enabled = false;
  80.                 }
  81.             }
  82.             if (treeView1.SelectedNode.Name.Equals(treeView1.Nodes["Main"].Name))   // Here Main is ur Parent Node Name
  83.             {
  84.                 if (treeView1.SelectedNode.IsExpanded == true)
  85.                 {
  86.                     groupBox1.Visible = true;
  87.                     groupBox1.Enabled = true;
  88.                 }
  89.             }
  90.         }
  91.         private void button1_Click(object sender, EventArgs e)
  92.         {
  93.  
  94.         }
  95.  
  96.         private void button2_Click(object sender, EventArgs e)
  97.         {
  98.  
  99.         }
  100.  
  101.         private void View_Log_File_Click(object sender, EventArgs e)
  102.         {
  103.  
  104.         }
  105.  
  106.         private void SendLogFile_Click(object sender, EventArgs e)
  107.         {
  108.  
  109.         }
  110.  
  111.         private void button8_Click(object sender, EventArgs e)
  112.         {
  113.  
  114.         }
  115.  
  116.         private void EnableVoices_CheckedChanged(object sender, EventArgs e)
  117.         {
  118.             if (EnableVoices.Checked == true)
  119.             {
  120.                 voices_on_off = true;
  121.                 speaker.Dispose();
  122.                 speaker = new SpeechSynthesizer();
  123.                 EnableVoices.Text = "Voices Are Now Enabled";
  124.                 speaker.Rate = -2;
  125.                 speaker.Volume = 100;
  126.                 speaker.SpeakAsync("Voices are now enabled");
  127.             }
  128.             else
  129.             {
  130.  
  131.                 this.Invoke((MethodInvoker)delegate
  132.                 {
  133.                     voices_on_off = false;
  134.                     EnableVoices.Text = "Voices Are Now Disabled";
  135.                     speaker.Dispose();
  136.                     speaker = new SpeechSynthesizer();
  137.                     speaker.SpeakAsync("voices Are Now Disabled");
  138.                 });
  139.             }
  140.             setting_file.SetKey("Voices", EnableVoices.Checked.ToString());
  141.         }
  142.  
  143.  
  144.     }
  145. }
  146.  

In the form1 class level i did : SettingsMenu settingsmenu;

And in the constructor of form1 i did:
settingsmenu = new SettingsMenu();

And here is a sample line im using in my Form1 to hear the voices when cheking in the checkbox on the new form:

Expand|Select|Wrap|Line Numbers
  1. if (settingsmenu.voices_on_off == true)
  2.                     {
  3.                         settingsmenu.speaker.SpeakAsync("Download started");
  4.                     }
  5.                     else
  6.                     {
  7.                     }
  8.  

In the new form the line setting_file.Se tKey("Voices", EnableVoices.Ch ecked.ToString( )); is where i set the key in my settings txt file so it will rmember if the checkbox checked or not. And in the new form constructor i call for this key: string key = setting_file.Ge tKey("Voices");

My problem is in runtime to take effect on the form1 changes if i check in the checkbox in the new form ill hear the voices from Form1 for example if ill click the start download button. And if i uncheck the checkbox in the new form so when i click the start download button i will not hear anything.

For now in runtime its taking effect only on the changes i did in the new form.
I tried to use the flag in the new form:

public bool voices_on_off;

But i used then a breakpoint in form1 for example on the start download button here:

if (settingsmenu.v oices_on_off == true)

But it never stoped. I checked the checkbox many times in the new form in runtime and it didnt get to the breakpoint.


Thanks for help.
Feb 4 '11 #1
0 1355

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1632
by: Laurent | last post by:
I have got a three state checkbox, where i would like to apply a readonly properties in order to keepthe three state view (Check and Blank, Unchecked and Blank, Checked and shaded) when my control is locked. Further more i would like to know if it's possible, to change my checkBox color when when my control have a Enabled properties set to False. Thanks Laurent
3
8826
by: Roberto Castro | last post by:
Hello! I have been assigned for the first time an adp Access project and so far I have managed to make the changes needed for some requirements. However, I am struggling to find the place where the application changes the color of the background of a textbox. Here the explanation goes: This is a form bound to an SQL view. The detail section has several fields, one of them being a textbox of name "Type". I checked its
0
1411
by: Dan Neely | last post by:
Winform labels, buttons, etc don't respond to the normal/large/extra large font settings that can be specified in display properties. Is there an easy way to do an appwide detection+change at runtime for accescibility purposes? I realize the bigger fonts will make things "interesting" regarding layout in places, but if simply detecting and doing the font change is a major effort the other problem is a moot point.
0
1360
by: ABC | last post by:
How to make change one frame size (width) when I clicked a button on anothoer frame?
1
1864
by: scolivas | last post by:
I want to make a button that will open a specific file folder that contains some crystal reports. I don't want to pick a report ...just want to "lead the user to the folder" with just a click... can this be done?
10
3593
by: apparker | last post by:
I'm creating a new GUI for a program and it is for a medical exam. There are so many different things to ask someone during a history it wastes too much space to make checkboxes for everything so I had an idea: Can I simply create a list of conditions and when the doctor clicks them, they turn red? And clicking them again would make them default again? This would really make the exam better since the doctor could quickly glance at a...
3
3311
by: paoparaopao | last post by:
Hi, I am creating a new screen in a GUI. Can someone help me how can I make a checkbox look like it is enabled? For example, I use this code EUAMIndCheckBox.setEditable(false); and the checkbox appears to be blur. I know the reason is that to inform the user that it is not editable. But I want it to look like it is enabled but it is not. Hope someone can help me about this. Thanks.
26
2083
by: Protoman | last post by:
I've written this program that simulates a 36 character, 10 rotor reciprocal rotor cipher, w/ a plugboard. Any way I can make the plugboard function more compact and/or be able to change the mapping at runtime? char Enigma::plugboard(char Char) { if(Char=='A') return '0'; else if(Char=='B')
2
1150
by: marius4674 | last post by:
I want to use a combobox to change a checkbox but the combobox take information from a table 1 and checkbox from table 2. How do I specify for the specific Combobox.Value to change the checkbox.value. How do I declare tables to use data
2
12401
by: dangerouskicker | last post by:
dear friends any one can guide me or help, How i can change checkbox and radio button color change with java script regards devang
0
10136
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9925
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.