dialog controls
DESCRIPTION
DIALOG CONTROLS.pptTRANSCRIPT
![Page 1: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/1.jpg)
DIALOG CONTROLS•These controls are used to perform opening a file saving afile,applying font, color attributes,perform page settings and printer settings etc……•Different Types of Dialog Controls•OpenFileDialog Control•SaveFileDialog Control•Font Dialog Control•Color Dialog Control•PageSetupDialog Control•Print Dialog Control
![Page 2: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/2.jpg)
OpenFileDialog Control
• This control is used to display open file dialog box to the user so that user can select any file to Open.• This control is available in using
System.Windows.Forms.OpenFiledialogBox
![Page 3: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/3.jpg)
Properties of Open File DialogS.No PROPERTIES DESCRIPTION
1. DefaultExt This is the DefaultExt for opening Files. it is used wild card technique for filtering file names .if the value of DefaultExt is *.doc here files with extension doc will open Open File Dialog.
2. FileName This property is used to store Name of the file i.e. selected by the user.
3. Filter This property is used to filter the files like text files, word files ,excel files all files etc…
4. Dialog Result It shows whet ether user has selected the OK or cancel button to the close Dialog box
![Page 4: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/4.jpg)
SaveFileDialog Control
• This control is used to display Save file dialog box to the user so that user can save any filename.
• This control is available in using System.Windows.Forms.SaveFileDialogBox
![Page 5: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/5.jpg)
Properties of Save File DialogS.No PROPERTIES DESCRIPTION
1. FileName This property is used to store Name of the file i.e. selected by the user.
2. Filter This property is used to filter the files like text files, word files ,excel files all files etc…
![Page 6: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/6.jpg)
Font Dialog BoxControl• This control is used to display font dialog box to
the user so that user can select required font • Properties:• Font: this property is used to store the Font
attributes selected by the user within the dialog control
• Max Size:which is used to set the max font size.• Min Size:which is used to set the min font size.• Show Affects: user can access the Show affects
option within the Font dialog control
![Page 7: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/7.jpg)
Color Dialog Control
• This control is used to display Color Dialog Box to the user so that user can select required Color.
• Properties:• Color:this property stores the color value
whenever any color selected by the user• FullOpen :when set true color dialog will open
in full mode other wise it will open in partial mode.
![Page 8: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/8.jpg)
PAGE SETUP DIALOG CONTROLS• This control is used to display Pagesetup
Dialog Box to the user so that user can perform page settings to the required user.
• Properties :this property is used to set the print document for the user which would like to perform page settings.
![Page 9: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/9.jpg)
PRINT DIALOG CONTROLS
• This control is used to display pagesetup dialog box to the user so that user can perform page settings to the document.
• Properties:• Document: this property is used to set the
print document name for which user will select printer settings to the printout.
![Page 10: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/10.jpg)
Method with all Dialog Controls
• Show Dialog():this method is used to display the dialog control to the user.
![Page 11: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/11.jpg)
Working with Menus • Menu control will display on the top of the
application• Main menu is represented in .net by System.
Windows .Forms.MainMenu Class• Drag and drop menu control in the toolbox
![Page 12: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/12.jpg)
Code for Private SaveFile Method #region Private SaveFile Method private bool SaveFile() { string fname; DialogResult res = saveFileDialog1.ShowDialog(); fname = saveFileDialog1.FileName; StreamWriter fsave = new StreamWriter(fname); fsave.WriteLine(textBox1.Text); fsave.Flush(); fsave.Close(); this.Text = fname; // saveChek = false; textBox1.Clear(); return true;
} #endregion
![Page 13: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/13.jpg)
#region mnunew_Click private void mnunew_Click(object sender, EventArgs e) { textBox1.Text = "";
} #endregion
![Page 14: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/14.jpg)
Code for mnuopen_Click #region mnuopen_Click private void mnuopen_Click(object sender, EventArgs e) { // textBox1.Text = ""; // openFileDialog1.ShowDialog(); //MessageBox.Show(openFileDialog1.FileName); // StreamReader sr = new StreamReader(openFileDialog1.FileName); // string s = sr.ReadToEnd(); // textBox1.Text = s;
openFileDialog1.InitialDirectory = Environment.SpecialFolder.Programs.ToString(); openFileDialog1.Filter = "textfiles *.txt|*.txt"; if (openFileDialog1.ShowDialog() == DialogResult.OK)
using (StreamReader t = new StreamReader(openFileDialog1.FileName)) { textBox1.Text = t.ReadToEnd(); }
} #endregion
![Page 15: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/15.jpg)
Private SaveFile Method#region Private SaveFile Method private bool SaveFile() { string fname; DialogResult res = saveFileDialog1.ShowDialog(); fname = saveFileDialog1.FileName; StreamWriter fsave = new StreamWriter(fname); fsave.WriteLine(textBox1.Text); fsave.Flush(); fsave.Close(); this.Text = fname; // saveChek = false; textBox1.Clear(); return true;
} #endregion
![Page 16: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/16.jpg)
Code for mnusave_Click
#region mnusave_Click private void mnusave_Click(object sender,
EventArgs e) { SaveFile();
}
![Page 17: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/17.jpg)
Code for mnuquit_Click
#region mnuquit_Click private void mnuquit_Click(object sender,
EventArgs e) { Application.Exit(); }
![Page 18: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/18.jpg)
mnupagesetup_Click
#region mnupagesetup_Click private void mnupagesetup_Click(object
sender, EventArgs e) { PageSettings pg =new PageSettings(); pageSetupDialog1.PageSettings= pg; pageSetupDialog1.ShowDialog(); }
![Page 19: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/19.jpg)
mnuprintdialog_Click
#region mnuprintdialog_Click private void mnuprintdialog_Click(object
sender, EventArgs e) { printDialog1.ShowDialog(); }
#endregion
![Page 20: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/20.jpg)
![Page 21: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/21.jpg)
Code for mnucut_Click
#region mnucut_Click private void mnucut_Click(object sender,
EventArgs e) { textBox1.Cut(); }
![Page 22: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/22.jpg)
Code for mnucopy_Click
#region mnucopy_Click private void mnucopy_Click(object sender,
EventArgs e) { textBox1.Copy(); } #endregion
![Page 23: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/23.jpg)
Code for mnupaste_Click
#region mnupaste_Click private void mnupaste_Click(object
sender, EventArgs e) { textBox1.Paste(); } #endregion
![Page 24: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/24.jpg)
Code for mnuselectall_Click
• #region mnuselectall_Click private void mnuselectall_Click(object
sender, EventArgs e) { textBox1.SelectAll(); }
![Page 25: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/25.jpg)
Code for mnuundo_Click
#region mnuundo_Click private void mnuundo_Click(object sender,
EventArgs e) { textBox1.Undo(); }
![Page 26: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/26.jpg)
mnuaboutus_Click
Take a new form about.cs#region mnuaboutus_Click private void mnuaboutus_Click(object sender,
EventArgs e) { About abt = new About(); abt.Show(); this.Hide(); } #endregion
![Page 27: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/27.jpg)
mnuclose_Click
#region mnuclose_Click private void mnuclose_Click(object sender,
EventArgs e) { this.Close(); } #endregion
![Page 28: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/28.jpg)
![Page 29: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/29.jpg)
code for mnufont_Click
#region mnufont_Click private void mnufont_Click(object sender,
EventArgs e) { fontDialog1.ShowDialog(); textBox1.Font = fontDialog1.Font; } #endregion
![Page 30: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/30.jpg)
mnucolordialog_Click #region mnucolordialog_Click private void mnucolordialog_Click(object sender,
EventArgs e) { colorDialog1.ShowDialog(); //textBox1.ForeColor = colorDialog1.Color;
}
Drag and Drop Tool Strip
![Page 31: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/31.jpg)
Form1_Closingprivate void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e) {if (textBox1.Text != strMyOriginalText) {if(MessageBox.Show("Do you want to save
changes to your text?", "My Application", MessageBoxButtons.YesNo) == DialogResult.Yes)
{e.Cancel = true; } } }
![Page 32: Dialog Controls](https://reader034.vdocuments.us/reader034/viewer/2022051402/55cf8ce85503462b13906e3b/html5/thumbnails/32.jpg)
MDI APPLICATION
• The applications that we allow the user to work with more than one files or documents at once are known as MDI applications
• Ex :MsEcel,Msword,MsPowerPoint etc…