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

Bài giảng Lập trình C# 2010: Chương 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. | 1 ColorDialog How to use ColorDialog? pnColor btnColor 2 private void btnColor_Click (object sender, EventArgs e) { ColorDialog cldlg= new ColorDialog(); = ; if(()==) = ; } 3 If you want to set color by the RED, GREEN, BLUE. Please see figure below: pnColor trackBarRed txtRed trackBarBlue txtBlue trackBarGreen txtGreen 4 For each trackbar, please set properties as the same figure 5 private void setColor(){ int nRed = ; int nGreen = ; int nBlue = ; = nRed+""; = nBlue + ""; = nGreen+""; = (nRed, nGreen,nBlue); } 6 Create Event or trackbar control private void processTrackBar (object sender, EventArgs e) { setColor(); } 7 private void frmColorDialog_Load (object sender, EventArgs e) { += processTrackBar; += processTrackBar; += processTrackBar; setColor(); } 8 Name Description Maximum The Maximum property sets the value of the track bar when the slider is all the way to the right Minimum 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 9 Name Description LargeChange 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 10 FontDialog lblFont How to use FontDialog? btnFont 11 private void btnFont_Click (object sender, EventArgs e) { FontDialog ftDialog = new FontDialog(); = ; if (() == ) { = ; } } 12 RichTextBox & StreamFile 13 OpenFileDialog openDlg = new OpenFileDialog(); = "(*.txt)|*.txt|(All)|*.*"; if (() == ) { (, ); } 14 You could choose StreamType 15 But We could use StreamFile to read Data. You should Know this 16 Add this command at the top File using ; if (() == ) { //Open to read Stream stream = (); StreamReader reader = new StreamReader(stream); = (); (); } 17 RichTextBox & StreamFile 18 SaveFileDialog saveDlg = new SaveFileDialog(); = "(*.txt)|*.txt|(All)|*.*"; if (() == ) { (); } 19 if (() == ) { Stream stream = ();//Open to Write StreamWriter writer = new StreamWriter(stream); (); (); } Use StreamFile to Write Data. 20 END 21

TỪ KHÓA LIÊN QUAN