c#-winform-dialog Box control

Source: Internet
Author: User

dialog box controls

Set the click button to pop up the dialog box control

1. ColorDialog-Color dialog box

Receive the information that determines the return

========================================================

2. FontDialog-Font dialog box

Receive determines the value returned

FontDialog has a Showcolor property, default is False, click to True, you can choose the font color

Receive Font Color

(Lee Brainstorming Lxc)

===========================================================

3. FolderBrowserDialog-Provide user select folder

The smallest option is still the folder, which returns the path to the selected folder

==============================================

4. Openfaildialog-Open dialog box

Show returns the file path

How do I actually open the selected text? -- Stream IO-pipeline file with binary walk (Li brainstorming lxc)

Refer to namespace IO First, using read stream StreamReader

Create read stream parameter one is the path, parameter two is the encoding method (Li brainstorming lxc)

Read the data under the path, read from the beginning to the end, and receive by RichTextBox (Lee brainstorming Lxc)

===========================================

5. SaveFileDialog-Save dialog box

The value returned by show is the file path

How do I actually save the text? --Stream IO-pipeline file with binary walk (Li brainstorming lxc)

Reference the namespace IO first, using the output stream Streamwriet

Create output stream parameter is path

Output content, and execution (Li brainstorming lxc)


=======================================================

Open and save there is a small loophole, if only the text document, then open and save only the. txt type, how to set?

Open the Settings type openfiledialog.filter= "text file |*.txt"; (Lee brainstorming Lxc)

Save settings Type savefiledialog.filter= "text file |*.txt| Word|*.doc ";

Save settings Default file name savafiledialog.filename= "new text document";

c#-winform-dialog Box control

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.