Bài giảng lập trình c 2010 chương 2 3 đh công nghệ đồng nai

21 268 0
Bài giảng lập trình c 2010  chương 2 3   đh công nghệ đồng nai

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

DONG NAI UNIVERSITY OF TECHNOLOGY DONG NAI UNIVERSITY OF TECHNOLOGY ColorDialog pnColor btnColor How to use ColorDialog? DONG NAI UNIVERSITY OF TECHNOLOGY private void btnColor_Click (object sender, EventArgs e) { ColorDialog cldlg= new ColorDialog(); cldlg.Color = pnColor.BackColor; if(cldlg.ShowDialog()==DialogResult.OK) pnColor.BackColor = cldlg.Color; } DONG NAI UNIVERSITY OF TECHNOLOGY If you want to set color by the RED, GREEN, BLUE Please see figure below: pnColor trackBarRed txtRed trackBarGreen txtGreen trackBarBlue txtBlue DONG NAI UNIVERSITY OF TECHNOLOGY For each trackbar, please set properties as the same figure DONG NAI UNIVERSITY OF TECHNOLOGY private void setColor(){ int nRed = trackBarRed.Value; int nGreen = trackBarGreen.Value; int nBlue = trackBarBlue.Value; txtRed.Text = nRed+""; txtBlue.Text = nBlue + ""; txtGreen.Text = nGreen+""; pnColor.BackColor = Color.FromArgb(nRed, nGreen,nBlue); } DONG NAI UNIVERSITY OF TECHNOLOGY Create Event or trackbar control private void processTrackBar (object sender, EventArgs e) { setColor(); } DONG NAI UNIVERSITY OF TECHNOLOGY private void frmColorDialog_Load (object sender, EventArgs e) { trackBarBlue.Scroll += processTrackBar; trackBarGreen.Scroll += processTrackBar; trackBarRed.Scroll += processTrackBar; setColor(); } DONG NAI UNIVERSITY OF TECHNOLOGY Name Maximum Minimum Value Description The Maximum property sets the value of the track bar when the slider is all the way to the right Gets or sets the lower limit of the range this TrackBar is working with Gets or sets a numeric value that represents the current position of the scroll box on the track bar DONG NAI UNIVERSITY OF TECHNOLOGY Name LargeChange Description Sets how many positions to move if the bar is clicked on either side of the slider SmallChange sets how many positions to move if the keyboard arrows are used to move the slider TickFrequency Establishes how many positions are between each tick-mark DONG NAI UNIVERSITY OF TECHNOLOGY FontDialog lblFont btnFont How to use FontDialog? private void btnFont_Click (object sender, EventArgs e) { FontDialog ftDialog = new FontDialog(); ftDialog.Font = lblFont.Font; if (ftDialog.ShowDialog() == DialogResult.OK) { lblFont.Font = ftDialog.Font; } } DONG NAI UNIVERSITY OF TECHNOLOGY DONG NAI UNIVERSITY OF TECHNOLOGY RichTextBox & StreamFile DONG NAI UNIVERSITY OF TECHNOLOGY OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Filter = "(*.txt)|*.txt| (All)|*.*"; if (openDlg.ShowDialog() == DialogResult.OK) { rtFile.LoadFile(openDlg.FileName, RichTextBoxStreamType.PlainText); } DONG NAI UNIVERSITY OF TECHNOLOGY You could choose StreamType DONG NAI UNIVERSITY OF TECHNOLOGY But We could use StreamFile to read Data You should Know this DONG NAI UNIVERSITY OF TECHNOLOGY Add this command at the top File using System.IO; if (openDlg.ShowDialog() == DialogResult.OK) { //Open to read Stream stream = openDlg.OpenFile(); StreamReader reader = new StreamReader(stream); richTxtFile.Text = reader.ReadToEnd(); reader.Close(); } DONG NAI UNIVERSITY OF TECHNOLOGY RichTextBox & StreamFile DONG NAI UNIVERSITY OF TECHNOLOGY SaveFileDialog saveDlg = new SaveFileDialog(); saveDlg.Filter = "(*.txt)|*.txt| (All)|*.*"; if (saveDlg.ShowDialog() == DialogResult.OK) { rtFile.SaveFile(saveDlg.FileName, RichTextBoxStreamType.PlainText); } Use StreamFile to Write Data DONG NAI UNIVERSITY OF TECHNOLOGY if (saveDlg.ShowDialog() == DialogResult.OK) { Stream stream = saveDlg.OpenFile();//Open to Write StreamWriter writer = new StreamWriter(stream); writer.WriteLine(rtFile.Text); writer.Close(); } DONG NAI UNIVERSITY OF TECHNOLOGY END [...]...DONG NAI UNIVERSITY OF TECHNOLOGY FontDialog lblFont btnFont How to use FontDialog? private void btnFont_Click (object sender, EventArgs e) { FontDialog ftDialog = new FontDialog(); ftDialog.Font = lblFont.Font; if (ftDialog.ShowDialog() == DialogResult.OK) { lblFont.Font = ftDialog.Font; } } DONG NAI UNIVERSITY OF TECHNOLOGY DONG NAI UNIVERSITY OF TECHNOLOGY RichTextBox & StreamFile DONG NAI UNIVERSITY... UNIVERSITY OF TECHNOLOGY OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Filter = "(*.txt)|*.txt| (All)|*.*"; if (openDlg.ShowDialog() == DialogResult.OK) { rtFile.LoadFile(openDlg.FileName, RichTextBoxStreamType.PlainText); } DONG NAI UNIVERSITY OF TECHNOLOGY You could choose StreamType DONG NAI UNIVERSITY OF TECHNOLOGY But We could use StreamFile to read Data You should Know this DONG NAI UNIVERSITY... this DONG NAI UNIVERSITY OF TECHNOLOGY Add this command at the top File using System.IO; if (openDlg.ShowDialog() == DialogResult.OK) { //Open to read Stream stream = openDlg.OpenFile(); StreamReader reader = new StreamReader(stream); richTxtFile.Text = reader.ReadToEnd(); reader.Close(); } DONG NAI UNIVERSITY OF TECHNOLOGY RichTextBox & StreamFile DONG NAI UNIVERSITY OF TECHNOLOGY SaveFileDialog saveDlg... DialogResult.OK) { rtFile.SaveFile(saveDlg.FileName, RichTextBoxStreamType.PlainText); } Use StreamFile to Write Data DONG NAI UNIVERSITY OF TECHNOLOGY if (saveDlg.ShowDialog() == DialogResult.OK) { Stream stream = saveDlg.OpenFile();//Open to Write StreamWriter writer = new StreamWriter(stream); writer.WriteLine(rtFile.Text); writer.Close(); } DONG NAI UNIVERSITY OF TECHNOLOGY END ... cldlg= new ColorDialog(); cldlg.Color = pnColor.BackColor; if(cldlg.ShowDialog()==DialogResult.OK) pnColor.BackColor = cldlg.Color; } DONG NAI UNIVERSITY OF TECHNOLOGY If you want to set color by...DONG NAI UNIVERSITY OF TECHNOLOGY ColorDialog pnColor btnColor How to use ColorDialog? DONG NAI UNIVERSITY OF TECHNOLOGY private void btnColor_Click (object sender, EventArgs e) { ColorDialog cldlg=... DONG NAI UNIVERSITY OF TECHNOLOGY private void frmColorDialog_Load (object sender, EventArgs e) { trackBarBlue.Scroll += processTrackBar; trackBarGreen.Scroll += processTrackBar; trackBarRed.Scroll

Ngày đăng: 03/12/2015, 18:31

Từ khóa liên quan

Mục lục

  • Slide 1

  • Slide 2

  • Slide 3

  • Slide 4

  • Slide 5

  • Slide 6

  • Slide 7

  • Slide 8

  • Slide 9

  • Slide 10

  • Slide 11

  • Slide 12

  • Slide 13

  • Slide 14

  • Slide 15

  • Slide 16

  • Slide 17

  • Slide 18

  • Slide 19

  • Slide 20

Tài liệu cùng người dùng

Tài liệu liên quan