+ All Categories
Home > Documents > Dialog Controls

Dialog Controls

Date post: 06-Feb-2016
Category:
Upload: nadikattu-ravikishore
View: 219 times
Download: 0 times
Share this document with a friend
Description:
DIALOG CONTROLS.ppt
32
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
Transcript
Page 1: Dialog Controls

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

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

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

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

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

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

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

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

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

Method with all Dialog Controls

• Show Dialog():this method is used to display the dialog control to the user.

Page 11: Dialog Controls

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

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

#region mnunew_Click private void mnunew_Click(object sender, EventArgs e) { textBox1.Text = "";

} #endregion

Page 14: Dialog Controls

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

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

Code for mnusave_Click

#region mnusave_Click private void mnusave_Click(object sender,

EventArgs e) { SaveFile();

}

Page 17: Dialog Controls

Code for mnuquit_Click

#region mnuquit_Click private void mnuquit_Click(object sender,

EventArgs e) { Application.Exit(); }

Page 18: Dialog Controls

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

mnuprintdialog_Click

#region mnuprintdialog_Click private void mnuprintdialog_Click(object

sender, EventArgs e) { printDialog1.ShowDialog(); }

#endregion

Page 20: Dialog Controls
Page 21: Dialog Controls

Code for mnucut_Click

#region mnucut_Click private void mnucut_Click(object sender,

EventArgs e) { textBox1.Cut(); }

Page 22: Dialog Controls

Code for mnucopy_Click

#region mnucopy_Click private void mnucopy_Click(object sender,

EventArgs e) { textBox1.Copy(); } #endregion

Page 23: Dialog Controls

Code for mnupaste_Click

#region mnupaste_Click private void mnupaste_Click(object

sender, EventArgs e) { textBox1.Paste(); } #endregion

Page 24: Dialog Controls

Code for mnuselectall_Click

• #region mnuselectall_Click private void mnuselectall_Click(object

sender, EventArgs e) { textBox1.SelectAll(); }

Page 25: Dialog Controls

Code for mnuundo_Click

#region mnuundo_Click private void mnuundo_Click(object sender,

EventArgs e) { textBox1.Undo(); }

Page 26: Dialog Controls

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

mnuclose_Click

#region mnuclose_Click private void mnuclose_Click(object sender,

EventArgs e) { this.Close(); } #endregion

Page 28: Dialog Controls
Page 29: Dialog Controls

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

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

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

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…


Recommended