Danh mục

Bài giảng Lập trình C# 2010: Chương 2.3 - ĐH Công nghệ Đồng Nai

Số trang: 21      Loại file: pptx      Dung lượng: 1.13 MB      Lượt xem: 13      Lượt tải: 0    
Hoai.2512

Xem trước 3 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Bài giảng Lập trình C# 2010: Chương 2.3 trình bày cách thức thực hiện, câu lệnh, nút lệnh và tính năng của các nút lệnh cùng một số nội dung khác về Windows Forms and Windows Forms Controls.
Nội dung trích xuất từ tài liệu:
Bài giảng Lập trình C# 2010: Chương 2.3 - ĐH Công nghệ Đồng NaiDONG NAI UNIVERSITY OF TECHNOLOGY DONG NAI UNIVERSITY OF TECHNOLOGYColorDialog pnColor How to use btnColo ColorDialog r ? DONG NAI UNIVERSITY OF TECHNOLOGYprivate void btnColor_Click(object sender, EventArgs e){ColorDialog cldlg= newColorDialog();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: pnColo rtrackBarRedtxtRedtrackBarGreentxtGreentrackBarBluetxtBlue DONG NAI UNIVERSITY OF TECHNOLOGYFor eachtrackbar,please setpropertiesas thesame figure DONG NAI UNIVERSITY OF TECHNOLOGYprivate 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 TECHNOLOGYCreate Event or trackbarcontrolprivate void processTrackBar(object sender, EventArgs e) { setColor(); } DONG NAI UNIVERSITY OF TECHNOLOGYprivate voidfrmColorDialog_Load(object sender, EventArgs e){ trackBarBlue.Scroll += processTrackBar; trackBarGreen.Scroll += processTrackBar; trackBarRed.Scroll += processTrackBar; setColor();} DONG NAI UNIVERSITY OF TECHNOLOGY Name DescriptionMaximum The Maximum property sets the value of the track bar when the slider is all the way to the rightMinimum Gets or sets the lower limit of the range this TrackBar is working with.Value 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 DescriptionLargeChang Sets how many positions toe move if the bar is clicked on either side of the sliderSmallChang sets how many positions toe move if the keyboard arrows are used to move the sliderTickFrequen Establishes how many positionscy are between each tick-mark DONG NAI UNIVERSITY OF TECHNOLOGYFontDialog lblFon t How to use btnFont FontDialog ?private void btnFont_Click DONG NAI UNIVERSITY OF TECHNOLOGY(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 TECHNOLOGYRichTextBox &StreamFile DONG NAI UNIVERSITY OF TECHNOLOGYOpenFileDialog openDlg = newOpenFileDialog();openDlg.Filter = (*.txt)|*.txt|(All)|*.*;if (openDlg.ShowDialog() ==DialogResult.OK){rtFile.LoadFile(openDlg.FileName,RichTextBoxStreamType.PlainText);} DONG NAI UNIVERSITY OF TECHNOLOGYYou could chooseStreamType DONG NAI UNIVERSITY OF TECHNOLOGYBut We could use StreamFileto read Data.You should Know this DONG NAI UNIVERSITY OF TECHNOLOGYAdd this command at the top Fileusing System.IO;if (openDlg.ShowDialog() ==DialogResult.OK) { //Open to readStream stream =openDlg.OpenFile();StreamReader reader = newStreamReader(stream);richTxtFile.Text =reader.ReadToEnd();reader.Close(); DONG NAI UNIVERSITY OF TECHNOLOGYRichTextBox &StreamFile DONG NAI UNIVERSITY OF TECHNOLOGYSaveFileDialog saveDlg = newSaveFileDialog();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 TECHNOLOGYif (saveDlg.ShowDialog() ==DialogResult.OK){Stream stream =saveDlg.OpenFile();//Open toWriteStreamWriter writer = newStreamWriter(stream);writer.WriteLine(rtFile.Text);writer.Close();

Tài liệu được xem nhiều: