thiết kế các Ứng dụng gui bằng windows forms
TRANSCRIPT
-
7/24/2019 Thit K Cc ng Dng GUI Bng Windows Forms
1/14
Thi9% k9 c,c g dDg GUI
b8g Wid!($ F!#m$Bw:N>j %>^ A
NhHg i:& khi; khg h? %#
$+> T + i T[y- .NE% C+-= F;+@; s =;y.
? CheckedListBox
? ColorDialog
? ErrorProvider
? FontDialog
? GroupBox
? HelpProvider
? LinkLabel
? NotificationBubble
? NotifyIcon
? All Print controls
? RichTextBox
? Splitter
NhHg h-m .NET C!m"ac% F#ame(!#k khg h? %#
D+
-
7/24/2019 Thit K Cc ng Dng GUI Bng Windows Forms
2/14
? AcceptButton
? CancelButton
? AutoScroll
? Anchor
? G+ k T+ = k> (MDI)
? KeyPreview
? TabIndex
? TabStop
? K =]
? %^= -] -- ] U ^
? C- Th> i Hosting ActiveX
Thi9% k9 F!#m %# Vi$&al S%&di! .NET
%g= g F; c '+ $=> .NE% - -O =+ =g= g + k } z
=;- >+ c -- =] -- Th> i. B\ - =i Th> -l m =;J -- Th> i,=g= a -- =>t- =J = >+ -+ t- =J, =\ -- i.
Ca $> %hi9% k9 F!#m$
K -O =+ =\ t= $+;= D- E= -{+ . H 2.1 T[+ Tg - -O =+F; D D i, Th> i - +, p [ Th> i M+M>, Th> i ContextMenu,Th> i Timer, - h>Th> i -.
%g= g -- } z G&I c @< F; =; =- k g> ; -{+ \ -}+ Tt= Th> i `. %; .NET Compact FrameworkTh m -- -+ p. 'J z, g> t= + T[y- Te= =; ; + T -}+t= Th> i, + T i u T[y-= +.
Ca $> T!!lB!)
C+ i -{+ .NE% C+-= F;+@; -O =+ - =i = } z. Vi = t= Th> i } z O- =g=g ;^= j [ t= Th> i =~ ToolBox =] F;< -{+ } z =;-+
-
7/24/2019 Thit K Cc ng Dng GUI Bng Windows Forms
4/14
Ca !9 ToolBo& cho d )n SDE Pocke" PC.
Ca $> %h&@c %/h
C+ t- =J -}+ T =^= -] -- =>t- =J >- -{+ Th> i T+ + -n=; -+ i c-- T[+ =;m Th> i TextBox -\ -- = =>t- =J. Ng> =>t- =J- u \
pT[y- i =m -\ = =>t- =JT. Ng> =;m -{+ =>t- =J t= =a y -- Tp =[y e- t= Tp =[y }- =\,- =i Te- =J T w -\ = =>t- =J. Cn Te- =J T i TextBox T[y- -n.
Ca !9 Pope"ie! c?a m;" i6# khi7n Te&"Bo&
%g= g -- } z G&I c @< F; - s h =].
N: %6g Wid!($ CE .NET
D @< CE .NE% p [ -- } z @ .NE% F;+@; T_T{. %;[u- =, O= , O= +, O= -^= k =; t Th> i-{+ } z [ -O =+ k- =; Tp =[y F; .NE% F;+@; T_ T{. C-O= - [ =; t- =J ControlBox-{+ F; +t- =J MinimizeBox MaximizeBox= + .NE% -}+ T t= Th> i InputPanel.%; s !-= !C Th> i - -O =+ =[Z =- u $I!. InputPanel- -O =+ \ >p $I!. InputPanel i MainMenuy k - Th>
i I>=!+ T[y- = =; F;. Ng> - Th> i MainMenu=;F;, T t= \ k
-
7/24/2019 Thit K Cc ng Dng GUI Bng Windows Forms
6/14
L-m 'i i -l -}+ T h> ^= t= O=, t= O= ,
, e- O= - i - =i -}+T O= , O= +, O= - ic =>t- =J MinimizeBox MaximizeBox. B] 2.1 =] =;m m =;J -{+MinimizeBox ] [w -{+ s h =]. B] 2.3
%g= g -- } z G&I c @< F; i - [v P - =i a k> T_> - }. Vh> iTextBox s =;y =>t- =J BackColor ForeColor, p [ _>g= -- Th> i - =; .NE% C+-= F;+@;. $ k C- s=;y, [ - s =;y -- t- =JPasswordCharT[y- s =;y.
3i:& khi; Label
Vh> i - -O =+ i =m U ] =u [v t- =J %=-{+ Th> i - Tm U d
-
7/24/2019 Thit K Cc ng Dng GUI Bng Windows Forms
9/14
3i:& khi; Radi!B&%%!
NO= Th> i #+ T[+ =u [v .
K t= O= ;+ =; t= T[y- -n, -- O= -
-
7/24/2019 Thit K Cc ng Dng GUI Bng Windows Forms
10/14
3i:& khi; CheckB!)
Vh> i CheckBoxp [ Th> i RadioButton. Vh> i T[+ Tg- [v i CheckBox- =i- h> + -n =; -P t= O-, =; Th> i RadioButton+ -n
\ =;~.Vh> i CheckBox-> -^ =>t- =J CheckState, - T Th> i T[y- -n. %>t- =J CheckState=- -^= t= ] k= . % _ -{+ Unchecked, Checked, Indeterminate. %;\ = Indeterminate-l - =i [y- t- =J ThreeState-{+ Th> i CheckBoxT[y-=g= a =;>. K CheckState Indeterminate =>t- =J ThreeState =;>, Th> i T[y- + = >. C W+ =;\ = -n =ii i ] =u [v =; =>t- =J AutoCheckT[y- =g= a false. K =>t- =J AutoCheck
T[y- =g= a true, T - =i ^ -n =; Th> i.
| z Apples.exe t= J z - TZ ] - Tm \ = [v i CheckBox =; -P - QI + iCheckBox - - -P u \ = - +> t= =;\ = v v -Tg CheckBox- QI +
-
7/24/2019 Thit K Cc ng Dng GUI Bng Windows Forms
11/14
3i:& khi; C!mb!B!)
Vh> i ComboBox Th> i =i k t= + i TextBox -P u t=X = =+ ]. Mt= + p [u Th> i [v t- =J I=< =; -+ t- =J.N i ComboBoxO- =- =. Vh> - =i = c + --:
C,ch1: Gn [Z =}- A =; =>t- =J =a y Items -{+ Th> iComboBox. C- z- - =i \ o = >+ [Z =} # =; =a y I=s Th> i ComboBox- = comboBox1
comboBox1.Items.Add("Hi"); comboBox1.Items.Add("Howdy");
comboBox1.Items.Add("Wuz Up");
%g= g -- } z G&I c @< F;t- Th>i u t= Tp =[y =a y. Vh> T[y- = c -- =g= aDataSourceu t= Tp =[y =a y. K ComboBox-p b = t= z- + t- =J
DisplayName-{+ Th> i
ComboBox. ComboBoxt- =J ; k=
=; =>t- =J DisplayName = ->s =;] h + 0) ?
string.Format(FullNameWithInitial, m_First, m_Middle[0],
m_Last) : string.Format(FullNameNoInitial, m_First,
m_Last); } } } private void LoadCustomers() { if(customers
!= null) return; customers = new Customer[6]; customers[0]
= new Customer("Ronnie", "Donnell", "Yates"); customers[1]
= new Customer("Moya", "Alicia", "Hines"); customers[2] =new Customer("Veronica", "Christine", "Yates");
customers[3] = new Customer("Diane", "", "Taylor");
customers[4] = new Customer("Kindell", "Elisha", "Yates");
customers[5] = new Customer("Zion", "Donnell", "Yates");
this.comboBox1.DataSource = customers;
this.comboBox1.DisplayMember = "FullName"; }
C + -- Ti ^ z- T+ T[y- -n =; Th> i ComboBox. %} ^=, =>t-
=J SelectedIndex=;] h -l
i ComboBox. V\ \ =>t- =J SelectIndex:
string selItem =
comboBox1.Items[comboBox1.SelectedIndex].ToString();
%g= g -- } z G&I c @< F; i ComboBox -> -^ =>t- =J SelectedItem, =>t- =J =;] h t==+ -g> Tg z- T+ -n. Mt= -O =+ - =i =+ -g> Tg z- T+ -n,-O =+ -_ ] T[+ -l
t- =J Items. V\ =] -- t- =J SelectedItem:
string selItem = comboBox1.SelectedItem.ToString();
3i:& khi; Li$%B!)
ListBox Y -n - [v t- =J -- [Z =}- p +>. B+ q=>t- =J =a y Items -- =[Z =}- Add, Remove, Clear =; =>t-=J Items. 'J z, T\ = ->s Th> i ListBox O- =g= g.
listBox1.Items.Add("Hi"); listBox1.Items.Add("Howdy");
listBox1.Items.Add("Wuz Up");
CO =+ - =i = Th> i ListBoxO- =- = c -- b ListBoxu t= =a y. %; > =; b t= Th> i ListBoxp u > =;=; Th> i ComboBox. %;[u- =, =g= a DataSourceu t= =a y. $+>T, =g= a =>t- =J DisplayMemberu t= z- =; >q k>, z- s.
private void LoadCustomers() { if(customers != null)
return; customers = new Customer[6]; customers[0] = new
Customer("Ronnie", "Donnell", "Yates"); customers[1] = new
Customer("Moya", "Alicia", "Hines"); customers[2] = new
Customer("Veronica", "Christine", "Yates"); customers[3] =
new Customer("Diane", "", "Taylor"); customers[4] = new
Customer("Kindell", "Elisha", "Yates"); customers[5] = new
Customer("Zion", "Donnell", "Yates");
this.listBox1.DataSource = customers;
this.listBox1.DisplayMember = "FullName"; }
C,c i:& khi; kh,c
? NumericUpDown
? DomainUpDown
%g= g -- } z G&I c @< F;