visual studio 2015
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click 'Set the Save dialog properties With SaveFileDialog1 .DefaultExt = 'txt' .FileName = strFileName .Filter = 'Text Documents (*.txt)|*.txt|All Files (*.*)|*.*' .FilterIndex = 1 .OverwritePrompt = True .Title = 'Demo Save File Dialog' End With 'Show the Save dialog and if the user clicks the Save button, 'save the file If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then Try 'Save the file path and name strFileName = SaveFileDialog1.FileName My.Computer.FileSystem.WriteAllText(strFileName, txtFile.Text, False) Catch ex As Exception MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End IfEnd Sub
Property DESCRIPTIONAllowScriptChange Indicates whether the user can change the character set specified in the Script drop-down box to display a character set other than the one currently displayedColor Indicates the selected font colorFont Indicates the selected fontFontMustExist Indicates whether the dialog specifies an error condition if the user attempts to enter a font or style that does not existMaxSize Indicates the maximum size (in points) a user can selectMinSize Indicates the minimum size (in points) a user can selectShowApply Indicates whether the dialog contains an Apply buttonShowColor Indicates whether the dialog displays the color choiceShowEffects Indicates whether the dialog contains controls that allow the user to specify strikethrough, underline, and text color optionsShowHelp Indicates whether the dialog displays a Help button
You will be using only one method (ShowDialog) of FontDialog in the following. Other methods available include Reset, which enables you to reset all the properties to their default values.FontDialog1.ShowColor = TrueFontDialog1.ShowDialog()
Property DESCRIPTIONAllowFullOpen Indicates whether users can use the dialog to define custom colorsAnyColor Indicates whether the dialog displays all available colors in the set of basic colorsColor Indicates the color selected by the userCustomColors Indicates the set of custom colors shown in the dialogFullOpen Indicates whether the controls used to create custom colors are visible when the dialog is openedShowHelp Indicates whether a Help button appears in the dialogSolidColorOnly Indicates whether the dialog will restrict users to selecting solid colors only
Private Sub btnColor_Click(sender As Object, e As EventArgs) Handles btnColor.Click 'Show the Color dialog and if the user clicks the OK button, 'update the background color of the form If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then Me.BackColor = ColorDialog1.Color End IfEnd Sub