Sunteți pe pagina 1din 984

1.1.1.

Compile Visual codul surs de baz n linia de comand


VBC / R: System.dll / R: System.Windows.Forms.DLL / R: System.Drawing.DLL WinEvents.vb

1.1.2.How a compila si rula codul n acest tutorial

Du-te la: Start-> Programs-> Visual Studio.NET-> Visual Studio.NET Instrumente-> Visual Studio.N Command Prompt, i tipul: c: \ exemple> VBC example1.vb.

1.3.Simple programul Visual Basic.


Tester modul Sub Main () Console.WriteLine ( "Bine ati venit la Visual Basic!" ) End Sub 'Main End Module

1.1.4.Writing linie de text cu mai multe declaraii.


Tester modul Sub Main () Console.Write ( "Bine ati venit la" ) Console.WriteLine ( "Visual Basic!" ) End Sub 'Main End Module

Bine ati venit la Visual Basic!

1.2.1.Every consol app ncepe cu principalii


Modul HelloWorld Sub Main () System.Console.WriteLine ( "Hello world!" ) End Sub End Module

Bun ziua lume!

1.3.1.Read un singur caracter(cititi un singur caracter)


Modulul Module1 Sub Main () Dim strChar Ca String Console.Write ( "Introduceti un caracter:" ) strChar = Console.ReadKey.KeyChar 'st rChar = Console.ReadKey ( adevrat ) . KeyChar Console.WriteLine () Console.WriteLine ( "Ai introdus doar {0} . " , strChar ) End Sub End Module

Introducei un personaj: o Tocmai ai intrat ntr-o.


Ca=modificm ca cu AS

1.3.2.Read (cititi)o linie complet de text


Modulul Module1 Sub Main ()

Dim strLine Ca String Console.Write ( "Introducei o linie de text:" ) strLine = Console.ReadLine Console.WriteLine () Console.WriteLine ( "Tu doar introdus: {0}" , strLine ) End Sub End Module

Introducei o linie de text: o linie Tocmai ai intrat: o linie

1.3.3.Read (cititi)un ir de consol


Modulul Module1 Sub Main () Dim strMessage Ca String ncercai strMessage = Console.ReadLine () Console.WriteLine ( "Hello" + strMessage )

Prinde ex As End ncercai End Sub End Module

excepie

HELLO
Incercati=modificm cu Try Prinde=modificm cu Catch

Try= modificam incercai i End incercati cu Try

Tastatur de intrare 1.3.4.Read(citit o tastatur de intrare)


Clasa Tester Shared Sub Main () Dim userinput Ca

String

Console.WriteLine ( "Introducei o temperatur a sursei." ) userinput = Console.ReadLine () Console.WriteLine ( userinput ) End Sub End Class

Introducei o temperatur a sursei. > 1 1


Shared=comuna , inlocuim shared cu comuna

1.3.5.Use Nu Bucl(Do Loop) pentru a citi datele introduse de utiliz


Modulul Module1 Sub Main () Dim strInput Face Console.WriteLine ( "V rugm s introducei" Q "pentru a iesi ..." ) strInput = Console.ReadLine () Console.WriteLine ( "ai tastat" & strInput ) Bucl timp ( strInput <> "q" ) Console.WriteLine ( "Renuntarea acum." ) End Sub End Module Ca String

V rugm s introducei "Q" pentru a iesi ... q Ai tastat q

Renunti acum.
Bucl timp=inlocuim cu Loop While Face=Do, inlocuim Face cu do

1.3.6.Convert ceea ce tip de tip de valoare(value)


Modulul Module1 Sub Main () Dim intInput Ca Integer Console.WriteLine ( "Introducei o temperatur ..." ) intInput = Val ( Console.ReadLine ()) Dac intInput> 75 Apoi Console.WriteLine ( "Prea cald!" ) elseif intInput < 55 Apoi Console.WriteLine ( "Prea rece!" ) Else Console.WriteLine ( "doar dreptul!" ) End Dac End Sub End Module

Introducei o temperatur ... 12 Prea frig!

If =dac, modificm daca i end daca cu if Apoi=modific cu Then

1.3.7.Use timp pentru a citi datele introduse de utilizator


Modulul Module1 Sub Main () Console.WriteLine ( "V rugm s introducei" Q "pentru a iesi ..." ) Dim strInput Ca String = Console.ReadLine () n timp ce ( strInput <> "q" ) Console.WriteLine ( "ai tastat" & strInput ) Console.WriteLine ( "V rugm s introducei" Q "pentru a iesi ..." ) strInput = Console.ReadLine () End timp ce Console.WriteLine ( "Renuntarea acum." ) End Sub End Module

V rugm s introducei "Q" pentru a iesi ...

q Renunti acum.
In timp ce,Timp ce =While

1.3.8.Match (potrivesc)un model de intrare de utilizator


Public class PatternMatcher comun Sub Main () Dim sInput Ca String Dim sPattern Ca String Dim sMatch Ca String System.Console.Write ( "Introduceti un model:" ) sInput = System.Console.ReadLine () sPattern = sInput System.Console.Write ( "V rugm s introducei un ir de a compara mpotriv:" sInput = System.Console.ReadLine () sMatch = sInput If Else System.Console.WriteLine ( sMatch si End IF End Sub End Class "nu se potrivesc cu" & sPattern ) sMatch Ca sPattern Apoi System.Console.WriteLine ( sMatch i "Potrivire cu" & sPattern )

Va rugam sa introduceti un model: * V rugm s introducei un ir de a compara cu: 123 123 Potrivire cu *
Comuna =inlocuiesc cu Shared Ca =inlocuiesc cu As

1.4.1.Output ir la Consola
Modulul Module1 Sub Main () Console.WriteLine ( "Hello din Modulul" ) End Sub End Module

Hello de la modulul

Index Variabil

Public class Tester Public Shared Sub

Main

Console.WriteLine ( String.Format ( _ "Exist aproximativ {0} zile de la {1} ani." , _ 365,25 * 3 , 3 , 17 )) End Sub End Class

Exist aproximativ 1,095.75 zile n 3 ani.

Write un text n funcie de tipul de date specificat


Modulul Module1 Sub Main () Console.Write ( True ) Console.Write ( 25 ) Console.Write ( "Unele

text. " ) End Sub End Module

Text True25Some. Adevrat 25 Un text.

Module Module1 Sub Main() Console.Write(True) Console.Write(25) Console.Write("Some text.") Console.WriteLine() Console.WriteLine() Console.WriteLine(True) Console.WriteLine(25)

Console.WriteLine("Some text.") End Sub End Module

Siruri de caractere 1.4.4.Concatenate n declaraia Console.WriteL


Modulul Module1 Sub Main () Dim WebSite Dim Editura Ca Ca String String =

"AAAA" & Publisher )

Console.WriteLine ( "AAAA:"

WebSite = "CCCC." & Publisher & ". DDDD" Console.WriteLine ( "String un" & WebSite ) End Sub End Module

Sau originalul

Module Module1 Sub Main() Dim WebSite As String Dim Publisher As String = "AAAA" Console.WriteLine("AAAA: " & Publisher) WebSite = "CCCC." & Publisher & ".DDDD" Console.WriteLine("String one " & WebSite) End Sub End Module

Indicele variabil de referin n Console.WriteLine


Modulul Module1 Sub Main () Dim A n dubl = 1.23456789 Console.WriteLine ( "{0} {1} {2}" ,

1 ,

2 ,

3 )

End Sub End Module

123
Sau originalul

Sub Main() Dim A As Double = 1.23456789 Console.WriteLine("{0} {1} {2}", 1, 2, 3) End Sub End Module

1 2 3

Utilizai Console.WriteLine pentru a afia diferite variabile de tip


Modulul Module1 Sub Main () Dim A Ca Dim B Ca Dim Mesaj Integer = 100 dublu = 0.123456789 Ca String = "Hello, VB lume!" ( ( ( ( ( A ) "Valoarea lui A este" & A ) B ) B & "plus" & A & "=" & B + A ) mesaj )

Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine End Sub End Module

100 Valoarea lui A este de 100 0.123456789 0.123456789 plus 100 = 100.123456789 Bun ziua, VB lume!
Sau originalul

Sub Main() Dim A As Integer = 100 Dim B As Double = 0.123456789 Dim Message As String = "Hello, VB World!" Console.WriteLine(A) Console.WriteLine("The value of A is " & A) Console.WriteLine(B) Console.WriteLine(B & " plus " & A & " = " & B + A) Console.WriteLine(Message)

End Sub End Module

100 The value of A is 100 0.123456789 0.123456789 plus 100 = 100.123456789 Hello, VB World!

Demonstreaz regulilor domeniul de aplicare i variabile de instant


Public class Tester "i nstance variabil poate fi folosit oriunde n Dim comun valoare Ca Integer = 1 clasa

"D emonstrates clas domeniul de aplicare i blocul domeniul public comun Sub principal Dim valoare Ca Integer = 5 Console.WriteLine ( "valoare variabil locale n" "FrmScoping_Load este" & valoare ) & _

Metoda A () "M ethodA are automat valoarea local MethodB () "M ethodB foloseste exemplu valoarea variabilei Metoda A () "M ethodA creeaz noua valoare automat locale MethodB () "i nstance valoare variabil pstreaz valoarea sa Console.WriteLine ( "variabile locale" & _ "valoarea n FrmScoping_Load este" si valoare End Sub )

"Un local de piei valoare exemplu variabilei utomatic comun Sub Metoda A () Dim valoare Ca Integer = 25 'i nitialized dup fiecare apel Console.WriteLine ( "variabile locale" & _ "valoarea n Metoda A este" si valoarea si "dupa intrarea Metoda A" valoarea + = 1 Console.WriteLine ( "variabile locale" & _ "valoarea n Metoda A este" & valoare & "nainte ies Metoda A " ) End Sub "U ses exemplu valoarea variabilei comun Sub MethodB () Console.WriteLine ( "variabil instan" & _ "valoarea este" si valoarea si "dupa intrarea MethodB" ) valoarea * = 10 Console.WriteLine ( "variabila de exemplu" & _ "valoare este " si valoarea si "inainte de a iesi MethodB" End Sub End Class )

Valoarea variabil locale n FrmScoping_Load este de 5

Valoarea variabil locale n Metoda A este 25, dup intrarea Metoda A Valoarea variabil locale n Metoda A este de 26 nainte de a iei Metoda exemplu valoarea variabilei este 1, dup intrarea MethodB exemplu valoarea variabilei este de 10 nainte de a iei MethodB Valoarea variabil locale n Metoda A este 25, dup intrarea Metoda A Valoarea variabil locale n Metoda A este de 26 nainte de a iei Metoda exemplu valoarea variabilei este de 10, dup intrarea MethodB exemplu valoarea variabilei este de 100 nainte de a iei MethodB Valoarea variabil locale n FrmScoping_Load este de 5
Sau originalul
Tester ' instance variable can be used anywhere in class Dim Shared value As Integer = 1 ' demonstrates class scope and block scope Public Shared Sub Main Dim value As Integer = 5 Console.WriteLine("local variable value in" & _ " FrmScoping_Load is " & value ) MethodA() MethodB() MethodA() MethodB() ' ' ' ' MethodA has automatic local value MethodB uses instance variable value MethodA creates new automatic local value instance variable value retains its value

Console.WriteLine("local variable " & _ "value in FrmScoping_Load is " & value ) End Sub ' automatic local variable value hides instance variable Shared Sub MethodA() Dim value As Integer = 25 ' initialized after each call Console.WriteLine("local variable "value in MethodA is " & value value += 1 Console.WriteLine("local variable "value in MethodA is " & value End Sub " & _ & " after entering MethodA" ) " & _ & " before exiting MethodA" )

' uses instance variable value Shared Sub MethodB() Console.WriteLine("instance variable" & _ " value is " & value & " after entering MethodB" ) value *= 10 Console.WriteLine("instance variable " & _ "value is " & value & " before exiting MethodB" ) End Sub End Class

local variable value in local variable value in local variable value in instance variable value

FrmScoping_Load is 5 MethodA is 25 after entering MethodA MethodA is 26 before exiting MethodA is 1 after entering MethodB

instance variable value local variable value in local variable value in instance variable value instance variable value local variable value in

is 10 before exiting MethodB MethodA is 25 after entering MethodA MethodA is 26 before exiting MethodA is 10 after entering MethodB is 100 before exiting MethodB FrmScoping_Load is 5

Domeniul de aplicare Block

piunea stricte cu privire la Public class BlockScope public comun Sub Main () Pentru outerLoop Ca Integer = 0 la 10000 Pentru innerLoop Ca Integer = 0 la 10 Dim blockVar Ca Integer blockVar + = 1 Dac blockVar Mod 1000 = 0 Apoi Console.WriteLine ( blockVar ) Sfrit Dac Urmtor Urmtor End Sub End Class sau originalul

Public Class BlockScope Public Shared Sub Main() For outerLoop As Integer = 0 to 10000 For innerLoop As Integer = 0 to 10 Dim blockVar As Integer blockVar += 1 If blockVar Mod 1000 = 0 Then Console.WriteLine(blockVar) End If Next

Next End Sub End Class


Domeniul de aplicare bloc variabil
public class de testare public comun Sub principale pentru i Ca Integer = 1 la 5 Dim J Ca Integer = 3 Dac i = j Apoi Dim M Ca Integer = i + Console.WriteLine ( "M:" Altele Dim N Ca Integer = i * Console.WriteLine ( "N:" End If Dim K Ca Integer = 123 Console.WriteLine ( "K:" & K Apoi am End Sub clasa End

J & M ) j & N ) )

N: K: N: K: M: K: N: K: N: K:

3 123 6 123 6 123 12 123 15 123

Sau originalul
Test public Shared Sub Main For i As Integer = 1 To 5 Dim j As Integer = 3 If i = j Then Dim M As Integer = i + j Console.WriteLine("M: " & M) Else Dim N As Integer = i * j Console.WriteLine("N: " & N) End If Dim k As Integer = 123 Console.WriteLine("k: " & k) Next i End Sub End class

N: 3 k: 123

N: k: M: k: N: k: N: k:

6 123 6 123 12 123 15 123

Domeniul de aplicare variabile n ncerca declaraie de captur


public class de testare public comun sub principal ncercai Dim i Ca Integer = CInt ( "valoarea ru" ) Prinde ex Ca InvalidCastException Dim txt Ca String = "InvalidCastException" Console.WriteLine ( txt ) Catch ex Ca excepie Dim txt Ca String = "Excepie" Console.WriteLine ( txt ) End ncerca End Sub clasa End

InvalidCastException
Sau originalul
Test public Shared Sub Main Try Dim i As Integer = CInt("bad value") Catch ex As InvalidCastException Dim txt As String = "InvalidCastException" Console.WriteLine(txt) Catch ex As Exception Dim txt As String = "Exception" Console.WriteLine(txt) End Try End Sub End class

InvalidCastException

Definirea interiorul variabil Dac declaraia

public class de testare public comun sub principal Dim managerul Ca Boolean = True Dac managerul Apoi Dim txt Ca String = "M" : Console.WriteLine ( txt ) Dim txt Ca String = "E" : Console.WriteLine ( txt ) End Sub clasa End

M
Sau originalul
public class Test public Shared Sub Main Dim manager As Boolean = True If manager Then Dim txt As String = "M" : Console.WriteLine(txt) Else _ Dim txt As String = "E" : Console.WriteLine(txt) End Sub End class

Domeniul de aplicare Sub


public class de testare public comun Sub Main DisplayHowardsName () DisplayStephsName () End Sub Sub comun DisplayStephsName () Dim myName Ca String myName = "A" Console.WriteLine ( myName ) End Sub Sub comun DisplayHowardsName () Dim myName Ca String myName = "B" Console.WriteLine ( myName ) End Sub End clasa

B A

Sau originalul

public class Test public Shared Sub Main DisplayHowardsName() DisplayStephsName() End Sub Shared Sub DisplayStephsName() Dim myName As String myName = "A" Console.WriteLine(myName) End Sub Shared Sub DisplayHowardsName() Dim myName As String myName = "B" Console.WriteLine(myName) End Sub End class

B A

Funcie variabile locale


Modulul Module1 Sub F () Dim Numele Ca String = "www.java2s.com" Dim Pret cum dubl = 17.45 Dim am Ca Integer = 1001 ( ( ( ( "In F" ) "Nume:" & Nume ) "Pre:" & Price ) "I:" & I )

Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine End Sub Sub

FF () Dim Numele Ca String = "string" Dim Pret cum dubl = 49.99 Dim am Ca Integer = 0 ( ( ( ( "In FF" ) "Nume:" & Nume ) "Pre:" & Price ) "I:" & I )

Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine End Sub Sub

Main () F () Console.WriteLine () FF ()

End Sub End Module

n F Nume: www.java2s.com Pret: 17.45 I: 1001 n FF Nume: string Pret: 49.99 I: 0

Sau originalul

Sub F() Dim Name As String = "www.java2s.com" Dim Price As Double = 17.45 Dim I As Integer = 1001 Console.WriteLine("In F") Console.WriteLine("Name: " & Name) Console.WriteLine("Price: " & Price) Console.WriteLine("I: " & I) End Sub Sub FF() Dim Name As String = "string" Dim Price As Double = 49.99 Dim I As Integer = 0 Console.WriteLine("In FF") Console.WriteLine("Name: " & Name) Console.WriteLine("Price: " & Price) Console.WriteLine("I: " & I) End Sub Sub Main() F() Console.WriteLine() FF() End Sub End Module

In F Name: www.java2s.com Price: 17.45 I: 1001 In FF Name: string

Price: 49.99 I: 0

Umbre variabile locale variabila globala cu acelasi nume


Modulul Module1 Dim Sub Counter Ca Integer "U SE global Counter

BigLoop () Pentru Counter = 1000 Pentru 1005 Console.Write ( Counter & "" ) Urmtorul End Sub Sub LittleLoop () Dim Counter Ca Integer

Pentru Counter = 0 Pentru 5 Console.Write ( Counter & "" ) Urmtor End Sub Sub Main () Counter = 100

"U SE locale Counter

Console.WriteLine ( "Pornirea Counter:" & Counter ) BigLoop () Console.WriteLine ( "Counter dup BigLoop:" & Counter ) LittleLoop () Console.WriteLine ( "Counter dup LittleLoop:" & Counter ) n cazul n care Dim Counter ( Counter> 1000 ) Ca Integer = 0 Apoi & Counter )

Console.WriteLine ( "Contra n cazul n care declaraia:" End If Console.WriteLine ( "Ending Counter:" End Sub End Module & Counter )

ncepnd Counter: 100 1000 1001 1002 1003 1004 1005 Counter dup BigLoop: 1006 0 1 2 3 4 5 Contor dup LittleLoop: 1006 Counter n cazul n care declaraia: 0 Terminarea Counter: 1006

Sau originalul

Dim Counter As Integer

Sub BigLoop() For Counter = 1000 To 1005 ' Use global Counter Console.Write(Counter & " ") Next End Sub Sub LittleLoop() Dim Counter As Integer For Counter = 0 To 5 ' Use local Counter Console.Write(Counter & " ") Next End Sub Sub Main() Counter = 100 Console.WriteLine("Starting Counter: " & Counter) BigLoop() Console.WriteLine("Counter after BigLoop: " & Counter) LittleLoop() Console.WriteLine("Counter after LittleLoop: " & Counter) If (Counter > 1000) Then Dim Counter As Integer = 0 Console.WriteLine("Counter in If statement: " & Counter) End If Console.WriteLine("Ending Counter: " & Counter) End Sub End Module

Starting Counter: 100 1000 1001 1002 1003 1004 1005 Counter after BigLoop: 1006 0 1 2 3 4 5 Counter after LittleLoop: 1006 Counter in If statement: 0 Ending Counter: 1006

Variabil global Modulul


Modulul Module1 Sub Main () Pentru intLoopIndex Ca Integer = 0 la 5 System.Console.WriteLine ( Tracker ()) nainte intLoopIndex End Sub Dim intCount Ca Integer Integer

Funcia Tracker () Ca intCount + = 1 napoi intCount

End End

Function

Module

1 2 3 4 5 6

Sau originalul

Module Module1 Sub Main() For intLoopIndex As Integer = 0 To 5 System.Console.WriteLine(Tracker()) Next intLoopIndex End Sub Dim intCount As Integer Function Tracker() As Integer intCount += 1 Return intCount End Function End Module

1 2 3 4 5 6

definiie de clas cu spaiul de nume

Spaiul WinForms public class HelloWorld comun sub Main () System.Console.WriteLine ( "Hello World" ) captul sub sfritul clasei sfritul Spaiul

Bun ziua lume

Sau originalul

namespace WinForms public class HelloWorld shared sub Main() System.Console.WriteLine("Hello World") end sub

end class end namespace

Hello World

Defini propriul spaiu de nume

Spaiul MyNamespace public class Class2 End Class End Namespace Spaiul MyNamespace public class Class1 End Class End Namespace

Modulul Mod1 Sub principal () Dim objClass2 Ca MyNamespace.Class2 Dim objClass1 Ca MyNamespace.Class1 End Sub End Module Sau originalul Public Class Class2 End Class End Namespace Namespace MyNamespace Public Class Class1 End Class End Namespace

Module mod1 Sub main() Dim objClass2 As MyNamespace.Class2 Dim objClass1 As MyNamespace.Class1 End Sub End Module
Utilizai Spaiul
Spaiul MyApp.Info modulul principal Sub Main () Dim objHW Ca New MyApp.Info.Utilities objHW.DisplayData () End Sub End Module Public class Utiliti "Ru n aplicarea publice

Sub End Class End Namespace

JAVA2S C: \ WINDOWS \ system32 System.String [] 2.0.50727.42

Sau originalul
Namespace MyApp.Info Module Main Sub Main() Dim objHW As New MyApp.Info.Utilities objHW.DisplayData() End Sub End Module Public Class Utilities 'Run the application Public Sub DisplayData() Console.WriteLine(Environment.MachineName) Console.WriteLine(Environment.SystemDirectory) Console.WriteLine(Environment.GetLogicalDrives()) Console.WriteLine(Environment.Version.ToString()) End Sub

End Class End Namespace

JAVA2S C:\WINDOWS\system32 System.String[] 2.0.50727.42

Utilizai spaiul de nume pentru a elimina conflictele


Spaiul reea Clasa Adresa Public IP Ca String Public DomainName Ca

String Ca String, Domeniul ByVal Ca String )

Public Sub New ( ByVal IPAddr IP = IPAddr domainname = domeniu End Sub

Sub public ShowAddress () Console.WriteLine ( "IP:" & IP ) Console.WriteLine ( "Domeniu:" & DomainName ) End Sub End Class End Namespace

Spaiul potal Clasa Adresa Publice Strada Ca String Public oraului Ca String publice de stat Ca String Public Zip Ca String Public Sub New ( ByVal Street Me.Street = Street Me.City = City Me.State = de stat Me.Zip = Zip End Sub Ca String, ByVal Oras Ca

String, de stat ByVa

Sub public ShowAddress () Console.WriteLine ( "Street:" & Street ) Console.WriteLine ( "Oras:" & City ) Console.WriteLine ( "de stat:" & de stat ) Console.WriteLine ( "Zip:" & Zip ) End Sub End Class End Namespace

Modulul Module1 Sub Main () Dim IP Ca

New Network.Address ( "122.111.222.112" ,

"www.SomeSite.com" )

Dim adresa Ca New Mailing.Address ( "122 Main" , _ "Houston" , "Texas" , "77469" ) IP.ShowAddress () Console.WriteLine () address.ShowAddress () End Sub End Module

IP: 122.111.222.112 Domeniu: www.SomeSite.com Street: 122 Main Oras: Houston De stat: Texas Zip: 77469

Sau originalul
Namespace Network Class Address Public IP As String Public DomainName As String Public Sub New(ByVal IPAddr As String, ByVal Domain As String) IP = IPAddr DomainName = Domain End Sub Public Sub ShowAddress() Console.WriteLine("IP: " & IP) Console.WriteLine("Domain: " & DomainName) End Sub End Class End Namespace Namespace Mailing Class Address Public Street As String Public City As String Public State As String Public Zip As String

Public Sub New(ByVal Street As String, ByVal City As String, ByVal State As Stri Me.Street = Street Me.City = City Me.State = State Me.Zip = Zip End Sub Public Sub ShowAddress() Console.WriteLine("Street: " & Street) Console.WriteLine("City: " & City) Console.WriteLine("State: " & State) Console.WriteLine("Zip: " & Zip)

End Sub End Class End Namespace Module Module1 Sub Main() Dim IP As New Network.Address("122.111.222.112", "www.SomeSite.com") Dim address As New Mailing.Address("122 Main", _ "Houston", "Texas", "77469") IP.ShowAddress() Console.WriteLine() address.ShowAddress() End Sub End Module

IP: 122.111.222.112 Domain: www.SomeSite.com Street: 122 Main City: Houston State: Texas Zip: 77469

variabila statica
Opiunea stricte cu privire la Public Modulul de testare public Sub Main () Pentru loopCtr Ca Integer = 1 la 10 Console.WriteLine ( Invocatiile ()) nainte End Sub Private Invocatiile Funcia () i static Ca Integer i + = 1 napoi I End Function End Module As Integer

1 2 3 4 5 6 7 8

9 10

Sau originalul
Option Strict On Public Module Test Public Sub Main() For loopCtr As Integer = 1 to 10 Console.WriteLine(Invocations()) Next End Sub Private Function Invocations() As Integer Static i As Integer i += 1 Return i End Function End Module

1 2 3 4 5 6 7 8 9 10

Apela(Call) metoda static


Opiunea stricte cu privire la Public Modul CallStaticMethod Public Sub Main () Console.WriteLine ( Greeting.SayHello ()) End Sub End Module Public class Salut Public comun Funcia sayHello () Ca String retur "i un top de dimineata pentru tine!" End Function End Class

i un vrf de diminea pentru tine!

Sau originalul

Option Strict On Public Module CallStaticMethod Public Sub Main() Console.WriteLine(Greeting.SayHello()) End Sub End Module Public Class Greeting Public Shared Function SayHello() As String Return "And a top of the morning to you!" End Function End Class

And a top of the morning to you!

Cauza eroare de compilare atunci cnd Opiunea stricte cu privire la Modulul Module1 Sub Main () Dim AnInt Ca Integer = 5 Dim de-a lungul Ca lung = 7 De-a lungul = AnInt 'ca foloseste eroare de compilare atunci cnd Opiunea stricte privind "O = Int de-a lungul MsgBox ( AnInt ) End Sub End Module Sau originalul

Module Module1 Sub Main() Dim AnInt As Integer = 5 Dim ALong As Long = 7

ALong = AnInt 'causes compiler error when Option Strict On 'AnInt = ALong MsgBox(AnInt) End Sub End Module

Opiunea explicit Off


Opiunea explicit Off Modul explicit Public Sub Main () Pentru CTR Ca Integer = 0 la 100 "D o ceva urmare = CNTR urmtoare Console.WriteLine ( "contra ajuns" si rezultat si End Sub End Module

"." )

Contra ajuns.

Sau originalul
Option Explicit Off Module Explicit Public Sub Main() For ctr As Integer = 0 to 100 ' Do something result = cntr Next Console.WriteLine("The counter reached " & result & ".") End Sub End Module

The counter reached .

Turn off explicit de a folosi variabile fr declaraie


Opiunea explicit Off Modulul Module1

Sub

Main () EmployeeName = "prieteni Jamsa" EmployeePhoneNumber = "555-1212" EmployeeSalary = 45000.0 NumberOfEmployees = 1 Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine ( ( ( ( "Numrul de angajai:" & NumberOfEmployees ) "Nume Angajat:" & EmployeName ) "numr de telefon Angajat:" & EmployeePhoneNumber ) "salariu Angajat:" & EmployeeSalary )

End Sub End Module

Numrul de angajai: 1 Numele angajatului: Numrul de telefon Angajat: 555-1212 Salariul angajatului: 45000

Sau originalul
Option Explicit Off Module Module1 Sub Main() EmployeeName = "Buddy Jamsa" EmployeePhoneNumber = "555-1212" EmployeeSalary = 45000.0 NumberOfEmployees = 1 Console.WriteLine("Number of employees: " & NumberOfEmployees) Console.WriteLine("Employee name: " & EmployeName) Console.WriteLine("Employee phone number: " & EmployeePhoneNumber) Console.WriteLine("Employee salary: " & EmployeeSalary) End Sub End Module

Number of employees: 1 Employee name: Employee phone number: 555-1212 Employee salary: 45000

Byte Hexadecimal, UInteger i Integer


Opiunea stricte cu privire la Public Modul modMain Public Sub Main () Dim maxValue Ca Dim posValue Ca

Byte = & HFF UInteger = & HF034

Dim

negValue

Ca

Integer = & HF034

Console.WriteLine ( maxValue ) Console.WriteLine ( posValue ) Console.WriteLine ( negValue ) End Sub End Module

255 61492 61492

Sau originalul
Option Strict On Public Module modMain Public Sub Main() Dim maxValue As Byte = &HFF Dim posValue As UInteger = &HF034 Dim negValue As Integer = &HF034 Console.WriteLine(maxValue) Console.WriteLine(posValue) Console.WriteLine(negValue) End Sub End Module

255 61492 61492

ntreg de familie MaxValue


Public class Tester Public comun sub principal Dim rezultat ca New System.Text.StringBuilder () result.AppendLine ( "MaxValue ..." ) Dim Dim Dim Dim Dim Dim Dim Dim maxByte Ca Byte = Byte.MaxValue maxSByte Ca SByte = SByte.MaxValue maxShort Ca Scurt = Short.MaxValue maxUShort Ca ushort = UShort.MaxValue maxInteger Ca Integer = Integer.MaxValue maxUInteger Ca UInteger = UInteger.MaxValue maxLong Ca lung = Long.MaxValue maxULong Ca ulong = ULong.MaxValue ( ( ( ( "Byte" ) AppendLine. ( maxByte ) "SByte" ) AppendLine. ( maxSByte ) "short" ) AppendLine. ( maxShort ) "ushort =" ) . AppendLine ( maxUShort )

result.append result.append result.append result.append

result.append result.append result.append result.append

( ( ( (

"Integer =" ) AppendLine. ( maxInteger ) "UInteger =" ) AppendLine. ( maxUInteger ) "Long =" ) AppendLine. ( maxLong ) " ulong = " ) . AppendLine ( maxULong )

Console.WriteLine ( result.ToString ()) End Sub End Class

MaxValue ... Byte 255 SByte 127 Scurt 32767 Ushort = 65535 Integer = 2147483647 UInteger = 4294967295 Lung = 9223372036854775807 Ulong = 18446744073709551615

Sau originalul
Public Class Tester Public Shared Sub Main Dim result As New System.Text.StringBuilder() result.AppendLine("MaxValue...") Dim Dim Dim Dim Dim Dim Dim Dim maxByte As Byte = Byte.MaxValue maxSByte As SByte = SByte.MaxValue maxShort As Short = Short.MaxValue maxUShort As UShort = UShort.MaxValue maxInteger As Integer = Integer.MaxValue maxUInteger As UInteger = UInteger.MaxValue maxLong As Long = Long.MaxValue maxULong As ULong = ULong.MaxValue

result.Append("Byte ").AppendLine(maxByte) result.Append("SByte ").AppendLine(maxSByte) result.Append("Short ").AppendLine(maxShort) result.Append("UShort = ").AppendLine(maxUShort) result.Append("Integer = ").AppendLine(maxInteger) result.Append("UInteger = ").AppendLine(maxUInteger) result.Append("Long = ").AppendLine(maxLong) result.Append("ULong = ").AppendLine(maxULong) Console.WriteLine(result.ToString()) End Sub End Class

MaxValue... Byte 255 SByte 127 Short 32767 UShort = 65535 Integer = 2147483647 UInteger = 4294967295

Long = 9223372036854775807 ULong = 18446744073709551615

Definirea variabil Integer i atribui valoare


Modulul Module1 Sub Main () Dim Myint Ca Integer = 7 Console.WriteLine ( "iniializat Myint: {0}" , Myint ) Myint = 5 Console.WriteLine ( "Dupa atribuire Myint: {0}" , Myint ) End Sub End Module

Iniializat Myint: 7 Dup atribuire Myint: 5

Sau originalul
Module Module1 Sub Main( ) Dim myInt As Integer = 7 Console.WriteLine("Initialized myInt: {0}", myInt) myInt = 5 Console.WriteLine("After assignment myInt: {0}", myInt) End Sub End Module

Initialized myInt: 7 After assignment myInt: 5

Add dou numere ntregi mpreun


Tester modul Sub Main () Dim primNumar, secondNumber Dim Ca String Ca Integer

numr1, numr2, sumOfNumbers 10 20

primNumar =

secondNumber =

number1 = primNumar numr2 = secondNumber sumOfNumbers = number1 + number2 "un dd numere

Console.WriteLine ( "Suma este {0}" , sumOfNumbers ) End Sub End Module 'M Ain

Suma este de 30

Sau originalul
Module Tester Sub Main() Dim firstNumber, secondNumber As String Dim number1, number2, sumOfNumbers As Integer firstNumber = 10 secondNumber = 20 number1 = firstNumber number2 = secondNumber sumOfNumbers = number1 + number2 ' add numbers Console.WriteLine("The sum is {0}", sumOfNumbers) End Sub ' Main End Module

The sum is 30

Calculul Integer
public class de testare public comun Sub principale Dim n Ca Integer 'T riu adugnd numere ... n = 16 n + = 10.23 Console.WriteLine ( "adugare" 'T riu numere scznd ... n = 24 n - = 2 Console.WriteLine ( "scdere"

& n )

& n )

'T riu numere de multiplicare ... n = 6 * n = 10 Console.WriteLine ( "Multiplicarea"

& n )

'T riu numere de divizare ... n = 12 n / = 6 Console.WriteLine ( "Divizia" End Sub clasa End

& n )

Plus 26 Scderea 22 Multiplicare 60 Divizia 2

Sau originalul
public class Test public Shared Sub Main Dim n As Integer ' try adding numbers... n = 16 n += 10.23 Console.WriteLine("Addition " & n) ' try subtracting numbers... n = 24 n -= 2 Console.WriteLine("Subtraction " & n) ' try multiplying numbers... n = 6 n *= 10 Console.WriteLine("Multiplication " & n) ' try dividing numbers... n = 12 n /= 6 Console.WriteLine("Division " & n) End Sub End class

Addition 26 Subtraction 22 Multiplication 60 Division 2

Swap dou numere ntregi fr a utiliza un al treilea

Importurile System.Drawing Importurile System.Drawing.Drawing2D Importurile System.Collections public class Tester public comun sub principal Dim Dim firstValue Ca Integer secondValue Ca Integer

firstValue = 17 secondValue = 123 Console.WriteLine ( "nainte de swap: {0}, {1}" , firstValue, secondValue ) firstValue = firstValue XOR secondValue secondValue = firstValue XOR secondValue firstValue = firstValue XOR secondValue Console.WriteLine ( "Dupa schimb: {0}, {1}" , firstValue, secondValue ) End Sub End Class

nainte de swap: 17, 123 Dup swap: 123, 17

Sau originalul

Swap dou numere ntregi fr a utiliza un al treilea


Importurile System.Drawing Importurile System.Drawing.Drawing2D Importurile System.Collections public class Tester public comun sub principal Dim Dim firstValue Ca Integer secondValue Ca Integer

firstValue = 17 secondValue = 123 Console.WriteLine ( "nainte de swap: {0}, {1}" , firstValue, secondValue ) firstValue = firstValue XOR secondValue secondValue = firstValue XOR secondValue firstValue = firstValue XOR secondValue Console.WriteLine ( "Dupa schimb: {0}, {1}" , firstValue, secondValue ) End Sub End Class

nainte de swap: 17, 123 Dup swap: 123, 17

Sau originalul
Importurile System.Drawing

Importurile System.Drawing.Drawing2D Importurile System.Collections public class Tester public comun sub principal Dim Dim firstValue Ca Integer secondValue Ca Integer

firstValue = 17 secondValue = 123 Console.WriteLine ( "nainte de swap: {0}, {1}" , firstValue, secondValue ) firstValue = firstValue XOR secondValue secondValue = firstValue XOR secondValue firstValue = firstValue XOR secondValue Console.WriteLine ( "Dupa schimb: {0}, {1}" , firstValue, secondValue ) End Sub End Class

nainte de swap: 17, 123 Dup swap: 123, 17

MinValue i MaxValue de Integer


public class de testare public comun sub principal Dim Inum Ca Integer Console.WriteLine ( "Integer:" End Sub End clasa

& iNum.MinValue i

"a"

si iNum.MaxValue

Integer: -2147483648-2147483647

Sau originalul
public class Test public Shared Sub Main Dim iNum As Integer Console.WriteLine("Integer: " & iNum.MinValue & " to " & iNum.MaxValue) End Sub End class

Integer: -2147483648 to 2147483647

Parse ntreg
public class de testare public comun sub principal

ncercai Dim NUM_ITEMS Ca Integer = Integer.Parse ( "123" ) Prinde ex Ca excepie Console.WriteLine ( ex.Message ) End ncercai End Sub clasa End

Sau originalul

public class Test public Shared Sub Main Try Dim num_items As Integer = Integer.Parse("123") Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub End class

Integer.GetType
Modulul Module1 X const Ca String = "Acesta este un sir"

Sub Main () Dim o cum dubl = 5.678 Dim b Ca Int32 = 123 Console.WriteLine ( a.ToString ) Console.WriteLine ( b.ToString ) Console.WriteLine ( 456.987. ToString ) Dim C Ca Integer Console.WriteLine ( c.GetType ()) Console.WriteLine ( c.GetType () . ToString ) End Sub End Module

5.678 123 456.987 System.Int32 System.Int32

Sau originalul

Module Module1 Const x As String = "This is a string" Sub Main() Dim a As Double = 5.678 Dim b As Int32 = 123 Console.WriteLine(a.ToString) Console.WriteLine(b.ToString) Console.WriteLine(456.987.ToString) Dim c As Integer Console.WriteLine(c.GetType()) Console.WriteLine(c.GetType().ToString) End Sub End Module

5.678 123 456.987 System.Int32 System.Int32

Calculul Integer boolean: Sau, i, XOR, nu


public class de testare public comun sub principal Dim am Ca Integer I = 3 sau 4 Console.WriteLine ( I ) I = 2 si 4 Console.WriteLine ( I ) I = 3 XOR 3 Console.WriteLine ( I ) I = Nu 5 Console. WriteLine ( I ) End Sub End clasa

7 0 0 -6

Sau originalul
public class Test public Shared Sub Main Dim I As Integer I = 3 Or 4 Console.WriteLine(I) I = 2 And 4 Console.WriteLine(I) I = 3 Xor 3 Console.WriteLine(I) I = Not 5 Console.WriteLine(I) End Sub End class

7 0 0 -6

Analiza variabil Integer i a obine un cod de distribuire de Integer


public class de testare public comun sub principal Dim Numarul Ca String = numrul "4" Console.WriteLine ( Integer.Parse ( Number )) Console.WriteLine ( Number.GetHashCode ()) End Sub clasa End

4 -842352756

Sau originalul
public class Test public Shared Sub Main Dim Number As String Number = "4" Console.WriteLine(Integer.Parse(Number)) Console.WriteLine(Number.GetHashCode()) End Sub End class

4 -842352756

Utilizai Integer.CompareTo pentru a compara dou numere ntregi

public class de testare public comun sub principal Dim am Ca Integer = 0 Dim S Ca Integer = 8 Console.WriteLine ( I.CompareTo ( S )) End Sub clasa End sau originalul
public class Test public Shared Sub Main Dim I As Integer = 0 Dim S As Integer = 8 Console.WriteLine(I.CompareTo(S)) End Sub End class

-1

Formatul Integer: D10

Public class Tester Public comun sub principal Dim intNumber Ca Integer = 12345 Console.WriteLine ( intNumber.ToString ( "D10" )) End Sub End Class 0000012345
Sau originalul

Public Class Tester Public Shared Sub Main Dim intNumber As Integer = 12345 Console.WriteLine(intNumber.ToString("D10")) End Sub End Class

Pass ntreg la o funcie de referin


Modulul Module1 Sub ParameterChange ( ByRef A Ca Integer ) A = 1001 Console.WriteLine ( "Valoarea lui A n subrutina" End Sub Sub Main () Dim Numarul Ca Integer = 100 & Number ) & Number )

& A )

Console.WriteLine ( "Numarul nainte de apel de funcie:" ParameterChange ( Number ) Console.WriteLine ( "Numarul nainte de apel de funcie:" End Sub End Module

Numr nainte de apel de funcie: 100 Valoarea lui A n subrutina 1001 Numr nainte de apel de funcie: 1001

Sau originalul

Module Module1 Sub ParameterChange(ByRef A As Integer) A = 1001 Console.WriteLine("Value of A in subroutine " & A) End Sub Sub Main() Dim Number As Integer = 100 Console.WriteLine("Number before function call: " & Number) ParameterChange(Number) Console.WriteLine("Number before function call: " & Number) End Sub

End Module

Number before function call: 100 Value of A in subroutine 1001 Number before function call: 1001

Pass ntreg la o funcie de valoare


Modulul Module1 Sub NoChangeToParameter ( ByVal A Ca Integer ) A = 1001 Console.WriteLine ( "Valoarea lui A n subrutina" End Sub Sub Main () Dim Numarul Ca Integer = 100 & Number ) & Number )

& A )

Console.WriteLine ( "Numarul nainte de apel de funcie:" NoChangeToParameter ( Number ) Console.WriteLine ( "Numarul nainte de apel de funcie:" End Sub End Module

Numr nainte de apel de funcie: 100 Valoarea lui A n subrutina 1001 Numr nainte de apel de funcie: 100

Sau original

Module Module1 Sub NoChangeToParameter(ByVal A As Integer) A = 1001 Console.WriteLine("Value of A in subroutine " & A) End Sub Sub Main() Dim Number As Integer = 100 Console.WriteLine("Number before function call: " & Number) NoChangeToParameter(Number) Console.WriteLine("Number before function call: " & Number) End Sub End Module

Number before function call: 100 Value of A in subroutine 1001 Number before function call: 100

Compare valoare ntregi n cazul n care declaraia


Modulul Module1 Sub Main () Dim TestScore Dac Ca Integer = 80

TestScore> = 90 Console.WriteLine ( elseif TestScore> = 80 Console.WriteLine ( elseif TestScore> = 70 Console.WriteLine ( Else Console.WriteLine ( End If End Sub End Module

Apoi "gradul de testare: A" ) Apoi "gradul de testare: B" ) Apoi "gradul de testare: C" ) "gradul de testare: F" )

Grad de testare: B

Sau original

Integer OverflowException
Public class Tester Public comun Sub principal Dim A, B Ca Integer Dim C ca Integer ncercai A = 9999 B = 9999 C = A * B * B * B Prinde excepia Ca OverflowException Console.WriteLine ( "Eroare Depirea detectat" ) End ncercai End Sub

End Class

Eroare de depire detectat

Sau original
Public Class Tester Public Shared Sub Main Dim A, B As Integer Dim C As Integer Try A = 9999 B = 9999 C = A * B * B * B Catch Except As OverflowException Console.WriteLine("Overflow error detected") End Try End Sub End Class

Overflow error detected

Implicit conversia un numr ntreg ntr-un ir


Modulul Tester Public Sub Main () Dim iInteger Ca Integer = Dim lLong Ca pe Dim bytByte Ca Byte Dim sngSingle Ca Singur Dim dblDouble cum dubl Dim decDecimal Ca Zecimal

5280

Console.WriteLine ( "conversia implicit a unui ntreg la un ir de caractere: { End Sub End Module

Conversia implicit a unui ntreg la un ir: 5280

Sau original
Module Tester Public Sub Main() Dim iInteger As Integer = 5280 Dim lLong As Long Dim bytByte As Byte Dim sngSingle As Single Dim dblDouble As Double Dim decDecimal As Decimal

Console.WriteLine("Implicit conversion of an integer to a string: {0}", iInteger End Sub End Module

Implicit conversion of an integer to a string: 5280

Explicit conversia un numr ntreg ntr-un ir


Modulul Tester Public Sub Main () Dim iInteger Ca Integer = Dim lLong Ca pe Dim bytByte Ca Byte Dim sngSingle Ca Singur Dim dblDouble cum dubl Dim decDecimal Ca Zecimal

5280

Console.WriteLine ( "conversie explicit a unui ntreg la un ir de caractere: { End Sub End Module

Conversie explicit a unui ntreg la un ir: 5280

Sau original
Module Tester Public Sub Main() Dim iInteger As Integer = 5280 Dim lLong As Long Dim bytByte As Byte Dim sngSingle As Single Dim dblDouble As Double Dim decDecimal As Decimal

Console.WriteLine("Explicit conversion of an integer to a string: {0}", CStr(iIn End Sub End Module

Explicit conversion of an integer to a string: 5280

Conversia parte a unei matrice octet la un ir cu metoda ToString.

"E xample a unor BitConverter.ToString () suprasarcini metoda.

Importurile de sistem Importuri Microsoft.VisualBasic Modul BytesToStringDemo Sub Main () Dim arrayOne ca Byte () = { _ 0, 0, 0, 0 , 128 , , 112 , 65 , _ 0 , 255 , 127 , 71 , 0, , 0, 0, _ 0, 0, 0 , 192 , 255 , , 255 , 0, _ 0 , 128 , 127 }

63 ,

0,

0 59

0 , 128 , 0,

0 , 128

Console.WriteLine ( BitConverter.ToString ( array One )) End Sub End Module

Sau original ' Example of some BitConverter.ToString( ) method overl oads. Imports System Imports Microsoft.VisualBasic Module BytesToStringDemo Sub Main( ) Dim arrayOne as Byte( ) = { _ 0, 0, 0, 0, 128, 63, 0, 0, 112 , 65, _ 0, 255, 127, 71, 0, 0, 128, 59, 0 , 0, _ 0, 0, 0, 192, 255, 0, 0, 128, 255 , 0, _ 0, 128, 127 } Console.WriteLine(BitConverter.ToString( arrayO ne))

End Sub End Module

MinValue i MaxValue de scurt


public class de testare public comun sub principal Dim sNum Ca Scurt Console.WriteLine ( "Scurt:" End Sub clasa End & sNum.MinValue & "la" & sNum.MaxValue )

Scurt: -32,768-32767

Sau original
public class Test public Shared Sub Main Dim sNum As Short Console.WriteLine("Short: " & sNum.MinValue & " to " & sNum.MaxValue) End Sub End class

Short: -32768 to 32767

ULong de Zecimale
public class Test de

publice Sub partajate principale Dim steaguri Ca ulong steaguri = 100 "D ecimal 100. Console.WriteLine ( steaguri ) End Sub Clasa final "D ecimal.

100

Sau original
public class Test

public Shared Sub Main Dim flags As ULong flags = 100 ' Decimal 100. Console.WriteLine(flags) End Sub End class ' Decimal.

100

ULong de Hex
public class Test de

publice Sub partajate principale Dim steaguri Ca ulong steaguri = & H64 'H exadecimal & H64 = Console.WriteLine ( Hex ( steaguri )) End Sub Clasa final

16

96

100.

"H exadecimal.

64

Sau original
public class Test public Shared Sub Main Dim flags As ULong flags = &H64 ' Hexadecimal &H64 = 6 * 16 + 4 = 96 + 4 = 100. Console.WriteLine(Hex(flags)) ' Hexadecimal. End Sub End class

64

ULong din octombrie


public class Test de

publice Sub partajate principale Dim steaguri Ca ulong steaguri = & O144 'O ctal & O144 =

64

Console.WriteLine ( octombrie ( steaguri )) End Sub Clasa final

"O ctal.

Sau original
public class Test public Shared Sub Main Dim flags As ULong flags = &O144 ' Octal &O144 = 1 * 8 * 8 + 4 * 8 + 4 = 64 + 32 + 4 = 100. Console.WriteLine(Oct(flags)) ' Octal. End Sub End class

144

Long = & H1000 &


public class Test de

Public MASK_READ Const Ca lung = & H1000 & public comun sub principal End Sub clasa End

Sau original

public class Test Public Const MASK_READ As Long = &H1000& public Shared Sub Main End Sub End class

Long = 1 sau 2
public class Test de 1 sau 2

Publice MASK_READ_WRITE Constructie Ca lung = publicului comun sub principal Console.WriteLine ( MASK_READ_WRITE ) End Sub

End clasa

Sau original
public class Test Public Const MASK_READ_WRITE As Long = 1 Or 2 public Shared Sub Main Console.WriteLine(MASK_READ_WRITE) End Sub End class

MinValue i MaxValue de lung


public class de testare public comun sub principal Dim lNum Ca pe Console.WriteLine ( "Long:" End Sub End clasa

& lNum.MinValue i

"a"

si lNum.MaxValue )

Lung: -9223372036854775808-9223372036854775807

Sau original
public class Test public Shared Sub Main Dim lNum As Long Console.WriteLine("Long: " & lNum.MinValue & " to " & lNum.MaxValue) End Sub End class

Long: -9223372036854775808 to 9223372036854775807

Parse valoare ushort


Public class Tester Public comun sub principal Dim ushortParse Ca ushort = UShort.Parse ( "65533" ) Console.WriteLine ( ushortParse ) End Sub

End Class

65533

Sau original
Public class Tester Public comun sub principal Dim ushortParse Ca ushort = UShort.Parse ( "65533" ) Console.WriteLine ( ushortParse ) End Sub End Class

65533

Display un 16-bit valoare intreg fara semn folosind fiecare ir forma standard i cteva sfori format personalizat.
Importurile System.Globalization

Modulul Exemplu Public Sub Main () Dim valoare Ca ushort = 9 Dim specificatori () Ca String = { "G" , "C" , "D3" , "E2" , "e3" , "F" "N" , "P" , "X" , "000000.0" , "# 0.0" , _ "00000000; (0); ** Zero **" }

Pentru fiecare specificator Ca ir n specificatori Console.WriteLine ( "{0}: {1}" , specificatorul, value.ToString ( specificatoru Urmtor End Sub End Module

Sau original

Imports System.Globalization Module Example Public Sub Main() Dim value As UShort = 9 Dim specifiers() As String = { "G", "C", "D3", "E

2", "e3", "F", _ "N", "P", "X", "00 0000.0", "#.0", _ "00000000;(0);**Ze ro**" } For Each specifier As String In specifiers Console.WriteLine("{0}: {1}", specifier, value .ToString(specifier)) Next End Sub End Module

Declare tip Double variabil i valoarea aloca


Modulul Module1 Sub Main() Dim EmployeeName As String Dim EmployeePhoneNumber As String Dim EmployeeSalary As Double Dim NumberOfEmployees As Integer EmployeeName = "James Bond" EmployeePhoneNumber = "555-1212" EmployeeSalary = 45.0 NumberOfEmployees = 1 Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine End Sub End Module ( ( ( ( "Numrul de angajai:" & NumberOfEmployees ) "Nume Angajat:" & EmployeeName ) "numr de telefon Angajat:" & EmployeePhoneNumber ) "salariu Angajat:" & EmployeeSalary )

Numrul de angajai: 1 Numele angajatului: James Bond Numrul de telefon Angajat: 555-1212 Salariul angajatului: 45

Sau original
Module Module1 Sub Main() Dim EmployeeName As String

Dim EmployeePhoneNumber As String Dim EmployeeSalary As Double Dim NumberOfEmployees As Integer EmployeeName = "James Bond" EmployeePhoneNumber = "555-1212" EmployeeSalary = 45.0 NumberOfEmployees = 1 Console.WriteLine("Number of employees: " & NumberOfEmployees) Console.WriteLine("Employee name: " & EmployeeName) Console.WriteLine("Employee phone number: " & EmployeePhoneNumber) Console.WriteLine("Employee salary: " & EmployeeSalary) End Sub End Module

Number of employees: 1 Employee name: James Bond Employee phone number: 555-1212 Employee salary: 45

Define dublu i ieire valoarea sa


public class de testare public comun sub principal Dim am Ca Integer = 2 I * = 5 Console.WriteLine ( I ) Dim D Aa cum dubl = I / Console.WriteLine ( D ) End Sub clasa End 3

10 3.33333333333333

Sau original
public class Test public Shared Sub Main Dim I As Integer = 2 I *= 5 Console.WriteLine(I) Dim D As Double = I / 3 Console.WriteLine(D) End Sub

End class

10 3.33333333333333

Ia Epsilon de la Double
public class de testare public comun Sub Main Dim D Ca Double D = 5 Console.WriteLine ( D.Epsilon ) End Sub clasa End

4.94065645841247E-324

Sau original
public class de testare public comun Sub Main Dim D Ca Double D = 5 Console.WriteLine ( D.Epsilon ) End Sub clasa End

4.94065645841247E-324

Show precizie diferen de Single i Double (1)


Modulul Module1 Sub Main () Dim A Ca Dim B Ca Singur = 0.123456789012345 dublu = 0.123456789012345 & A ) & B )

Console.WriteLine ( "Single:" Console.WriteLine ( "Double:" End Sub End Module

Singur: 0.1234568 Dublu: .123456789012345

Sau original
Modulul Module1 Sub Main () Dim A Ca Dim B Ca Singur = 0.123456789012345 dublu = 0.123456789012345 & A ) & B )

Console.WriteLine ( "Single:" Console.WriteLine ( "Double:" End Sub End Module

Singur: 0.1234568 dubl: .123456789012345

Single dubl MaxValue i Dimensiune memorie (1)


Public class Tester Public comun Sub Dim Dim Dim Dim Dim Main

rezultat ca New System.Text.StringBuilder maxSingle Ca Singur = Single.MaxValue maxDouble cum dubl = Double.MaxValue sizeOfSingle Ca Integer = Runtime.InteropServices.Marshal.SizeOf ( maxSin sizeOfDouble Ca ntregi = Runtime.InteropServices . Marshal.SizeOf ( maxD

result.append ( "Dimensiune memorie de un singur (bytes):" ) result.AppendLine ( sizeOfSingle ) result.append ( "valoarea maxim a unui singur:" ) result.AppendLine ( maxSingle ) result.AppendLine () result.append ( "dimensiunea memoriei unui dublu (bytes):" ) result.AppendLine ( sizeOfDouble ) result.append ( "Valoarea maxim a unui dubla:" ) result.AppendLine ( maxDouble ) Console.WriteLine ( result.ToString ()) End Sub End Class

Dimensiunea memoriei unui singur (bytes): 4 Valoarea maxim a unui singur: 3.402823E +38

Dimensiunea memoriei unui dublu (bytes): 8 Valoarea maxim a unui dublu: 1.79769313486232E 308

Sau original
Public Class Tester Public Shared Sub Main Dim Dim Dim Dim Dim

result As New System.Text.StringBuilder maxSingle As Single = Single.MaxValue maxDouble As Double = Double.MaxValue sizeOfSingle As Integer = Runtime.InteropServices.Marshal.SizeOf(maxSingle.G sizeOfDouble As Integer = Runtime.InteropServices.Marshal.SizeOf(maxDouble.G

result.Append("Memory size of a Single (bytes): ") result.AppendLine(sizeOfSingle) result.Append("Maximum value of a Single: ") result.AppendLine(maxSingle) result.AppendLine() result.Append("Memory size of a Double (bytes): ") result.AppendLine(sizeOfDouble) result.Append("Maximum value of a Double: ") result.AppendLine(maxDouble) Console.WriteLine(result.ToString()) End Sub End Class

Memory size of a Single (bytes): 4 Maximum value of a Single: 3.402823E+38 Memory size of a Double (bytes): 8 Maximum value of a Double: 1.79769313486232E+308

Parse valoare dubl


Public class Tester Public comun sub principal Dim doubleParse cum dubl = Double.Parse ( "3.1416" ) Console.WriteLine ( doubleParse ) End Sub End Class

3.1416

Sau original
Public Class Tester Public Shared Sub Main Dim doubleParse As Double = Double.Parse("3.1416") Console.WriteLine(doubleParse) End Sub End Class

3.1416

Definirea i bucla prin matrice valoare dubl


Tester modul Sub Main () Dim Valorile () As Integer = { 100 , 200 , 300 , 400 , Dim MyValues ( 5 ) Ca Integer Dim Preuri () Aa cum dubl = { 25.5 , 4,95 , 33,4 } Dim I Ca Integer & "" ) 500 }

Pentru i = 0 la 4 Console.Write ( valori ( I ) nainte Console.WriteLine ()

Pentru i = 0 Pentru a Prices.GetUpperBound ( 0 ) Console.Write ( Preuri ( I ) & "" ) Urmtorul End Sub End Module

100 200 300 400 500 25,5 4,95 33,4

Sau original
Module Tester Sub Main() Dim Values() As Integer = {100, 200, 300, 400, 500} Dim MyValues(5) As Integer Dim Prices() As Double = {25.5, 4.95, 33.4} Dim I As Integer For I = 0 To 4 Console.Write(Values(I) & " ")

Next Console.WriteLine() For I = 0 To Prices.GetUpperBound(0) Console.Write(Prices(I) & " ") Next End Sub End Module

100 200 300 400 500 25.5 4.95 33.4

Read valoare dubl de la tastatur


Modulul Module1 Sub Main () Dim Salariul Ca dubl Console.Write ( "Salariu:" ) Salariul = Console.ReadLine () Console.WriteLine ( salariu )

End Sub End Module

Salariu: 123 123

Sau original
Module Module1 Sub Main() Dim Salary As Double Console.Write("Salary: ") Salary = Console.ReadLine() Console.WriteLine(Salary) End Sub End Module

Salary: 123 123

Convert Double la ntreg

Modulul Module1 Sub Main () Dim dblValue Ca dubl Dim intValue Ca Integer dblValue = 1.2345678 intValue = dblValue Console.WriteLine ( intValue ) End Sub End Module

Sau original
Module Module1 Sub Main() Dim dblValue As Double Dim intValue As Integer dblValue = 1.2345678 intValue = dblValue Console.WriteLine(intValue) End Sub End Module

Parse (analiz)dubl
Importurile System

MyModule Modulul Sub Main () Dim num cum Dim Dim denom res Ca cum dubl = Double.Parse ( "12.12" ) dubl = Double.Parse ( "2.2" )

dubl = num / denom

Console.WriteLine ( res ) End Sub End Module

5.50909090909091

Sau original

Imports System Module MyModule Sub Main() Dim num As Double = Double.Parse("12.12") Dim denom As Double = Double.Parse("2.2") Dim res As Double = num / denom Console.WriteLine(res) End Sub End Module

5.50909090909091

Double.IsNaN ()
Importurile System

MyModule Modulul Sub Main () Dac ( Double.IsNaN ( "1.2" )) Apoi, Console.WriteLine ( "Nu este un numr." ) End If End Sub End Module

Sau original

Imports System Module MyModule Sub Main() If (Double.IsNaN("1.2")) Then Console.WriteLine("Not a Number.") End If End Sub End Module

Double.IsPositiveInfinity ()
Importurile System

MyModule Modulul

Sub

Main ()

n cazul n care ( Double.IsPositiveInfinity ( "999999999999999999999999999999999" Console.WriteLine ( "infinit pozitiv." ) End If End Sub End Module

Sau original

Imports System Module MyModule Sub Main() If (Double.IsPositiveInfinity("99999999999999999999 9999999999999")) Then Console.WriteLine("Positive infinity.") End If End Sub End Module

Double.IsNegativeInfinity ()
Importurile System

MyModule Modulul Sub Main () Apoi,

n cazul n care ( Double.IsNegativeInfinity ( ".0000000000000001" )) Console.WriteLine ( "minus infinit." ) End If End Sub End Module

Sau original

Imports System Module MyModule Sub Main() If (Double.IsNegativeInfinity("0.0000000000000001") ) Then

Console.WriteLine("Negative infinity.") End If End Sub End Module

Catch OverflowException
Public class Exemplu public comun Sub Dim valoarea Main () Ca String

valoare =

este n afara intervalului de tip Double. " , valoare ) End ncercai End Sub End Class

Sau original

Public Class Example Public Shared Sub Main() Dim value As String

value = Double.MaxValue.ToString() Try Console.WriteLine(Double.Parse(value)) Catch e As OverflowException Console.WriteLine("{0} is outside the range of the Double type.", value) End Try End Sub End Class

Calculation cu un singur
public class de testare public comun sub principal Dim Suma Ca Singur Dim Discount Ca Singur Dim DiscAmount Ca Single

Suma = 24500 Discount = 0,35 DiscAmount = Suma * ( 1 - Discount ) Console.WriteLine ( "pretul este: $" & DiscAmount ) End Sub clasa End

Pretul este de: 15,925 dolari

Sau original
public class Test public Shared Sub Main Dim Amount As Single Dim Discount As Single Dim DiscAmount As Single Amount = 24500 Discount = 0.35 DiscAmount = Amount * (1 - Discount) Console.WriteLine("Your price is: $" & DiscAmount) End Sub End class

Your price is: $15925

Decimal.Compare
public class de testare public comun Sub principale Dim D1, D2 Ca zecimale D1 = 10 D2 = 5.7 Console.WriteLine ( Decimal.Compare ( D1, D2 )) End Sub clasa End

Sau original
public class Test public Shared Sub Main Dim D1, D2 As Decimal D1 = 10 D2 = 5.7

Console.WriteLine(Decimal.Compare(D1, D2)) End Sub End class

Decimal.Divide
public class de testare public comun Sub principale Dim D1, D2 Ca zecimale D1 = 10 D2 = 5.7 Console.WriteLine ( Decimal.Divide ( D1, D2 )) End Sub End clasa

1.7543859649122807017543859649

Sau original
public class Test public Shared Sub Main Dim D1, D2 As Decimal D1 = 10 D2 = 5.7 Console.WriteLine(Decimal.Divide(D1, D2)) End Sub End class

1.7543859649122807017543859649

Decimal.Floor
public class de testare public comun Sub principal Console.WriteLine ( Decimal.Floor ( 5,7 )) End Sub End clasa

Sau original
public class Test

public Shared Sub Main Console.WriteLine(Decimal.Floor(5.7)) End Sub End class

Decimal.GetBits
public class de testare public comun Sub principale Dim D1, D2 Ca zecimale D1 = 10 D2 = 5.7 Console.WriteLine ( Decimal.GetBits ( 3 ) . GetValue ( 0 )) End Sub clasa End

Sau original
public class Test public Shared Sub Main Dim D1, D2 As Decimal D1 = 10 D2 = 5.7 Console.WriteLine(Decimal.GetBits(3).GetValue(0)) End Sub End class

Calculul Decmimal
public class de testare public comun sub principal Dim DEC1, DEC2 Ca Zecimal DEC1 = 100 DEC2 = 200 DEC1 = DEC1 + DEC2 Console.WriteLine ( DEC1 ) DEC1 = - DEC1 Console.WriteLine ( DEC1 )

DEC1 = + + DEC2 Console.WriteLine ( DEC1 ) End Sub clasa End

300 300 200

Sau original
public class Test public Shared Sub Main Dim Dec1, Dec2 As Decimal Dec1 = 100 Dec2 = 200 Dec1 = Dec1 + Dec2 Console.WriteLine(Dec1) Dec1 = --Dec1 Console.WriteLine(Dec1) Dec1 = ++Dec2 Console.WriteLine(Dec1) End Sub End class

300 300 200

mprii zecimal dublu


Public class Tester Public comun Sub Dim Dim Dim

Main

rezultat ca New System.Text.StringBuilder maxDecimal Ca Zecimal = Decimal.MaxValue sizeOfDecimal Ca Integer = Runtime.InteropServices.Marshal.SizeOf ( maxDe

result.append ( "dimensiunea memoriei unui Decimal (bytes):" ) result.AppendLine ( sizeOfDecimal ) result.append ( "valoarea maxim a unui Zecimal:" ) result.AppendLine ( maxDecimal ) result.append ( "mprit cu un milion de : " ) result.AppendLine ( maxDecimal / 1000000D )

result.append ( "1D / 3D:" ) result.AppendLine ( 1D / 3D ) Console.WriteLine ( result.ToString ()) End Sub End Class

Dimensiunea memoriei de o zecimal (bytes): 16 Valoarea maxim a unui Zecimal: 79228162514264337593543950335 mprit de un milion: 79228162514264337593543.950335 1D / 3D: .3333333333333333333333333333

Sau original
Public Class Tester Public Shared Sub Main

Dim result As New System.Text.StringBuilder Dim maxDecimal As Decimal = Decimal.MaxValue Dim sizeOfDecimal As Integer = Runtime.InteropServices.Marshal.SizeOf(maxDecimal result.Append("Memory size of a Decimal (bytes): ") result.AppendLine(sizeOfDecimal) result.Append("Maximum value of a Decimal: ") result.AppendLine(maxDecimal) result.Append("Divided by one million: ") result.AppendLine(maxDecimal / 1000000D) result.Append("1D / 3D: ") result.AppendLine(1D / 3D) Console.WriteLine(result.ToString()) End Sub End Class

Memory size of a Decimal (bytes): 16 Maximum value of a Decimal: 79228162514264337593543950335 Divided by one million: 79228162514264337593543.950335 1D / 3D: 0.3333333333333333333333333333

MinValue i MaxValue de Decimal


public class de testare public comun sub principal Dim dNum Ca zecimale Console.WriteLine ( "Zecimal:" End Sub End clasa

& dNum.MinValue i

"a"

si dNum.MaxValue

Zecimal: -79228162514264337593543950335-79228162514264337593543950335

Sau original
public class Test public Shared Sub Main Dim dNum As Decimal Console.WriteLine("Decimal: " & dNum.MinValue & " to " & dNum.MaxValue) End Sub End class

Decimal: -79228162514264337593543950335 to 79228162514264337593543950335

Face calculul ntre ntreg i zecimale


public class de testare public comun sub principal Dim Dim metri Ca Integer inch Ca Zecimal

M = 23 inch = Metri * 39.37 Console.WriteLine ( "Metri:" M = Metri + 1 Console.WriteLine ( "Metri:" M + = 1 Console.WriteLine ( "Metri:" End Sub clasa End

& Metri ) & Metri ) & Metri )

Metri: 23 Metri: 24 Metri: 25

Sau original
public class Test public Shared Sub Main Dim Meters As Integer Dim Inches As Decimal Meters = 23 Inches = Meters * 39.37 Console.WriteLine("Meters: " & Meters)

Meters = Meters + 1 Console.WriteLine("Meters: " & Meters) Meters += 1 Console.WriteLine("Meters: " & Meters) End Sub End class

Meters: 23 Meters: 24 Meters: 25

Declaraia Char
public class de testare public comun sub principal Dim Char1 Ca Char = "O" Dim Char2 Ca Char = CChar ( "A" ) Dim Char3 Ca Char = "A" C Console.WriteLine ( Char1 & End Sub End clasa "" & Char2 & "" & Char3 )

AAA

Sau original
public class Test public Shared Sub Dim Char1 As Dim Char2 As Dim Char3 As Main Char = "A" Char = CChar("A") Char = "A"c

Console.WriteLine(Char1 & " " & Char2 & " " & Char3) End Sub End class

A A A

Use Ctype pentru a converti Char la String


Importuri System.Collections ConvertToString

public class

public comun sub principal Dim c Ca Char = "O" C Dim s Ca String = "" s = Ctype ( c, String ) Console.WriteLine ( s ) End Sub End clasa

Declare variabil ir i valoarea aloca


Modulul Module1 Sub Main() Dim EmployeeName As String Dim EmployeePhoneNumber As String Dim EmployeeSalary As Double Dim NumberOfEmployees As Integer EmployeeName = "James Bond" EmployeePhoneNumber = "555-1212" EmployeeSalary = 45.0 NumberOfEmployees = 1 Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine End Sub End Module ( ( ( ( "Numrul de angajai:" & NumberOfEmployees ) "Nume Angajat:" & EmployeeName ) "numr de telefon Angajat:" & EmployeePhoneNumber ) "salariu Angajat:" & EmployeeSalary )

Numrul de angajai: 1 Numele angajatului: James Bond Numrul de telefon Angajat: 555-1212 Salariul angajatului: 45

Sau original
Module Module1 Sub Main() Dim EmployeeName As String Dim EmployeePhoneNumber As String Dim EmployeeSalary As Double Dim NumberOfEmployees As Integer EmployeeName = "James Bond" EmployeePhoneNumber = "555-1212" EmployeeSalary = 45.0 NumberOfEmployees = 1 Console.WriteLine("Number of employees: " & NumberOfEmployees) Console.WriteLine("Employee name: " & EmployeeName) Console.WriteLine("Employee phone number: " & EmployeePhoneNumber)

Console.WriteLine("Employee salary: " & EmployeeSalary) End Sub End Module

Number of employees: 1 Employee name: James Bond Employee phone number: 555-1212 Employee salary: 45

String.Empty
Opiunea stricte cu privire la Public Modul modMain Public Sub Main () Console.WriteLine ( String.Empty ) End Sub End Module

Sau original

Option Strict On Public Module modMain Public Sub Main() Console.WriteLine(String.Empty) End Sub End Module

Demonstrating constructori clasa String


Tester modul Sub Main () Dim characterArray Ca Char () Dim citate Ca Char = ChrW ( 34 ) Dim originalString, ir1, ir2, string3, string4 characterArray = New Char () { "A" c, originalString = "test" string1 = originalString ir2 = new String ( characterArray ) string3 = new String ( characterArray, string4 = new String ( "C" C, 5 ) Console.WriteLine ( ir1 ) Console.WriteLine ( "ir2 =" & string2 "B" c,

Ca

String "D" c, "E" c, "F" c, ""

"C" C,

6 ,

3 )

Console.WriteLine ( "string3 =" Console.WriteLine ( "string4 =" End Sub End Module 'M Ain

& string3 & string4

) )

test ir2 = ABCDEF GH string3 = GH string4 = CCCCC

Sau original
Module Tester Sub Main() Dim characterArray As Char() Dim quotes As Char = ChrW(34) Dim originalString, string1, string2, string3, string4 As String

characterArray = New Char() {"A"c, "B"c, "C"c, "D"c, "E"c, "F"c, " "c, "G"c, "H"c} originalString = "test" string1 = originalString string2 = New String(characterArray) string3 = New String(characterArray, 6, 3) string4 = New String("C"c, 5) Console.WriteLine(string1) Console.WriteLine("string2 = " & string2 ) Console.WriteLine("string3 = " & string3 ) Console.WriteLine("string4 = " & string4 ) End Sub ' Main End Module

test string2 = ABCDEF GH string3 = GH string4 = CCCCC

Join string
Importuri System.Collections

public class de testare public comun sub principal Dim e () Ca String = { "unu" , Dim S2 Ca String s2 = s2.Join ( "," , s )

"doi" ,

"trei" }

"o

Console.WriteLine ( S2 ) End Sub End clasa

Sau original

Imports System.Collections public class Test public Shared Sub Main Dim s() As String = {"one", "two", "thre e"} 'a string array Dim s2 As String s2 = s2.Join(", ", s) Console.WriteLine(s2) End Sub End class

Copy din string1 n caracter Array


Tester modul Sub Main () Dim string1 Ca String Dim characterArray Ca Char () Dim i Ca Integer Dim citate Ca Char = ChrW ( 34 ) string1 = "hello there" characterArray = New Char ( 5 ) {} string1.CopyTo ( 0 , characterArray, 0 , 5 )

Pentru i = 0 Pentru a characterArray.GetUpperBound ( 0 ) Console.WriteLine ( characterArray ( i )) Urmtorul End Sub End Module 'M Ain

h e L L o

Sau original
Module Tester

Sub Main() Dim string1 As String Dim characterArray As Char() Dim i As Integer Dim quotes As Char = ChrW(34) string1 = "hello there" characterArray = New Char(5) {} string1.CopyTo(0, characterArray, 0, 5) For i = 0 To characterArray.GetUpperBound(0) Console.WriteLine(characterArray(i)) Next End Sub ' Main End Module

h e l l o

String Lungime proprietate


Tester modul Sub Main () Dim string1 Ca String Dim characterArray Ca Char () Dim i Ca Integer Dim citate Ca Char = ChrW ( 34 ) string1 = "hello there" characterArray = New Char ( 5 ) {} Console.WriteLine ( "Durata de string1:" End Sub End Module 'M Ain & string1.Length )

Durata de string1: 11

Demonstrating GetHashCode metoda de clasa String


Tester modul Sub Main ()

Dim Dim

string1 string2

Ca Ca

String = String =

"Hello" "Hello"

Console.WriteLine ( string1.GetHashCode ()) Console.WriteLine ( string2.GetHashCode ()) End Sub End Module 'M Ain

-695839 -694847

Sau original
Module Tester Sub Main() Dim string1 As String = "hello" Dim string2 As String = "Hello" Console.WriteLine(string1.GetHashCode() ) Console.WriteLine(string2.GetHashCode()) End Sub ' Main End Module

-695839 -694847

Insert sub ir de index


Opiunea stricte privind importurile System Clasa Tester public comun Sub Main () Dim S1 Ca String = "abcd" Dim S2 Ca String = "ABCD" Dim s3 Ca String = "AAAAs" s3 = s3 si "dezvoltarea" Dim s5 Ca String = String.Copy ( S2 ) " Console.WriteLine ( "s5 copiat de la S2: {0}" , s5 ) Console.WriteLine ( "String S3 este {0} caractere." , s5.Length ) Console.WriteLine ( "s3: {0}" , S3 ) "h vechi locaia prevede ca un ntreg

Dim

locaie

Ca

Integer = s3.IndexOf ( "A" ) "u" )

Dim S10 Ca String = s3.Insert ( locaie, Console.WriteLine ( "S10: {0}" , S10 ) End Sub "Ma n End clasa "Te ster

s5 copiate de la S2: ABCD ir S3 este de 4 caractere. s3: AAAAs dezvoltare Excepie netratat: System.ArgumentOutOfRangeException: Index a fost din Trebuie s fie non-negativ e i mai mic dect dimensiunea de colectare. Nume parametru: startIndex la System.String.Insert (Int32 startIndex, valoarea String) la Tester.Main ()

Sau original
Option Strict On Imports System Class Tester Public Shared Dim s1 As Dim s2 As Dim s3 As s3 = s3 & Sub Main( ) String = "abcd" String = "ABCD" String = "AAAAs " "development"

Dim s5 As String = String.Copy(s2) ' Console.WriteLine("s5 copied from s2: {0}", s5) Console.WriteLine("String s3 is {0} characters long. ",s5.Length) Console.WriteLine("s3: {0}", s3) ' hold the location of provides as an integer Dim location As Integer = s3.IndexOf("a") Dim s10 As String = s3.Insert(location, "u") Console.WriteLine("s10: {0}", s10) End Sub 'Main End Class 'Tester

s5 copied from s2: ABCD String s3 is 4 characters long. s3: AAAAs development

Unhandled Exception: System.ArgumentOutOfRangeException: Index was out of Must be non-negativ

e and less than the size of the collection. Parameter name: startIndex at System.String.Insert(Int32 startIndex, String value) at Tester.Main()

Metoda introduce returneaz irul rezultat


public class de testare public comun Sub principale Dim S1 Ca nou String ( "salut" ) s1.Insert ( 4 , "SDS" ), "NU ES nu a schimbat S1!! s1 = s1.Insert ( 8 , "s" ) " CH anges salut Salutri Console.WriteLine ( s1.Length ) Console.WriteLine ( S1 ) End Sub clasa End

9 Salutri

Sau original
public class Test public Shared Sub Main Dim s1 As New String("Greeting") s1.Insert(4, "sdss") 'DOES NOT CHANGE S1!!!! s1 = s1.Insert(8, "s") 'changes Greeting to Greetings Console.WriteLine(s1.Length) Console.WriteLine(s1) End Sub End class

9 Greetings

SubString
Opiunea stricte privind importurile System Clasa Tester public comun Sub Main () Dim S1 Ca String = "Unul Dou Trei Patru" Dim indicele Ca Integer 1 ))

index = s1.LastIndexOf ( "" ) Dim S2 Ca String = s1.Substring (( index +

s1 = s1.Substring ( 0 , indicele ) index = s1.LastIndexOf ( "" ) Dim s3 Ca String = s1.Substring (( index + 1 ))

s1 = s1.Substring ( 0 , indicele ) index = s1.LastIndexOf ( "" ) Dim s4 Ca String = s1.Substring (( index + 1 ))

s1 = s1.Substring ( 0 , indicele ) index = s1.LastIndexOf ( "" ) Dim s5 Ca String = s1.Substring (( index + ( ( ( ( ( "s1: {0}" , S1 ) "S2: {0}" , S2 ) "s3: {0}" , s3 ) "S4: { 0} " , S4 ) {0} ":" S5 , S5 ) 1 ))

Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine End Sub "Ma n End clasa "Te ster

S1: S2: s3: S4: s5:

One Patru Trei Dou O

Sau original
Option Strict On Imports System Class Tester Public Shared Sub Main( ) Dim s1 As String = "One Two Three Four" Dim index As Integer index = s1.LastIndexOf(" ") Dim s2 As String = s1.Substring((index + 1)) s1 = s1.Substring(0, index) index = s1.LastIndexOf(" ") Dim s3 As String = s1.Substring((index + 1)) s1 = s1.Substring(0, index) index = s1.LastIndexOf(" ")

Dim s4 As String = s1.Substring((index + 1)) s1 = s1.Substring(0, index) index = s1.LastIndexOf(" ") Dim s5 As String = s1.Substring((index + 1)) Console.WriteLine("s1: Console.WriteLine("s2: Console.WriteLine("s3: Console.WriteLine("s4: Console.WriteLine("s5: End Sub 'Main End Class 'Tester {0}", {0}", {0}", {0}", {0}", s1) s2) s3) s4) s5)

s1: s2: s3: s4: s5:

One Four Three Two One

Change la spaiu

Public class Tester Public comun Sub principale Dim file Ca String = "Acest lucru este ~ ~ ~ o ~ ~ ~ ~ file string" . nlocu Dim spaii Ca String = TabsToSpaces ( file, 8 ) Dim perioade Ca String = spaces.Replace ( "" c, "." c ) Console.WriteLine ( file ) Console.WriteLine ( spaii ) Console.WriteLine ( perioade ) End Sub Publice partajate Dim Dim TabsToSpaces funcii ( sursa ByVal Ca

String, ByVal ului vor fi

rezultat ca New System.Text.StringBuilder contra Ca Integer

Pentru contor = 0 Pentru a source.Length - 1 Dac ( source.Chars ( contor ) = vbTab ) Atunci Do result.append ( Space ( 1 )) Bucl pn la (( Mod ului vor result.Length ) Else result.append ( source.Chars ( counter )) End If Urmtor contra result.ToString retur () End Function End Class

0 )

Acesta este un ir cu file Acesta este un ir cu file Acest lucru .... este .............. un ....... file .................. s

Sau original
Public Class Tester Public Shared Sub Main Dim tabs As String = "This~is~~a~tabbed~~~string".Replace("~"c, vbTab) Dim spaces As String = TabsToSpaces(tabs, 8) Dim periods As String = spaces.Replace(" "c, "."c) Console.WriteLine(tabs) Console.WriteLine(spaces) Console.WriteLine(periods) End Sub

Public Shared Function TabsToSpaces(ByVal source As String, ByVal tabSize As Integer Dim result As New System.Text.StringBuilder Dim counter As Integer For counter = 0 To source.Length - 1 If (source.Chars(counter) = vbTab) Then Do result.Append(Space(1)) Loop Until ((result.Length Mod tabSize) = 0) Else result.Append(source.Chars(counter)) End If Next counter Return result.ToString() End Function End Class

This is a tabbed string This is a tabbed string This....is..............a.......tabbed..................string

Catch pentru String.Substring


public class de testare public comun sub principal Dim strCaption Ca String strCaption = "Rspuns" 1 ))

ncercai s Console.WriteLine ( strCaption.Substring ( 10 , Prinde ex Ca excepie Console.WriteLine ( ex.Message )

End ncercai End Sub clasa End

startIndex nu poate fi mai mare dect lungimea irului. Nume parametru: startIndex

Sau original
public class Test public Shared Sub Main Dim strCaption As String strCaption = "Answer" Try Console.WriteLine(strCaption.Substring(10, 1)) Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub End class

startIndex cannot be larger than length of string. Parameter name: startIndex

Face o copie de referinta


Public class Tester Public comun Sub principal Dim Arraya () Ca String = { "One" , "doi" , Console.WriteLine ( Join ( Arraya, "," )) Dim arrayB () Ca String = { "A" , Console.WriteLine ( Intrare ( arrayB, "trei" , "D" , "patru" , "E" ,

"Cinci" , "F" ,

"B" , "C" , "," ))

"E" ,

"- ---- face o copie de referinta. Dim arrayC () Ca String = Arraya Console.WriteLine ( Join ( arrayC, "," )) End Sub End Class

Unu, doi, trei, patru, cinci, ase A, B, C, D, E, E, F, G, H Unu, doi, trei, patru, cinci, ase

Sau original
Public Class Tester Public Shared Sub Main Dim arrayA() As String = {"One", "Two", "Three", "Four", "Five", "Six"} Console.WriteLine(Join(arrayA, ",")) Dim arrayB() As String = {"A", "B", "C", "D", "E", "E", "F", "G", "H"} Console.WriteLine(Join(arrayB, ",")) ' ----- Make a reference copy. Dim arrayC() As String = arrayA Console.WriteLine(Join(arrayC, ",")) End Sub End Class

One,Two,Three,Four,Five,Six A,B,C,D,E,E,F,G,H One,Two,Three,Four,Five,Six

Check un numr de carte de credit


"Q uote de la "Vi Sual de baz 2005 Soluii Carte de bucate pentru VB 2005 "de Tim Patrick ( Autor ) , John Craig ( autor ) "# Editura: O 'Re illy Media, Inc ( septembrie 21 , 2006 ) "# Limba: englez "# ISBN- 10 : 0596101775 "# ISBN- 13 : 978 - 0596101770 Public class Tester Public comun Sub Programatorii

principal

Console.WriteLine ( VerifyCreditCard ( "123123123123123123" )) End Sub Private comun VerifyCreditCard Funcia ( cardNumber ByVal Ca String ) Ca Boole "- ---- Avnd un numr de card, asigurai-v c este valabil. Aceast metod " folosete algoritmul Luhn a verifica numrul. Aceast rutin ' presupune c cardNumber conine doar

"- . ---- Efectuarea unor verificri iniiale useCard = Trim ( cardNumber ) Dac ( IsNumeric ( useCard ) = false ), apoi s se ntoarc false "- ---- separa ultima cifr, cifr de control. Pentru cardurile cu " un numr impar de cifre, prefixului cu un zero.

Dac (( Len ( useCard ) Mod 2 ) <> 0 ) Apoi useCard = "0" checkdigit = useCard.Substring ( Len ( useCard ) - 1 , 1 ) useCard = useCard.Substring ( 0 , Len ( useCard ) - 1 )

& useCard

"- ---- Procesul de fiecare cifr. digitTotal = 0 pentru contor = 1 Pentru a Len ( useCard ) Dac (( contra Mod 2 ) = 1 ) Atunci "- ---- Aceasta este o poziie cifre ciudat. Un numr dublu. holdValue = CInt ( Mid ( useCard, contor, 1 )) * 2 Dac ( holdValue> 9 ) Atunci "- ---- Break cifre ( de exemplu, 19 devine 1 + 9 ) . digitTotal + = ( holdValue \ 10 ) + ( holdValue - 10 ) Altfel digitTotal + = holdValue End Daca Altele "- ---- Aceasta este o poziie i cifre. Pur i simplu adauga. digitTotal + = CInt ( Mid ( useCard, contor, 1 )) End If contra Urmtor "- ---- Calculai 10 's completare a dou valori. calcDigit = 10 - ( Mod digitTotal 10 ) n cazul n care ( calcDigit = 10 ) Apoi calcDigit = 0 Dac ( checkdigit = calcDigit ) atunci return true Else return false End Function End Class

Fals

Sau original
Public Class Tester Public Shared Sub Main Console.WriteLine(VerifyCreditCard("123123123123123123")) End Sub Private Shared Function VerifyCreditCard(ByVal cardNumber As String) As Boolean ' ----- Given a card number, make sure it is valid. This method ' uses the Luhn algorithm to verify the number. This routine ' assumes that cardNumber contains only digits. Dim counter As Integer Dim digitTotal As Integer Dim holdValue As Integer Dim checkDigit As Integer Dim calcDigit As Integer Dim useCard As String ' ----- Perform some initial checks. useCard = Trim(cardNumber) If (IsNumeric(useCard) = False) Then Return False ' ----- Separate out the last digit, the check digit. For cards with ' an odd number of digits, prepend with a zero. If ((Len(useCard) Mod 2) <> 0) Then useCard = "0" & useCard checkDigit = useCard.Substring(Len(useCard) - 1, 1)

useCard = useCard.Substring(0, Len(useCard) - 1) ' ----- Process each digit. digitTotal = 0 For counter = 1 To Len(useCard) If ((counter Mod 2) = 1) Then ' ----- This is an odd digit position. Double the number. holdValue = CInt(Mid(useCard, counter, 1)) * 2 If (holdValue > 9) Then ' ----- Break the digits (e.g., 19 becomes 1+9). digitTotal += (holdValue \ 10) + (holdValue - 10) Else digitTotal += holdValue End If Else ' ----- This is an even digit position. Simply add it. digitTotal += CInt(Mid(useCard, counter, 1)) End If Next counter ' ----- Calculate the 10's complement of both values. calcDigit = 10 - (digitTotal Mod 10) If (calcDigit = 10) Then calcDigit = 0 If (checkDigit = calcDigit) Then Return True Else Return False End Function End Class

False

Citii valoarea String de la tastatur


Modulul Module1 Sub Main () Dim Prenume Ca String Console.Write ( "Name:" ) Prenumele = Console.ReadLine () Console.WriteLine ( Prenume ) End Sub End Module

Nume: Numele nume

Sau original
Module Module1 Sub Main() Dim FirstName As String Console.Write("Name: ") FirstName = Console.ReadLine() Console.WriteLine(FirstName)

End Sub End Module

Name: name name

Insert sub ir de index


Opiunea stricte privind importurile System Clasa Tester public comun Sub Main () Dim S1 Ca String = "abcd" Dim S2 Ca String = "ABCD" Dim s3 Ca String = "AAAAs" s3 = s3 si "dezvoltarea" Dim s5 Ca String = String.Copy ( S2 ) " Console.WriteLine ( "s5 copiat de la S2: {0}" , s5 ) Console.WriteLine ( "String S3 este {0} caractere." , s5.Length ) Console.WriteLine ( "s3: {0}" , S3 ) "h vechi locaia prevede ca un ntreg Dim locaie Ca Integer = s3.IndexOf ( "A" ) Dim S10 Ca String = s3.Insert ( locaie, Console.WriteLine ( "S10: {0}" , S10 ) End Sub "Ma n End clasa "Te ster "u" )

s5 copiate de la S2: ABCD ir S3 este de 4 caractere. s3: AAAAs dezvoltare Excepie netratat: System.ArgumentOutOfRangeException: Index a fost din Trebuie s fie non-negativ e i mai mic dect dimensiunea de colectare. Nume parametru: startIndex la System.String.Insert (Int32 startIndex, valoarea String) la Tester.Main ()

Sau original
ption Strict On Imports System

Class Tester Public Shared Dim s1 As Dim s2 As Dim s3 As s3 = s3 &

Sub Main( ) String = "abcd" String = "ABCD" String = "AAAAs " "development"

Dim s5 As String = String.Copy(s2) ' Console.WriteLine("s5 copied from s2: {0}", s5) Console.WriteLine("String s3 is {0} characters long. ",s5.Length) Console.WriteLine("s3: {0}", s3) ' hold the location of provides as an integer Dim location As Integer = s3.IndexOf("a") Dim s10 As String = s3.Insert(location, "u") Console.WriteLine("s10: {0}", s10) End Sub 'Main End Class 'Tester

s5 copied from s2: ABCD String s3 is 4 characters long. s3: AAAAs development

Unhandled Exception: System.ArgumentOutOfRangeException: Index was out of Must be non-negativ e and less than the size of the collection. Parameter name: startIndex at System.String.Insert(Int32 startIndex, String value) at Tester.Main()

String (ir)CONCATENATE
Opiunea stricte privind importurile Sistemul de clasa Tester public comun Sub Main () Dim S1 Ca String = "abcd" Dim s2 Ca String = "ABCD" "C oncatenation metoda Dim s3 Ca String = String.Concat ( S1, S2 ) Console.WriteLine ( "s3 concatenate din S1 i S2: {0}" , s3 ) End Sub "Ma n End clasa "Te ster

s3 concatenate din S1 i S2: abcdABCD

Sau original
Option Strict On Imports System Class Tester Public Shared Sub Main( ) Dim s1 As String = "abcd" Dim s2 As String = "ABCD" ' concatenation method Dim s3 As String = String.Concat(s1, s2) Console.WriteLine("s3 concatenated from s1 and s2: {0}", s3) End Sub 'Main End Class 'Tester

s3 concatenated from s1 and s2: abcdABCD

Use operator suprancrcat


Opiunea stricte privind importurile Sistemul de clasa Tester public comun Sub Main () Dim S1 Ca String = "abcd" Dim s2 Ca String = "ABCD" Dim s4 Ca String = S1 si S2 Console.WriteLine ( "S4 concatenate la S1 si S2:" + S4 ) End Sub "Ma n End clasa "Te ster

s4 concatenate din S1 si S2: abcdABCD

Original
Option Strict On Imports System Class Tester Public Shared Sub Main( ) Dim s1 As String = "abcd" Dim s2 As String = "ABCD" Dim s4 As String = s1 & s2 Console.WriteLine("s4 concatenated from s1 & s2:"+ s4) End Sub 'Main End Class 'Tester

s4 concatenated from s1 & s2: abcdABCD

Create String aleatorie de matrice String


Importuri System.Collections

Modulul Exemplu Public Sub Main () Const WORD_SIZE Ca Dim cuvinte () Ca Dim Dim Dim

Integer = 4 String = { "1234" , duble Ca String

"5678" ,

"90qw" ,

"qwer"

chei ( WORD_SIZE ) Ca literele ( WORD_SIZE ) RND Ca aleatorie ()

Pentru fiecare cuvnt ca ir de caractere n cuvinte pentru CTR Ca Integer = 0 Pentru a word.Length chei ( CTR ) = rnd.NextDouble () = word.Chars ( CTR )

literele ( CTR ) Urmtorul

Array.Sort ( chei, scrisori,

0 , WORD_SIZE, Comparer.Default )

Dim scrambledWord Ca String = String.Concat ( litere ( 0 ) , litere ( 1 ) , Console.WriteLine ( cuvnt ) Console.WriteLine ( scrambledWord ) Urmtor End Sub End Module

Original

Imports System.Collections Module Example Public Sub Main() Const WORD_SIZE As Integer = 4 Dim words() As String = { "1234", "5678", "90qw", "qwer" } Dim keys(WORD_SIZE) As Double Dim letters(WORD_SIZE) As String Dim rnd As New Random() For Each word As String In words

For ctr As Integer = 0 To word.Length - 1 keys(ctr) = rnd.NextDouble() letters(ctr) = word.Chars(ctr) Next Array.Sort(keys, letters, 0, WORD_SIZE, Compar er.Default) Dim scrambledWord As String = String.Concat(le tters(0), letters(1), letters(2), letters(3)) Console.WriteLine(word) Console.WriteLine(scrambledWord) Next End Sub End Module
Metoda concat cu o gam de coarde.

Importurile System Clasa publice ConcatTest Shared public Sub Main () Dim s Ca String () = { "Bun ziua" , "i" , "bun venit" , "a" , "acest lucru" , "demo!" } Console.WriteLine ( String.Concat ( e )) Array.Sort ( e ) Console.WriteLine ( String.Concat ( e )) End Sub Sfritul Clasa

Original Imports System

Public Class ConcatTest Public Shared Sub Main() Dim s As String() = {"hello ", "and ", "welcome ", "to ", "this ", "demo! "} Console.WriteLine(String.Concat(s)) Array.Sort(s) Console.WriteLine(String.Concat(s)) End Sub End Class

SubString(subir)
Opiunea stricte privind importurile System Clasa Tester public comun Sub Main () Dim S1 Ca String = "Unul Dou Trei Patru" Dim indicele Ca Integer 1 ))

index = s1.LastIndexOf ( "" ) Dim S2 Ca String = s1.Substring (( index + s1 = s1.Substring ( 0 , indicele ) index = s1.LastIndexOf ( "" ) Dim s3 Ca String = s1.Substring (( index +

1 ))

s1 = s1.Substring ( 0 , indicele ) index = s1.LastIndexOf ( "" ) Dim s4 Ca String = s1.Substring (( index + 1 ))

s1 = s1.Substring ( 0 , indicele ) index = s1.LastIndexOf ( "" ) Dim s5 Ca String = s1.Substring (( index + ( ( ( ( ( "s1: {0}" , S1 ) "S2: {0}" , S2 ) "s3: {0}" , s3 ) "S4: { 0} " , S4 ) {0} ":" S5 , S5 ) 1 ))

Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine End Sub "Ma n End clasa "Te ster

S1: S2: s3: S4: s5:

One Patru Trei Dou O

Original
Option Strict On Imports System Class Tester Public Shared Sub Main( ) Dim s1 As String = "One Two Three Four" Dim index As Integer index = s1.LastIndexOf(" ") Dim s2 As String = s1.Substring((index + 1)) s1 = s1.Substring(0, index) index = s1.LastIndexOf(" ") Dim s3 As String = s1.Substring((index + 1)) s1 = s1.Substring(0, index) index = s1.LastIndexOf(" ") Dim s4 As String = s1.Substring((index + 1)) s1 = s1.Substring(0, index) index = s1.LastIndexOf(" ") Dim s5 As String = s1.Substring((index + 1)) Console.WriteLine("s1: Console.WriteLine("s2: Console.WriteLine("s3: Console.WriteLine("s4: Console.WriteLine("s5: End Sub 'Main End Class 'Tester {0}", {0}", {0}", {0}", {0}", s1) s2) s3) s4) s5)

s1: s2: s3: s4: s5:

One Four Three Two One

Demonstrating constructori clasa String

Tester modul Sub Main () Dim characterArray Ca Char () Dim citate Ca Char = ChrW ( 34 ) Dim originalString, ir1, ir2, string3, string4 characterArray = New Char () { "A" c, originalString = "test" string1 = originalString ir2 = new String ( characterArray ) string3 = new String ( characterArray, string4 = new String ( "C" C, 5 ) Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine End Sub End Module 'M Ain ( ( ( ( "B" c,

Ca

String "D" c, "E" c, "F" c, ""

"C" C,

6 ,

3 )

ir1 ) "ir2 =" & string2 ) "string3 =" & string3 "string4 =" & string4

) )

test ir2 = ABCDEF GH string3 = GH string4 = CCCCC

Original
Module Tester Sub Main() Dim characterArray As Char() Dim quotes As Char = ChrW(34) Dim originalString, string1, string2, string3, string4 As String

characterArray = New Char() {"A"c, "B"c, "C"c, "D"c, "E"c, "F"c, " "c, "G"c, "H"c} originalString = "test" string1 = originalString string2 = New String(characterArray) string3 = New String(characterArray, 6, 3) string4 = New String("C"c, 5) Console.WriteLine(string1) Console.WriteLine("string2 = " & string2 ) Console.WriteLine("string3 = " & string3 ) Console.WriteLine("string4 = " & string4 ) End Sub ' Main End Module

test string2 = ABCDEF GH

string3 = GH string4 = CCCCC

Utilizai pentru fiecare bucl la ieire o gam String


Public class Tester Public comun Sub principal Dim fruitArray () Ca String = { "portocale" , "Mere" , "Struguri" ,

"bana

Pentru fiecare fruct ca ir n fruitArray Console.WriteLine ( fructe ) fructe urmtoare End Sub End Class

Portocale Mere Struguri Banane Afinele

Original

Public Class Tester Public Shared Sub Main Dim fruitArray() As String = {"Oranges", "Apples", "Grapes", "Bananas", "Blueber For Each fruit As String In fruitArray Console.WriteLine(fruit) Next fruit End Sub End Class

Oranges Apples Grapes Bananas Blueberries

Matrice string

Modulul de testare public Sub Main () Dim sMonths () Ca String = { "Jan" , "februarie" , "Mar" , "aprilie" , "poate" , "

iunie" , "iulie" , "august" , "septembrie" , octombrie "," noiembrie "," decembrie "} Console.WriteLine (" unsprezecea lun a anului = { 0 } ", sMonths (10)) End Sub End Module Original

Module Test Public Sub Main() Dim sMonths() As String = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug Console.WriteLine("Eleventh month of the year = {0}", sMonths(10)) End Sub End Module

Eleventh month of the year = Nov

Array.Sort o matrice ir
Importuri System.Collections

public class Test de Sub public comun principal Dim StringArray () Ca String = Array.Sort ( StringArray ) Dim E ca

{ "Aceasta" ,

"este" ,

"o" ,

"test" }

IEnumerator = StringArray.GetEnumerator ()

n timp ce ( E . MoveNext ()) Console.WriteLine ( E.Current ()) End timp End Sub clasa End

un este test Acest

Original

Imports System.Collections public class Test public Shared Sub Main Dim StringArray() As String = {"This", "is", "a", "test"} Array.Sort(StringArray) Dim E As IEnumerator = StringArray.GetEnumerator() While (E.MoveNext()) Console.WriteLine(E.Current()) End While End Sub End class

a is test This

Store ntr-o gam multivalue


Public class Tester Public comun Sub principal Dim multiValue ( 2 ) () Ca Dim counter1 Ca Integer Dim counter2 Ca Integer

String

"- ---- construi matrice multivalue. multiValue ( 0 ) = String nou () { "alfa" , "beta" , "Gamma" } multiValue ( 1 ) = String nou () { "A" , "B" , "C" , "D" , "E" , multiValue ( 2 ) = String nou () { "Da" , "Nu" } "- ---- Format matrice pentru . ecran Pentru counter1 = 0 Pentru a multiValue.Length - 1 Pentru counter2 = 0 Pentru a multiValue ( counter1 ) Lungime -. Console.WriteLine ( multiValue ( counter1 ) ( counter2 )) nainte counter2 Console . WriteLine ( "" ) nainte counter1 End Sub End Class

"F" ,

"G

alfa beta gamma

A B C D E F G H Da Nu

Original
Public Class Tester Public Shared Sub Main Dim multiValue(2)() As String Dim counter1 As Integer Dim counter2 As Integer ' ----- Build multiValue(0) multiValue(1) multiValue(2) the multivalue = New String() = New String() = New String() array. {"alpha", "beta", "gamma"} {"A", "B", "C", "D", "E", "F", "G", "H"} {"Yes", "No"}

' ----- Format the array for display. For counter1 = 0 To multiValue.Length - 1 For counter2 = 0 To multiValue(counter1).Length - 1 Console.WriteLine(multiValue(counter1)(counter2)) Next counter2 Console.WriteLine("") Next counter1 End Sub End Class

alpha beta gamma A B C D E F G H Yes No

Schimba ir la majuscule, prin utilizarea UCase


Clasa Tester comun Sub Main () Dim userinput Ca String userinput = "asdf" Console.WriteLine ( UCase ( userinput )) End Sub End Class

Asdf

Original
Class Tester Shared Sub Main() Dim userInput As String userInput = " asdf " Console.WriteLine(UCase(userInput)) End Sub End Class

ASDF

Schimba ir de litere mici i majuscule


Public class Tester Public comun sub principal Dim citat Ca String = "abcdefg" Dim rezultat ca New System.Text.StringBuilder result.AppendLine result.AppendLine result.AppendLine result.AppendLine ( ( ( ( "Original:" & quote ) "majuscule:" & quote.ToUpper ()) "Cazul de Jos:" & quote.ToLower ()) "regim mixt : " & MixedCase ( quote ))

Console.WriteLine ( result.ToString ()) End Sub Public comun MixedCase Funcia ( ByVal origText Ca String ) Dim contra Ca Integer Dim textParts () Ca String = crapat ( origText, "" ) Pentru contor = 0 Pentru a textParts.Length - 1 Dac ( textParts ( contor ) . lungime> 0 ) Apoi _ textParts ( contra ) = _ UCase ( Microsoft.VisualBasic.Left ( _ textParts ( contra ) , 1 )) & _ LCASE ( Mid ( textParts ( contor ) , 2 )) nainte counter

Ca

String

End

Reveni Intrare ( textParts, Function

"" )

End Class

Original: ABCDEFG Majuscule: ABCDEFG Litere mici: ABCDEFG Cazul mixt: ABCDEFG

Original
Public Class Tester Public Shared Sub Main Dim quote As String = "AbCdEfG" Dim result As New System.Text.StringBuilder result.AppendLine("Original: result.AppendLine("Upper Case: result.AppendLine("Lower Case: result.AppendLine("Mixed Case: " " " " & & & & quote) quote.ToUpper()) quote.ToLower()) MixedCase(quote))

Console.WriteLine(result.ToString()) End Sub Public Shared Function MixedCase(ByVal origText As String) As String Dim counter As Integer Dim textParts() As String = Split(origText, " ") For counter = 0 To textParts.Length - 1 If (textParts(counter).Length > 0) Then _ textParts(counter) = _ UCase(Microsoft.VisualBasic.Left( _ textParts(counter), 1)) & _ LCase(Mid(textParts(counter), 2)) Next counter Return Join(textParts, " ") End Function End Class

Original: Upper Case: Lower Case: Mixed Case:

AbCdEfG ABCDEFG abcdefg Abcdefg

Majuscule prima liter


Public class Tester Public comun sub principal Dim citat Ca String = "abcdefg" Dim rezultat ca New System.Text.StringBuilder

result.AppendLine result.AppendLine result.AppendLine result.AppendLine

( ( ( (

"Original:" & quote ) "majuscule:" & quote.ToUpper ()) "Cazul de Jos:" & quote.ToLower ()) "regim mixt : " & MixedCase ( quote ))

Console.WriteLine ( result.ToString ()) End Sub Public comun MixedCase Funcia ( ByVal origText Ca String ) Dim contra Ca Integer Dim textParts () Ca String = crapat ( origText, "" ) Pentru contor = 0 Pentru a textParts.Length - 1 Dac ( textParts ( contor ) . lungime> 0 ) Apoi _ textParts ( contra ) = _ UCase ( Microsoft.VisualBasic.Left ( _ textParts ( contra ) , 1 )) & _ LCASE ( Mid ( textParts ( contor ) , 2 )) nainte counter End Reveni Intrare ( textParts, Function "" )

Ca

String

End Class

Original: ABCDEFG Majuscule: ABCDEFG Litere mici: ABCDEFG Cazul mixt: ABCDEFG

Original
Public Class Tester Public Shared Sub Main Dim quote As String = "AbCdEfG" Dim result As New System.Text.StringBuilder result.AppendLine("Original: result.AppendLine("Upper Case: result.AppendLine("Lower Case: result.AppendLine("Mixed Case: " " " " & & & & quote) quote.ToUpper()) quote.ToLower()) MixedCase(quote))

Console.WriteLine(result.ToString()) End Sub Public Shared Function MixedCase(ByVal origText As String) As String Dim counter As Integer Dim textParts() As String = Split(origText, " ") For counter = 0 To textParts.Length - 1 If (textParts(counter).Length > 0) Then _ textParts(counter) = _ UCase(Microsoft.VisualBasic.Left( _ textParts(counter), 1)) & _ LCase(Mid(textParts(counter), 2)) Next counter Return Join(textParts, " ") End Function

End Class

Original: Upper Case: Lower Case: Mixed Case:

AbCdEfG ABCDEFG abcdefg Abcdefg

Utilizai metoda de copiere String(ir)


Opiunea stricte privind importurile System Clasa Tester public comun Sub Main () Dim S1 Ca String = "abcd" Dim s2 Ca String = "ABCD" 'T el metod String copie Dim S5 Ca String = String.Copy ( S2 ) Console.WriteLine ( "s5 copiat de la S2: {0}" , s5 ) End Sub "Ma n End clasa "Te ster

s5 copiate de la S2: ABCD

Original
Option Strict On Imports System Class Tester Public Shared Sub Main( ) Dim s1 As String = "abcd" Dim s2 As String = "ABCD" ' the String copy method Dim s5 As String = String.Copy(s2) Console.WriteLine("s5 copied from s2: {0}", s5) End Sub 'Main End Class 'Tester

s5 copied from s2: ABCD

Utilizai operatorul suprancrcat (=) pentru a copia ir


Opiunea stricte privind importurile System Clasa Tester

public comun Sub Main () Dim S1 Ca String = "abcd" Dim s2 Ca String = "ABCD" Dim S6 Ca String = s1 Console.WriteLine ( "S6 = s1: {0}" , S6 ) End Sub "Ma n End clasa "Te ster

S6 = S1: abcd

Original
Option Strict On Imports System Class Tester Public Shared Sub Main( ) Dim s1 As String = "abcd" Dim s2 As String = "ABCD" Dim s6 As String = s1 Console.WriteLine("s6 = s1: {0}", s6) End Sub 'Main End Class 'Tester

s6 = s1: abcd

Demonstrarea metode startswith i EndsWith


Tester modul Sub Main () Dim siruri de caractere Ca String () Dim ieire Ca String = "" Dim i Ca Integer Dim citate Ca Char = ChrW ( 34 ) siruri de caractere = String nou () { "a nceput" , "sa ncheiat" , "ncheie" } "ncepnd" , _

Pentru i = 0 Pentru a strings.GetUpperBound ( 0 ) n cazul n care siruri de caractere ( i ) . startswith ( "st" ) Console.WriteLine ( "ncepe cu st" ) End If Urmtor Pentru i = 0 Pentru a strings.GetUpperBound ( 0 ) n cazul n care siruri de caractere ( i ) . EndsWith ( "Ed" ) Console.WriteLine ( "se termin cu Ed" )

Apoi

Apoi

End If Urmtor End Sub End Module 'M Ain

ncepe cu st ncepe cu st se ncheie cu Ed se ncheie cu Ed

Original
Module Tester Sub Main() Dim strings As String() Dim output As String = "" Dim i As Integer Dim quotes As Char = ChrW(34) strings = New String() {"started", "starting", _ "ended", "ending"} For i = 0 To strings.GetUpperBound(0) If strings(i).StartsWith("st") Then Console.WriteLine(" starts with st") End If Next For i = 0 To strings.GetUpperBound(0) If strings(i).EndsWith("ed") Then Console.WriteLine(" ends with ed" ) End If Next End Sub ' Main End Module

starts with st starts with st ends with ed ends with ed

Utilizai indexOf pentru a localiza un subir ntr-un ir


Tester modul Sub Main ()

Dim Dim

litere Ca String = "abcdefghijklmabcdefghijklm" searchLetters Ca Char () = New Char () { "C" C,

"un" C,

"$" C }

Console.WriteLine ( letters.IndexOf ( "def" )) Console.WriteLine ( letters.IndexOf ( "def" , 7 )) 5 , 15 ))

Console.WriteLine ( letters.IndexOf ( "Bun ziua" , End Sub End Module

3 16 -1

Original
Module Tester Sub Main() Dim letters As String = "abcdefghijklmabcdefghijklm" Dim searchLetters As Char() = New Char() {"c"c, "a"c, "$"c} Console.WriteLine(letters.IndexOf("def")) Console.WriteLine(letters.IndexOf("def", 7)) Console.WriteLine(letters.IndexOf("hello", 5, 15)) End Sub End Module

3 16 -1

Utilizai lastIndexOf pentru a gsi un subir ntr-un ir


Tester modul Sub Main () Dim litere Ca String = "abcdefghijklmabcdefghijklm" Dim searchLetters Ca Char () = New Char () { "C" C, Console.WriteLine ( letters.LastIndexOf ( "def" )) Console.WriteLine ( letters.LastIndexOf ( "def" , 25 )) 20 , 15 ))

"un" C,

"$" C }

Console.WriteLine ( letters.LastIndexOf ( "Bun ziua" , End Sub

End

Module

16 16 -1

Original
Module Tester Sub Main() Dim letters As String = "abcdefghijklmabcdefghijklm" Dim searchLetters As Char() = New Char() {"c"c, "a"c, "$"c} Console.WriteLine(letters.LastIndexOf("def")) Console.WriteLine(letters.LastIndexOf("def", 25)) Console.WriteLine(letters.LastIndexOf("hello", 20, 15)) End Sub End Module

16 16 -1

Utilizai IndexOfAny pentru a gsi prima apariie de caracter n matrice


Tester modul Sub Main () Dim litere Ca String = "abcdefghijklmabcdefghijklm" Dim searchLetters Ca Char () = New Char () { "C" C, Console.WriteLine ( "prima apariie a lui" "C" "," "" "A" "sau" "$" "este situat la" & _ letters.IndexOfAny ( searchLetters )) & _

"un" C,

"$" C }

Console.WriteLine ( "prima apariie a lui" "C" "," "un" "sau" "" "$" "este situat la" & _ letters.IndexOfAny ( searchLetters, 7 )) Console.WriteLine ( "prima apariie a lui" "C" "," "un" "sau" "" "$" "este situat la" & _ letters.IndexOfAny ( searchLetters, 20 , 5 )) End Sub End Module

& _

& _

Prima apariie a lui "c", "o" sau "$" este situat la 0 Prima apariie a lui "c", "o" sau "$" este situat la 13

Prima apariie a lui "c", "o" sau "$" este situat la -1

Original
Module Tester Sub Main() Dim letters As String = "abcdefghijklmabcdefghijklm" Dim searchLetters As Char() = New Char() {"c"c, "a"c, "$"c} Console.WriteLine("First occurrence of ""c""," & _ " ""a"" or ""$"" is located at " & _ letters.IndexOfAny(searchLetters)) Console.WriteLine("First occurrence of ""c"", ""a"" or " & _ """$"" is located at " & _ letters.IndexOfAny(searchLetters, 7)) Console.WriteLine("First occurrence of ""c"", ""a"" or " & _ """$"" is located at " & _ letters.IndexOfAny(searchLetters, 20, 5)) End Sub End Module

First occurrence of "c", "a" or "$" is located at 0 First occurrence of "c", "a" or "$" is located at 13 First occurrence of "c", "a" or "$" is located at -1

Utilizai LastIndexOfAny pentru a gsi prima apariie de caracter n matrice


Tester modul Sub Main () Dim litere Ca String = "abcdefghijklmabcdefghijklm" Dim searchLetters Ca Char () = New Char () { "C" C, Console.WriteLine ( "ultima apariie a" "C" "," "" "A" "sau" "$" "este situat la" & _ letters.LastIndexOfAny ( searchLetters )) & _

"un" C,

"$" C }

Console.WriteLine ( "ultima apariie a" "C" "," "un" "sau" "" "$" "este situat la" & _ letters.LastIndexOfAny ( searchLetters, 1 )) Console.WriteLine ( "ultima apariie a" "C" "," "un" "sau" "" "$" "este situat la" & _ letters.LastIndexOfAny ( searchLetters, 25 , 5 )) End Sub End Module

& _

& _

Ultima apariie a lui "c", "o" sau "$" este situat la 15

Ultima apariie a lui "c", "o" sau "$" este situat la 0 Ultima apariie a lui "c", "o" sau "$" este situat la -1

Originar
Module Tester Sub Main() Dim letters As String = "abcdefghijklmabcdefghijklm" Dim searchLetters As Char() = New Char() {"c"c, "a"c, "$"c} Console.WriteLine("Last occurrence of ""c""," & _ " ""a"" or ""$"" is located at " & _ letters.LastIndexOfAny(searchLetters)) Console.WriteLine("Last occurrence of ""c"", ""a"" or " & _ """$"" is located at " & _ letters.LastIndexOfAny(searchLetters, 1)) Console.WriteLine("Last occurrence of ""c"", ""a"" or " & _ """$"" is located at " & _ letters.LastIndexOfAny(searchLetters, 25, 5)) End Sub End Module

Last occurrence of "c", "a" or "$" is located at 15 Last occurrence of "c", "a" or "$" is located at 0 Last occurrence of "c", "a" or "$" is located at -1

Pagina de start a.String (ir)de orice(nr pag)


public class de testare public comun Sub principale Dim S1 Ca nou String ( "salut" ) Console.WriteLine ( s1.IndexOfAny ( "staniu" )) End Sub End clasa

Originar
public class Test public Shared Sub Main Dim s1 As New String("Greeting") Console.WriteLine(s1.IndexOfAny("tin")) End Sub End class

Metoda EndsWith.

Importurile System Clasa publice EndsWithTest Shared public Sub Main () Dim strSource Ca String () = { "<b> este un text bold </ b>" , "greit>" } Dim s Ca String Pentru fiecare s n strSource Console.WriteLine ( StripEndTags ( e )) nainte s End Sub privat partajat StripEndTags Funcie ( post Ca String ) As String Dac item.Trim () . EndsWith ( ">" ) Apoi Dim lastLocation Ca Integer = item.LastIndexOf ( "</" ) Dac lastLocation> = 0 Apoi element = item.Substring ( 0 , lastLocation ) End Dac End Dac retur Poz. End Function End Class
Originar

Imports System Public Class EndsWithTest Public Shared Sub Main() Dim strSource As String() = { "<b>This is bold text</b>","wrong>"}

Dim s As String For Each s In strSource Console.WriteLine(StripEndTags(s)) Next s End Sub Private Shared Function StripEndTags(item As String ) As String If item.Trim().EndsWith(">") Then Dim lastLocation As Integer = item.LastInde xOf("</") If lastLocation >= 0 Then item = item.Substring(0, lastLocation) End If End If Return Item End Function End Class Gsi indicele de ultima apariie de orice caracter n irul "este" din alt ir. Importurile System Clasa Exemplu publice comun Sub Main () Dim str. Ca String = "acesta este un test." Dim nceput Ca Integer Dim la Ca Integer Dim int Ca String = "este" Dim anyOf Ca Char () = target.ToCharArray () la = str.LastIndexOfAny ( anyOf ) n cazul n care la> - 1 Apoi Console.Write ( la ) Else Console.Write ( "(nu a fost gsit)" ) End If End Sub End Class
Originar

Imports System Class Sample Public Shared Sub Main() Dim str As String = "this is a test." Dim start As Integer Dim at As Integer Dim target As String = "is" Dim anyOf As Char() = target.ToCharArray() at = str.LastIndexOfAny(anyOf) If at > - 1 Then Console.Write(at) Else Console.Write("(not found)") End If End Sub End Class
IsMatch (String) determin dac un ir este un valabil de expresie regulat

Importuri System.Text.RegularExpressions Modulul Exemplu Public Sub Main () Dim RgX Ca noi

End Sub End Module


Originar

Imports System.Text.RegularExpressions Module Example Public Sub Main() Dim rgx As New Regex("^[a-zA-Z0-9]\d{2}[a-zA-Z09](-\d{3}){2}[A-Za-z0-9]$") Console.WriteLine(rgx.IsMatch("1298-673-4192")) End Sub End Module

String.Format: {0,10: p}
Public class Tester Public comun Sub Main 0,32 ))

Console.WriteLine ( String.Format ( "{0,10: p}" , End Sub End Class

32.00%

Originar
Public Class Tester Public Shared Sub Main Console.WriteLine(String.Format("{0,10:p}", 0.32)) End Sub End Class

32.00 %

String.Format: {0: #, # # #, # # #, 00 # #, 00.}


Public class Tester Public comun Sub Main

Console.WriteLine ( String.Format ( "{0:. #, # # #, # # #, 00 # #, 00}" , 1232.234 End Sub End Class

0.0

Originar
Public Class Tester Public Shared Sub Main Console.WriteLine(String.Format("{0:#,### ; #.## ,00##,00}",1232.2345)) End Sub

End Class

0.0

String.Format: {0:.. # # # #, - # # #; 0.0 #} (2)


Public class Tester Public comun Sub Main

Console.WriteLine ( String.Format ( "{0:.. # # # #, - # # #; 0.0 #}" , - 1235.33 ) End Sub End Class

-1235.3

Originar
Public Class Tester Public Shared Sub Main Console.WriteLine(String.Format("{0:##.## ; -##.# ; 0.0#}", -1235.33)) End Sub End Class

-1235.3

String.Format: {0:. # # # #; (# # .00); 0.0 #} (3)


Public class Tester Public comun Sub Main 0 ))

Console.WriteLine ( String.Format ( "{0:. # # # #; (# # .00); 0.0 #}" , End Sub End Class

0.0

Originar
Public Class Tester

Public Shared Sub Main Console.WriteLine(String.Format("{0:##.## ; (##.00) ; 0.0#}", 0)) End Sub End Class

0.0

Formatul 2.34.5.String: {0, 1: D}


Modulul Module1 Sub Main () Dim A n dubl = 1.23456789 Console.WriteLine ( "{0, 1: D} {1, 2: D} {2, 3: D}" ,

1 ,

2 ,

3 )

End Sub End Module

1 2 3

Originar
Module Module1 Sub Main() Dim A As Double = 1.23456789 Console.WriteLine("{0, 1:D} {1, 2:D} {2, 3:D}", 1, 2, 3) End Sub End Module

Formatul 2.34.6.String: {0, 7: F1}


Modulul Module1 Sub Main () Dim A n dubl = 1.23456789 Console.WriteLine ( "{0, 7: F1} {1, 7: F3} {2, 7: F5}" , A, A, A )

End Sub

End

Module

1.2 1.235 1.23457

Originar
Module Module1 Sub Main() Dim A As Double = 1.23456789 Console.WriteLine("{0, 7:F1} {1, 7:F3} {2, 7:F5}", A, A, A) End Sub End Module

1.2

1.235 1.23457

Formatul 2.34.7.String: {0, 0: # #.}, {0, 0:. # # # #}, {0, 0: # # # # # #


Modulul Module1 Sub Main () Dim A n dubl = 1.23456789 Console.WriteLine ( "{0, 0:. # #}" , A ) Console.WriteLine ( "{0, 0:. # # # #}" , A ) Console. WriteLine ( "{0, 0:. # # # # # #}" , A )

End Sub End Module

1.2 1.235 1.23457

Originar
Module Module1 Sub Main() Dim A As Double = 1.23456789 Console.WriteLine("{0, 0:#.#}", A) Console.WriteLine("{0, 0:#.###}", A) Console.WriteLine("{0, 0:#.#####}", A) End Sub End Module

1.2 1.235 1.23457

Replace un ir sub cu "nlocuii"


Clasa Tester comun Sub Main () Dim userinput Ca String userinput = "asdf" Console.WriteLine ( nlocuii ( userinput, End Sub End Class "f" , "" ))

asd

Original
Class Tester Shared Sub Main() Dim userInput As String userInput = " asdf " Console.WriteLine(Replace(userInput, "f", "")) End Sub End Class

asd

nlocuii subir cu un alt subir


public class de testare public comun Sub principale Dim S1 Ca nou String ( "salut" ) s1 = s1.Replace ( "e" , "i" ) Console.WriteLine ( S1 ) End Sub End clasa

Griiting

Originar
public class Test public Shared Sub Main

Dim s1 As New String("Greeting") s1 = s1.Replace("e", "i") Console.WriteLine(s1) End Sub End class

Griiting

Microsoft.VisualBasic.Left
public class de testare public comun sub principal Dim strName Ca String = Dac Dac End Sub clasa End

"Visual Basic Express"

Microsoft.VisualBasic.Left ( strName, 3 ) = "Vis" Atunci Console.Write strName.StartsWith ( "Vis" ) Apoi Console.WriteLine ( "True" )

Adevrat Adevrat

Orioginar
public class Test public Shared Sub Main Dim strName As String = "Visual Basic Express"

If Microsoft.VisualBasic.Left(strName, 3) = "Vis" Then Console.WriteLine("True") If strName.StartsWith("Vis") Then Console.WriteLine("True") End Sub End class

True True

String.Copy
public class de testare public comun sub principal Dim str1, str2 Ca String str1 = "un text" str2 str1 =

str2 = String.Copy ( str1 ) Console.WriteLine ( str1 & vbCrLf & str2 ) End Sub clasa End

un text un text

Originar
public class Test public Shared Sub Main Dim str1, str2 As String str1 = "some text" str2 = str1 str2 = String.Copy(str1) Console.WriteLine(str1 & vbCrLf & str2) End Sub End class

some text some text

Utilizai String.Concat a nlnui dou iruri


public class de testare public comun Sub principale Dim aryStrings () Ca String = Dim strLongString Ca String

{ "ir1" ,

"string2" ,

"string3" ,

"string4

strLongString = String.Concat ( aryStrings ) Console.WriteLine ( strLongString ) End Sub clasa End

string1string2string3string4

Originar
public class Test public Shared Sub Main Dim aryStrings() As String = {"string1", "string2", "string3", "string4"} Dim strLongString As String strLongString = String.Concat(aryStrings)

Console.WriteLine(strLongString) End Sub End class

string1string2string3string4

LCASE: schimbarea ir de litere mici

Modulul Tester Public Sub Main () Dim sHello Ca String = "Hello World" Console.WriteLine ( "ir original: {0}" , sHello ) Console.WriteLine ( "Minuscule (LCASE (sHello)): {0}" , LCASE ( sHello )) End Sub End Module Este un ir de caractere o valoare numeric
Clasa Tester comun Sub Main () Dim userinput Ca String userinput = "asdf" Console.WriteLine ( IsNumeric ( userinput ) Sub End End Class = false )

Adevrat

Originar
Class Tester Shared Sub Main() Dim userInput As String userInput = " asdf " Console.WriteLine(IsNumeric(userInput) = False) End Sub End Class

True

Converti ir de valoare
Clasa Tester comun Sub Main () Dim userinput Ca userinput = "4" String

Console.WriteLine ( Val ( userinput )) End Sub End Class

Original
Class Tester Shared Sub Main() Dim userInput As String userInput = "4" Console.WriteLine(Val(userInput)) End Sub End Class

Demonstrating constructori clasa StringBuilder(ir constructor)


Importurile Tester modul Sub Main () Dim buffer1, buffer2, buffer3 ca StringBuilder System.Text

buffer1 = New StringBuilder () buffer2 = New StringBuilder ( 10 ) buffer3 = New StringBuilder ( "Bun ziua" ) Console.WriteLine ( buffer1.ToString ()) Console.WriteLine ( buffer2.ToString ()) Console.WriteLine ( buffer3.ToString ()) End Sub End Module 'M Ain

Alo

StringBuilder: Insert ir, adugare i nlocuire


Public class Tester Public comun sub principal Dim rezultat ca New System.Text.StringBuilder ( "AA" ) result.append ( "CCC." ) result.append ( "AAA" ) . Adaug ( "RRR" ) . Adaug ( "EEE " ) result.Insert ( 3 , "nota pentru a opri" ) result.Replace ( "CC" , "rr" ) result.Insert ( 0 , vbNewLine ) Console.WriteLine ( result.ToString ()) End Sub End Class

AA nota pentru a opri RRC. AAArrr eee

Original
Public Class Tester Public Shared Sub Main Dim result As New System.Text.StringBuilder("AA ") result.Append("CCC. ") result.Append("AAA").Append("rrr ").Append("eee") result.Insert(3, "note to stop ") result.Replace("CC", "rr") result.Insert(0, vbNewLine) Console.WriteLine(result.ToString()) End Sub End Class

AA note to stop rrC. AAArrr eee

Append Char a StringBuilder


Opiunea stricte cu privire la Importurile System.Text

Public Modul modMain Public Sub Main () Dim caractere ()

Ca

Dim

convertedChars

Char = { "T" C, "h" c, "i" C, "s" c, "" C, "i" C, "s" C, _ "" c, "o" c, "n" c, "" c, "o" c, "r" c, "r" c, "o" c, _ "y" c, "" c, " o " c, "f" c, "" C, "C" C, "h" C, _ "un" C, "R" C, "s" c } Ca New StringBuilder

Pentru fiecare CH Ca Char n caractere convertedChars.Append ( CH ) Urmatorul Dim displayString Ca String = convertedChars.ToString () Console.WriteLine ( displayString ) End Sub End Module

Aceasta este o matrice de caractere

Originar
Option Strict On Imports System.Text Public Module modMain Public Sub Main() Dim chars() As Char = {"T"c,"h"c,"i"c,"s"c," "c,"i"c,"s"c, _ " "c,"a"c,"n"c," "c,"a"c,"r"c,"r"c,"a"c, _ "y"c," "c,"o"c,"f"c," "c,"C"c,"h"c, _ "a"c,"r"c,"s"c} Dim convertedChars As New StringBuilder For Each ch As Char in chars convertedChars.Append(ch) Next Dim displayString As String = convertedChars.ToString() Console.WriteLine(displayString) End Sub End Module

This is an array of Chars

Demonstrating StringBuilder metode Ataare


Importurile Importurile System.Text System.Windows.Forms

Modulul modBuilderAppend Sub Main () Dim objectValue ca obiect = "Hello" Dim stringValue Ca String = "la revedere" Dim characterArray Ca Char () = { "A" C, Dim Dim Dim Dim booleanValue Ca Boolean = True characterValue Ca Char = "Z" C integerValue Ca Integer = 7 longValue Ca lung = 1000000

"b" C,

"C" C,

"d" C,

" e " C,

"

Dim Dim Dim

singleValue doubleValue tampon cum ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (

Ca Singur = 2,5 cum dubl = 33.333 StringBuilder = New StringBuilder () objectValue ) "" ) stringValue ) "" ) characterArray ) "" ) characterArray, 0 , "" ) booleanValue ) "" ) characterValue ) "" ) integerValue ) "" ) longValue ) "" ) singleValue ) "" ) doubleValue )

buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append tampon Adaug. buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append buffer.Append

3 )

Console.WriteLine ( "buffer =" End Sub End Module

& buffer.ToString ())

tampon = salut revedere abcdef ABC Adevrat Z 7 1000000 2,5 33.333

Original
Imports System.Text Imports System.Windows.Forms Module modBuilderAppend Sub Main() Dim objectValue As Object = "hello" Dim stringValue As String = "good bye" Dim characterArray As Char() = {"a"c, "b"c, "c"c, "d"c, "e"c, "f"c} Dim Dim Dim Dim Dim Dim Dim booleanValue As Boolean = True characterValue As Char = "Z"c integerValue As Integer = 7 longValue As Long = 1000000 singleValue As Single = 2.5 doubleValue As Double = 33.333 buffer As StringBuilder = New StringBuilder()

buffer.Append(objectValue) buffer.Append(" ") buffer.Append(stringValue) buffer.Append(" ") buffer.Append(characterArray) buffer.Append(" ") buffer.Append(characterArray, 0, 3)

buffer.Append(" ") buffer.Append(booleanValue) buffer.Append(" ") buffer.Append(characterValue) buffer.Append(" ") buffer.Append(integerValue) buffer.Append(" ") buffer.Append(longValue) buffer.Append(" ") buffer.Append(singleValue) buffer.Append(" ") buffer.Append(doubleValue) Console.WriteLine("buffer = " & buffer.ToString()) End Sub End Module

buffer = hello

good bye

abcdef

abc

True

1000000

2.5

33.333

StringBuilder AppendFormat
Importurile System.Text

Clasa Tester public comun Sub Main () Dim S1 Ca String = "unu, doi, trei Liberty Associates, Inc" Spaiu const Ca Char = "" c Const Virgul Ca Char = "," C Dim Dim Dim Dim delimitatori () Ca Char = { spaiu, virgul }

ieire Ca New StringBuilder () CTR Ca Integer = 0 resultArray Ca String () = s1.Split ( delimitatori )

Dim subir Ca String pentru fiecare sir de caractere in resultArray CTR = CTR + 1 output.AppendFormat ( "{0}: {1}" & Environment.NewLine, ctr, substring ) nainte subir Console.WriteLine ( ieire ) End Sub End Class

Echilibrul ca data de 16 mai 2002 este de $ 19,950.40

Originar
Imports System.Text

Class Tester Public Shared Sub Main( ) Dim s1 As String = "One,Two,Three Liberty Associates, Inc." Const Space As Char = " "c Const Comma As Char = ","c Dim delimiters( ) As Char = {Space, Comma} Dim output As New StringBuilder( ) Dim ctr As Integer = 0 Dim resultArray As String( ) = s1.Split(delimiters) Dim subString As String For Each subString In resultArray ctr = ctr + 1 output.AppendFormat("{0} : {1}" & Environment.NewLine, ctr, subString) Next subString Console.WriteLine(output) End Sub End Class

Your balance as of May 16, 2002 is $ 19,950.40

StringBuilder.AppendFormat: {0: D} este $ {1: #, # # # .00}


Importurile System

public class de testare public comun sub principal Dim objSB Ca New Text.StringBuilder objSB.AppendFormat ( "echilibrul ca de {0: D} este $ {1: #, # # # 0.00}" , _ # 5 / 16 / 2002 #, 19950.4 ) Console.WriteLine ( objSB.ToString ) End Sub clasa End

Echilibrul ca data de 16 mai 2002 este de $ 19,950.40

Originar

StringBuilder.AppendFormat: {0:D} is ${1: #,###.00}


Imports System public class Test public Shared Sub Main

Dim objSB As New Text.StringBuilder objSB.AppendFormat("Your balance as of {0:D} is ${1: #,###.00}", _ #5/16/2002#, 19950.4) Console.WriteLine(objSB.ToString) End Sub End class

Your balance as of May 16, 2002 is $ 19,950.40

Introducei metoda de StringBuilder

Importurile de sistem Importurile System.Text Clasa Exemplu privat partajat sb ca StringBuilder Public Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim comun Sub Main () xyz Ca String = "xyz" abc Ca Char () = { "A" C, "b" C, "C", C } stele Ca Char = "*" C obj Ca [ Obiectul ] = 0 xBool Ca Boolean = True xByte Ca Byte = 1 xInt16 Ca Scurt = 2 xInt32 Ca Integer = 3 xInt64 Ca lung = 4 xDecimal Ca [ Zecimal ] = 5 xSingle Ca Singur = 6.6F xDouble Ca dubla = 7.7 xUInt16 Ca System.UInt16 xUInt32 Ca System.UInt32 xUInt64 Ca System.UInt64 xSByte Ca System.SByte = = = = 8 9 10 11

sb = New StringBuilder ()

sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 , sb.Insert ( 3 ,

xyz, 2 ) xyz ) stele ) ABC ) ABC, 1 , 2 ) xBool ) obj ) xByte ) xInt16 ) xInt32 ) xInt64 ) xDecimal ) xSingle ) xDouble ) xUInt16 ) xUInt32 ) xUInt64 ) xSByte )

Console.WriteLine ( sb.ToString ()) End Sub End Class


Originar
Imports System Imports System.Text Class Sample Private Shared sb As StringBuilder Public Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim Shared Sub Main() xyz As String = "xyz" abc As Char() = {"a"c, "b"c, "c"c} star As Char = "*"c obj As [Object] = 0 xBool As Boolean = True xByte As Byte = 1 xInt16 As Short = 2 xInt32 As Integer = 3 xInt64 As Long = 4 xDecimal As [Decimal] = 5 xSingle As Single = 6.6F xDouble As Double = 7.7

Dim Dim Dim Dim

xUInt16 As System.UInt16 xUInt32 As System.UInt32 xUInt64 As System.UInt64 xSByte As System.SByte =

= = = -

8 9 10 11

sb = New StringBuilder() sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, sb.Insert(3, xyz, 2) xyz) star) abc) abc, 1, 2) xBool) obj) xByte) xInt16) xInt32) xInt64) xDecimal) xSingle) xDouble) xUInt16) xUInt32) xUInt64) xSByte)

Console.WriteLine(sb.ToString()) End Sub End Class

Use StringBuilder Indexer


Importurile Tester modul Sub Main () Dim i Ca Integer Dim tampon cum StringBuilder = New StringBuilder ( "Salut, ce mai faci?" ) "U se StringBuilder indexare Pentru i = 0 Pentru a buffer.Length Console.WriteLine ( tampon ( i )) Urmtorul End Sub End Module 1 System.Text

H e L l o

, h o w -o r e Y o u ?

Originar

Imports System.Text Module Tester Sub Main() Dim i As Integer Dim buffer As StringBuilder = New StringBuilder("Hello, how are you?") ' use StringBuilder Indexer For i = 0 To buffer.Length - 1 Console.WriteLine(buffer(i)) Next End Sub End Module

H e l l o , h o w a r e

y o u ?

Demonstrating introduce i a scoate din clasa StringBuilder


Importurile Importurile Tester modul Sub Main () Dim objectValue ca obiect = "Hello" Dim stringValue Ca String = "la revedere" Dim characterArray Ca Char () = { "A" C, Dim Dim Dim Dim Dim Dim Dim Dim System.Text System.Windows.Forms

"b" C,

"C" C,

"d" C,

" e " C,

"

booleanValue Ca Boolean = True characterValue Ca Char = "K" C integerValue Ca Integer = 7 longValue Ca lung = 12345677890 singleValue Ca Singur = 2,5 doubleValue cum dubl = 33.333 tampon cum StringBuilder = New StringBuilder () ieire Ca String

'I nsert valori n tampon buffer.Insert ( 0 , objectValue ) buffer.Insert ( 0 , "" ) buffer.Insert ( 0 , stringValue ) buffer.Insert ( 0 , "" ) buffer.Insert ( 0 , characterArray ) tampon. introducerii ( 0 , "" ) buffer.Insert ( 0 , booleanValue ) buffer.Insert ( 0 , "" ) buffer.Insert ( 0 , characterValue ) buffer.Insert ( 0 , "" ) buffer.Insert ( 0 , integerValue ) tampon . introducerii ( 0 , "" ) buffer.Insert ( 0 , longValue ) buffer.Insert ( 0 , "" ) buffer.Insert ( 0 , singleValue ) buffer.Insert ( 0 , "" ) buffer.Insert ( 0 , doubleValue ) buffer.Insert ( 0 , "" ) ieire = "tampon dup insertii:" & vbCrLf & _ buffer.ToString () & vbCrLf & vbCrLf buffer.Remove ( 12 , 1 ) 'd elete 5 n 2.5 buffer.Remove ( 2 , 4 ) 'd elete 33.3 la 33.333 Ieire & = "tampon dup ndeprteaz:" buffer.ToString () Console.WriteLine ( ieire ) & vbCrLf & _

End Sub End Module

'M Ain

tampon la introduce: 33.333 2.5 12345677890 7 K adevrat abcdef revedere salut tampon dup ndeprteaz: 33 2. 12345677890 7 K adevrat abcdef revedere salut

Originar

Imports System.Text Imports System.Windows.Forms Module Tester Sub Main() Dim objectValue As Object = "hello" Dim stringValue As String = "good bye" Dim characterArray As Char() = {"a"c, "b"c, "c"c, "d"c, "e"c, "f"c} Dim Dim Dim Dim Dim Dim Dim Dim booleanValue As Boolean = True characterValue As Char = "K"c integerValue As Integer = 7 longValue As Long = 12345677890 singleValue As Single = 2.5 doubleValue As Double = 33.333 buffer As StringBuilder = New StringBuilder() output As String

' insert values into buffer buffer.Insert(0, objectValue) buffer.Insert(0, " ") buffer.Insert(0, stringValue) buffer.Insert(0, " ") buffer.Insert(0, characterArray) buffer.Insert(0, " ") buffer.Insert(0, booleanValue) buffer.Insert(0, " ") buffer.Insert(0, characterValue) buffer.Insert(0, " ") buffer.Insert(0, integerValue) buffer.Insert(0, " ") buffer.Insert(0, longValue) buffer.Insert(0, " ") buffer.Insert(0, singleValue) buffer.Insert(0, " ") buffer.Insert(0, doubleValue) buffer.Insert(0, " ") output = "buffer after inserts:" & vbCrLf & _ buffer.ToString() & vbCrLf & vbCrLf

buffer.Remove(12, 1) ' delete 5 in 2.5 buffer.Remove(2, 4) ' delete 33.3 in 33.333 output &= "buffer after Removes:" & vbCrLf & _ buffer.ToString() Console.WriteLine(output) End Sub ' Main End Module

buffer after inserts: 33.333 2.5 12345677890 buffer after Removes: 33 2. 12345677890 7 K

K True

True

abcdef

good bye hello

hello

abcdef

good bye

StringBuilder.ToStrings
Importurile System

public class de testare public comun sub principal Dim objSB Ca New Text.StringBuilder ( "un text" ) Console.WriteLine ( objSB.ToString ) End Sub clasa End

un text

Originar
Imports System public class Test public Shared Sub Main Dim objSB As New Text.StringBuilder("some text") Console.WriteLine(objSB.ToString) End Sub End class

some text

StringWriter and StringReader


Imports System.IO public class Test public Shared Sub Main Dim string_writer As New StringWriter() string_writer.WriteLine("The quick brown fox") string_writer.WriteLine("jumps over the lazy dog.") Console.WriteLine(string_writer.ToString) ' Use a StringReader to read from the string. Dim string_reader As New StringReader(string_writer.ToString) string_writer.Close() Console.WriteLine(string_reader.ReadLine()) Console.WriteLine(string_reader.ReadToEnd()) string_reader.Close() End Sub End class

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

System.IO public class de testare public comun sub principal Dim string_writer Ca StringWriter Nou () string_writer.WriteLine ( "rapid maro vulpea" ) string_writer.WriteLine ( "sare peste cainele lenes." ) Console.WriteLine ( string_writer.ToString ) "U se o StringReader pentru a citi Dim string_reader Ca noi din irul.

End Sub clasa End

Rapid maro vulpea sare peste cainele lenes. Rapid maro vulpea sare peste cainele lenes.

Wrapped
Opiunea stricte cu privire la Public class WrappedType public comun Sub Main () Dim intVar Ca Integer = 100 Dim intType Ca Tip = intVar.GetType () Console.WriteLine ( TypeName ( intVar ) &

"="

& intType.FullName )

Dim stringVar Ca String = "Acesta este un sir." Dim stringType Ca Tip = stringVar.GetType () Console.WriteLine ( TypeName ( stringVar ) & "=" & stringType. FULLNAME ) Dim boolVar Ca Boolean = True Dim boolType Ca Tip = boolVar.GetType () Console.WriteLine ( TypeName ( boolVar ) &

"="

& boolType. FULLNAME )

Dim singleVar Ca Singur = 3.1417 Dim singleType Ca Tip = singleVar.GetType () Console.WriteLine ( TypeName ( singleVar ) & "=" End Sub End Class

& singleType. FULLNAME )

Integer = System.Int32 String = System.String Boolean = System.Boolean Single = System.Single

Original
Opiunea stricte cu privire la Public class WrappedType public comun Sub Main () Dim intVar Ca Integer = 100 Dim intType Ca Tip = intVar.GetType () Console.WriteLine ( TypeName ( intVar ) &

"="

& intType.FullName )

Dim stringVar Ca String = "Acesta este un sir." Dim stringType Ca Tip = stringVar.GetType () Console.WriteLine ( TypeName ( stringVar ) & "=" & stringType. FULLNAME ) Dim boolVar Ca Boolean = True Dim boolType Ca Tip = boolVar.GetType () Console.WriteLine ( TypeName ( boolVar ) &

"="

& boolType. FULLNAME )

Dim singleVar Ca Singur = 3.1417 Dim singleType Ca Tip = singleVar.GetType () Console.WriteLine ( TypeName ( singleVar ) & "=" End Sub End Class

& singleType. FULLNAME )

Integer = System.Int32 String = System.String Boolean = System.Boolean Singur = System.Single

Show. Tipuri nete de comand


Modulul Module1 Sub Main () Dim A n scurt Dim B Ca Integer Dim C Ca int64 Dim D Ca Singur Dim E ceea dubl Dim F Ca Char Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine Console.WriteLine End Sub End Module ( ( ( ( ( ( "A: "B: "C: "D: "E: "F: {0}" , A.GetType () . FULLNAME {0}" , B.GetType () . FULLNAME {0} " , C.GetType () FULLNAME. {0}" , D.GetType () . FULLNAME {0}" , E.GetType () . FULLNAME {0}" , F.GetType () . FULLNAME ) ) ) ) ) )

A: B: C: D: E: F:

System.Int16 System.Int32 System.Int64 System.Single System.Double System.Char

Original

Module Module1 Sub Main() Dim A As Dim B As Dim C As Dim D As Dim E As Dim F As

Short Integer Int64 Single Double Char

Console.WriteLine("A: {0} ", A.GetType().FullNa

me) Console.WriteLine("B: {0} ", B.GetType().FullNa me) Console.WriteLine("C: {0} ", C.GetType().FullNa me) Console.WriteLine("D: {0} ", D.GetType().FullNa me) Console.WriteLine("E: {0} ", E.GetType().FullNa me) Console.WriteLine("F: {0} ", F.GetType().FullNa me) End Sub End Module

CLng: converti ntreg i lung


Modulul Tester Public Sub Main () Dim iInteger Ca Integer = Dim lLong Ca pe Dim bytByte Ca Byte Dim sngSingle Ca Singur Dim dblDouble cum dubl Dim decDecimal Ca Zecimal

5280

Console.WriteLine ( "Conversia la un lung: {0}" , CLng ( iInteger ) End Sub End Module

* CLng ( iI

Conversia la un lung: 27878400

Original
Module Tester Public Sub Main() Dim iInteger As Integer = 5280 Dim lLong As Long Dim bytByte As Byte Dim sngSingle As Single Dim dblDouble As Double Dim decDecimal As Decimal Console.WriteLine("Convert to a Long: {0}", CLng(iInteger) * CLng(iInteger)) End Sub

End Module

Convert to a Long: 27878400

CByte: converti octet


Modulul Tester Public Sub Main () Dim iInteger Ca Integer = Dim lLong Ca pe Dim bytByte Ca Byte Dim sngSingle Ca Singur Dim dblDouble cum dubl Dim decDecimal Ca Zecimal

5280

Console.WriteLine ( "Conversia la un octet: {0}" , CByte ( iInteger )) End Sub End Module

Excepie netratat: System.OverflowException: operaie aritmetic a dus l revrsare. la Tester.Main ()

Original
Module Tester Public Sub Main() Dim iInteger As Integer = 5280 Dim lLong As Long Dim bytByte As Byte Dim sngSingle As Single Dim dblDouble As Double Dim decDecimal As Decimal Console.Writeline("Convert to a Byte: {0}", CByte(iInteger)) End Sub End Module

Unhandled Exception: System.OverflowException: Arithmetic operation resul overflow. at Tester.Main()

CSng: conversia la Single


Modulul Tester

Public Sub Main () Dim iInteger Ca Integer = Dim lLong Ca pe Dim bytByte Ca Byte Dim sngSingle Ca Singur Dim dblDouble cum dubl Dim decDecimal Ca Zecimal

5280

Console.WriteLine ( "Conversia la un singur: {0}" , CSng ( iInteger ) End Sub End Module

3.4 )

Conversia la un singur: 1,552.94117647059

Originar

Module Tester Public Sub Main() Dim iInteger As Integer = 5280 Dim lLong As Long Dim bytByte As Byte Dim sngSingle As Single Dim dblDouble As Double Dim decDecimal As Decimal Console.WriteLine("Convert to a Single: {0}", CSng(iInteger) / 3.4) End Sub End Module

Convert to a Single: 1552.94117647059

String este ca "expresii regulate *"


public class de testare public comun sub principal Dim s Ca String s = "VB.Net" Dac e ca "* VB.Net" End Sub clasa End

Apoi Console.WriteLine ( "" VB.Net "este ca" * VB

"VB.Net" este ca i cum "? B.Net"

Originar

public class Test public Shared Sub Main Dim s As String s = "VB.Net" If s Like "*VB.Net" Then Console.WriteLine("'VB.Net' is Like '*VB.Net'") End Sub End class

'VB.Net' is Like '?B.Net'

If cu Si (If with And)


Importurile Public class System Test de

Shared Sub Main () Dim dtCurrent Ca System.DateTime Dim iHour Ca Integer dtCurrent = dtCurrent.Now () iHour = dtCurrent.Hour n cazul n care ( iHour < 12 ) Apoi Console.WriteLine ( "Bun dimineaa!" ) elseif ( iHour> = 12 ) i ( iHour < 18 ) Console.WriteLine ( "Bun ziua!" ) Else Console.WriteLine ( "Bun seara! " ) End If End Sub End Class

Apoi

Bun ziua!

Originar

.If with And


Imports System Public Class Test Shared Sub Main() Dim dtCurrent As System.DateTime Dim iHour As Integer

dtCurrent = dtCurrent.Now() iHour = dtCurrent.Hour If (iHour < 12) Then Console.Writeline("Good Morning!") ElseIf (iHour >= 12) And (iHour < 18) Then Console.WriteLine("Good Afternoon!") Else Console.WriteLine("Good Evening!") End If End Sub End Class

Good Afternoon!

Imbricate if
Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim temp Dac Ca Integer = 32 Apoi, 32

temp <=

Dac temperatura = 32 Apoi Console.WriteLine ( "temp = 32" ) Else Console.WriteLine ( "Temp: {0}" , temp ) End Dac End Dac End Sub End Module

temp = 32

Originar
Option Strict On Imports System Module Module1 Sub Main( ) Dim temp As Integer = 32 If temp <= 32 Then If temp = 32 Then Console.WriteLine("temp = 32") Else Console.WriteLine("Temp: {0}", temp) End If

End If End Sub End Module

temp = 32

Utilizai elseif
Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim temp Ca Integer = - 32

Dac temperatura> 32 Apoi elseif temp = 32 Apoi Console.WriteLine ( "= 32" ) elseif temp> 0 Apoi elseif temp = 0 Apoi Console.WriteLine ( "= 0" ) Else Console.WriteLine ( "Else" ) End Dac End Sub Ma " n End Module

Altfel

Original
Option Strict On Imports System Module Module1 Sub Main( ) Dim temp As Integer = -32 If temp > 32 Then ElseIf temp = 32 Then Console.WriteLine("= 32") ElseIf temp > 0 Then ElseIf temp = 0 Then Console.WriteLine(" = 0") Else Console.WriteLine("Else") End If End Sub 'Main End Module

Else

Else cazul n care (nu elseif)


Importurile Public class System Test de

Shared Sub Main () Dim dtCurrent Ca System.DateTime Dim iHour Ca Integer dtCurrent = dtCurrent.Now () iHour = dtCurrent.Hour n cazul n care ( iHour < 12 ) Apoi Console.WriteLine ( "Bun dimineaa!" ) Altfel Dac ( iHour> = 12 ) i ( iHour < Console.WriteLine ( "Bun ziua!" ) Else Console.WriteLine ( "Bun seara ! " ) End If End Sub End Class

18 )

Apoi

Foarte bine.

Original
Imports System Public Class Test Shared Sub Main() Dim dtCurrent As System.DateTime Dim iHour As Integer dtCurrent = dtCurrent.Now() iHour = dtCurrent.Hour If (iHour < 12) Then Console.Writeline("Good Morning!") Else If (iHour >= 12) And (iHour < 18) Then Console.WriteLine("Good Afternoon!") Else Console.WriteLine("Good Evening!") End If End Sub End Class

Very Good.

Use Dac afirmaie ntr-o declaraie pentru


public class de testare public comun sub principal Dim Dim intCounter Ca Integer strString Ca String = "unele ir stupide"

Pentru intCounter = Dac strString strString = strString = End Dac Urmtor intCounter Console.WriteLine ( End Sub Clasa final

0 Pentru a strString.Length - 1 ( intCounter ) = "s" Atunci, strString.Remove ( intCounter, 1 ) strString.Insert ( intCounter, "S" ) strString )

Unele String Silly

Original
public class Test public Shared Sub Main Dim intCounter As Integer Dim strString As String = "some silly string" For intCounter = 0 To strString.Length - 1 If strString(intCounter) = "s" Then strString = strString.Remove(intCounter, 1) strString = strString.Insert(intCounter, "S") End If Next intCounter Console.WriteLine(strString) End Sub End class

Some Silly String

public class de testare public comun sub principal Dim Dim intScore Ca Integer strResult Ca String 78

intScore =

Dac

intScore < 50 Apoi strResult = "Failed." elseif intScore < 75 Apoi strResult = "Pass." elseif intScore < 90 Apoi strResult = "Foarte bine". Altfel strResult = "Excelent." Dac End Console.WriteLine ( strResult ) End Sub Clasa final

Foarte bine.

Original
public class Test public Shared Sub Main Dim intScore As Integer Dim strResult As String intScore = 78 If intScore < 50 Then strResult = "Failed." ElseIf intScore < 75 Then strResult = "Pass." ElseIf intScore < 90 Then strResult = "Very Good." Else strResult = "Excellent." End If Console.WriteLine(strResult) End Sub End class

Very Good.

Single linie vs Multi-line Dac declaraia


public class de testare public comun sub principal

Dim

intScore 23

Ca

Integer

intScore =

"Si linie ngle Dac Dac intScore < 50

declaratie. Apoi Console.WriteLine ( "Failed." )

: Console.WriteLine

"Mu LTI-line Dac declaratie. Dac intScore < 50 Apoi Console.WriteLine ( "Failed." ) Console.WriteLine ( "V rugm s ncercai din nou." ) End If End Sub Clasa final

Nu V Nu V

a reuit. rugm s ncercai din nou. a reuit. rugm s ncercai din nou.

Originar
public class Test public Shared Sub Main Dim intScore As Integer intScore = 23

'Single line If statement. If intScore < 50 Then Console.WriteLine("Failed.") : Console.WriteLine("Please t 'Multi-line If statement. If intScore < 50 Then Console.WriteLine("Failed.") Console.WriteLine("Please try again.") End If End Sub End class

Failed. Please try again. Failed. Please try again.

If declaratie scurtcircuitul
Public class scurtcircuitarea comun Sub Main () Dac testare ( "stnga" ) "a face ceva End Dac End Sub

i de testare ( "dreapta" )

Apoi,

comun test de funcionare ( sInput Ca System.Console.WriteLine ( sInput ) test = FALSE End Function End Class

String )

Ca

Boolean

Stnga Dreapta

Originar
Public Class ShortCircuiting Shared Sub Main() If Test("Left") AND Test("Right") Then 'do something End If End Sub Shared Function Test(sInput As String) As Boolean System.Console.WriteLine(sInput) Test = FALSE End Function End Class

Left Right

If scurtcircuitul cu andalso
Public class scurtcircuitarea comun Sub Main () Dac testare ( "stnga" ) "a face ceva End Dac End Sub

andalso test ( "dreapta" )

Apoi,

comun test de funcionare ( sInput Ca System.Console.WriteLine ( sInput ) test = FALSE End Function End Class

String )

Ca

Boolean

Stnga

Originar

If Short Circuiting with ANDALSO


Public Class ShortCircuiting Shared Sub Main() If Test("Left") ANDALSO Test("Right") Then 'do something End If End Sub Shared Function Test(sInput As String) As Boolean System.Console.WriteLine(sInput) Test = FALSE End Function End Class

Left

IIf
public class de testare public comun sub principal Dim intScore 23 IIf (( intScore < 50 ) , 1 , 2 )) Ca Integer

intScore =

Console.WriteLine ( End Sub Clasa final

Original
public class Test public Shared Sub Main Dim intScore As Integer intScore = 23 Console.WriteLine( IIf((intScore < 50), 1, 2) ) End Sub

End class

Utilizarea cu Declaraia cu obiect Form Importurile System.Drawing Importurile System.Windows.Forms Clasa publice WithForm: Motenete Forma Public comun Sub Main () Dim FRM ca nou form cu FRM BackColor = Color.Gray. ForeColor = Color.Red. Text =. "cu afirmaia" Enabled = Adevrat. Topmost = Adevrat. MinimizeBox =. fals . ShowDialog () End Cu End Sub End Class
Original

Imports System.Drawing Imports System.Windows.Forms Public Class WithForm : Inherits Form Public Shared Sub Main() Dim frm as New Form With frm .BackColor = Color.Gray .ForeColor = Color.Red .Text = "The With Statement" .Enabled = True .Topmost = True .MinimizeBox = False .ShowDialog()

End With End Sub End Class


Introducei declaraie n cu declaraia

Importurile System.Drawing Importurile System.Windows.Forms Clasa publice WithForm: Inherits Forma Public comun Sub Main () Dim frm ca nou form cu FRM . BackColor = Color.Gray . ForeColor = Color.Red . Text = "cu afirmaia" Dim FNT Ca Font =. Font MsgBox ( fnt.Name ) . Activat = Adevrat . Topmost = Adevrat . MinimizeBox = Fals . ShowDialog () End Cu End Sub End Class Original Imports System.Drawing Imports System.Windows.Forms Public Class WithForm : Inherits Form Public Shared Sub Main() Dim frm as New Form With frm .BackColor = Color.Gray .ForeColor = Color.Red .Text = "The With Statement" Dim fnt As Font = .Font MsgBox(fnt.Name)

.Enabled = True .Topmost = True .MinimizeBox = False .ShowDialog() End With End Sub End Class

Imbricate cu declaraia
Importurile System.Drawing Importurile System.Windows.Forms Public class Form1: Inherits Forma Public comun Sub Main () Dim FRM Ca New Form1 () Application.Run ( FRM ) End Sub Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e ca System.EventArgs ) Manere MyBase.Load cu mine . BackColor = Color.Gray . ForeColor = Color.Red . Text = "cu afirmaia" . Activat = Adevrat . cel mai de sus = Adevrat . MinimizeBox = Fals Pentru fiecare CTRL Ca de control n. Controale cu ctrl . BackColor = SystemColors.Window . AutoSize = Fals . Cursor = Cursors.Hand Sfrit Cu Urmtor Sfrit Cu

End Sub End Class

Originar

Imports System.Drawing Imports System.Windows.Forms Public Class Form1 : Inherits Form Public Shared Sub Main() Dim frm As New Form1() Application.Run(frm) End Sub Private Sub Form1_Load(ByVal sender As System.Object , ByVal e As System.EventArgs) Handles MyBase.Load With Me .BackColor = Color.Gray .ForeColor = Color.Red .Text = "The With Statement" .Enabled = True .TopMost = True .MinimizeBox = False For Each ctrl As Control In .Controls With ctrl .BackColor = SystemColors.Window .AutoSize = False .Cursor = Cursors.Hand End With Next End With End Sub End Class

Use cu afirmaia cu OpenFileDialog


Importurile System.Windows.Forms

public class OpenFileDialogWith public comun sub principal Dim OpenFileDialog1 Ca OpenFileDialog = New System.Windows.Forms.OpenFileDial Cu OpenFileDialog1 filename =. "C: \ My Documents \ Doc1.txt"

. DefaultExt = ". txt" . Filter = "Fiiere text | . * TXT " . Filter = . ". Bitmapuri | * BMP | gif | * | GIF" si _ .... "imagini JPG | * JPG | Toate Imagini | * BMP, GIF *, * JPG" . FilterIndex = 2 InitialDirectory =. "C: \ My Documents" . ShowReadOnly = Adevrat . ReadOnlyChecked = True End Cu Dac OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Apoi Console.WriteLine ( OpenFileDialog1.FileName )

End If End Sub clasa End

Original

Imports System.Windows.Forms public class OpenFileDialogWith public Shared Sub Main Dim OpenFileDialog1 As OpenFileDialog = New Sys tem.Windows.Forms.OpenFileDialog With OpenFileDialog1 .FileName = "C:\My Documents\Doc1.txt" .DefaultExt = ".txt" .Filter = "Text Files|*.TXT" .Filter = "Bitmaps|*.BMP|GIF Images|*.GIF|" & _ "JPG Images|*.JPG|All Images|*.BMP;*.GIF ;*.JPG" .FilterIndex = 2 .InitialDirectory = "C:\My Documents" .ShowReadOnly = True .ReadOnlyChecked = True End With If OpenFileDialog1.ShowDialog = Windows.Forms.D ialogResult.OK Then Console.WriteLine(OpenFileDialog1.FileName) End If

End Sub End class


Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim loopCounter Ca Integer Pentru loopCounter = 0 la 9 Console.WriteLine ( "loopCounter: {0}" , loopCounter ) Urmtorul End Sub End Module

loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter:

0 1 2 3 4 5 6 7 8 9

Originar
Option Strict On Imports System Module Module1 Sub Main( ) Dim loopCounter As Integer For loopCounter = 0 To 9 Console.WriteLine("loopCounter: {0}", loopCounter) Next End Sub End Module

loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter:

0 1 2 3 4 5 6 7

loopCounter: 8 loopCounter: 9

Using Pentru structura / Next pentru a demonstra nsumare.


Importurile Tester modul Sub Main () Dim suma = 0 , numrul Ca Integer 2 System.Windows.Forms

"Un dd chiar numere pentru numrul de = suma + = numr urmtoare

de la 2 la 100 2 Pentru 100 Pasul

Console.WriteLine ( "Suma este" End Sub End Module

& sum &

"Suma chiar ntregi la 2 la 100" )

Suma este numere ntregi chiar 2550Sum la 2 la 100

Originar
Imports System.Windows.Forms Module Tester Sub Main() Dim sum = 0, number As Integer ' add even numbers from 2 to 100 For number = 2 To 100 Step 2 sum += number Next Console.WriteLine("The sum is " & sum & "Sum even integers from 2 to 100") End Sub End Module

The sum is 2550Sum even integers from 2 to 100

Calculating dobnda compus.


Tester modul

Sub

Main () Dim suma, principalul Ca Dim rata Ca dubl Dim an Ca Integer Dim ieire Ca String principal = 1000 rata = 0.05 ieire = "Anul" & vbTab &

Zecimal

"Suma pe depozit"

& vbCrLf

Pentru anul = 1 Pentru a 10 suma = principal * ( 1 + rata ) ^ an ieire & = an si vbTab & _ String.Format ( "{0: C}" , suma ) si vbCrLf urmtoare Console.WriteLine ( ieire ) End Sub End Module

Anul Suma pe depozit 1 $ 1,050.00 2 $ 1,102.50 3 $ 1,157.63 4 $ 1,215.51 5 $ 1,276.28 6 $ 1,340.10 7 $ 1,407.10 8 $ 1,477.46 9 $ 1,551.33 10 $ 1,628.89

Original
Module Tester Sub Main() Dim amount, principal As Decimal Dim rate As Double Dim year As Integer Dim output As String principal = 1000 rate = 0.05 output = "Year" & vbTab & "Amount on deposit" & vbCrLf For year = 1 To 10 amount = principal * (1 + rate) ^ year output &= year & vbTab & _ String.Format("{0:C}", amount) & vbCrLf Next Console.WriteLine(output)

End Sub End Module

Year 1 2 3 4 5 6 7 8 9 10

Amount on deposit $1,050.00 $1,102.50 $1,157.63 $1,215.51 $1,276.28 $1,340.10 $1,407.10 $1,477.46 $1,551.33 $1,628.89

For cu flotor punct numr de control


Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim loopCounter Ca Single Pentru loopCounter = 0,5 la 9 Console.WriteLine ( "loopCounter: {0}" , loopCounter ) Urmtorul End Sub End Module 'Ma n

loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter:

0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5

Original
Option Strict On Imports System Module Module1 Sub Main( )

Dim loopCounter As Single For loopCounter = 0.5 To 9 Console.WriteLine("loopCounter: {0}", loopCounter) Next End Sub 'Main End Module

loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter:

0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5

Set pentru bucl Pasul float


Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim loopCounter Ca Single Pentru loopCounter = 0,5 a 9 Pasul 0.5 Console.WriteLine ( "loopCounter: {0}" , loopCounter ) Urmtorul End Sub End Module 'Ma n

loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter:

0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7

loopCounter: loopCounter: loopCounter: loopCounter:

7.5 8 8.5 9

Original
importurile sistem Modulul Module1 Sub Main () Dim loopCounter Ca Single Pentru loopCounter = 0,5 a 9 Pasul 0.5 Console.WriteLine ( "loopCounter: {0}" , loopCounter ) Urmtorul End Sub End Module 'Ma n

loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter: loopCounter:

0.5 1 1.5 2 2.5 3 3,5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9

Nested pentru bucl


Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim exterior Ca Integer

Dim

interior

Ca

Integer

Pentru exterior = 3 Pentru a 6 pentru interior = 10 la 12 Console.WriteLine ( "{0} * {1} = {2}" , _ exterior, interior, exterior * interior ) nainte interior, exterior End Sub End Module 'Ma n

3 3 3 4 4 4 5 5 5 6 6 6

* * * * * * * * * * * *

10 11 12 10 11 12 10 11 12 10 11 12

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

30 33 36 40 44 48 50 55 60 60 66 72

Originar
Option Strict On Imports System Module Module1 Sub Main( ) Dim outer As Integer Dim inner As Integer For outer = 3 To 6 For inner = 10 To 12 Console.WriteLine("{0} * {1} = {2}", _ outer, inner, outer * inner) Next inner, outer End Sub 'Main End Module

3 3 3 4 4 4 5 5

* * * * * * * *

10 11 12 10 11 12 10 11

= = = = = = = =

30 33 36 40 44 48 50 55

5 6 6 6

* * * *

12 10 11 12

= = = =

60 60 66 72

Float pas
public class de testare public comun Sub principale pentru x Ca Single = 1 la 3 Pasul 0.5 Console.WriteLine ( x.ToString ( "0.0" )) nainte x End Sub Clasa final

1.0 1.5 2.0 2.5 3.0

Original
public class Test public Shared Sub Main For x As Single = 1 To 3 Step 0.5 Console.WriteLine(x.ToString("0.0")) Next x End Sub End class

1.0 1.5 2.0 2.5 3.0

Calculated
public class de testare public comun Sub principale pentru x Ca Single = 1 la Console.WriteLine ( x )

Pasul

nainte x End Sub Clasa final

1 1.142857 1.285714 1.428572 1.571429 1.714286 1.857143

Original
public class Test public Shared Sub Main For x As Single = 1 To 2 Step 1 / 7 Console.WriteLine(x) Next x End Sub End class

1 1.142857 1.285714 1.428572 1.571429 1.714286 1.857143

Ieire pentru 1
public class de testare public comun sub principal Dim j Ca Integer Pentru i Ca Integer = 1 la 3 J = 0 n timp ce face j < 3 + J = 1 pentru k Ca Integer = 1 la 3 Dim test1 Ca Boolean = k = Dac test1 Apoi, Exit Pentru

2 "E xits Pentru K bucla.

Dim test2 Ca Boolean = i = j Dac test2 Apoi Exit Do "E xits Do. Console.WriteLine ( I & nainte k Bucl "," & J & "," & K )

Urmtor i End Sub Clasa final

2, 1, 1 3, 1, 1 3, 2, 1

Original

public class Test public Shared Sub Main Dim j As Integer For i As Integer = 1 To 3 j = 0 Do While j < 3 j += 1 For k As Integer = 1 To 3 Dim test1 As Boolean = k = 2 If test1 Then Exit For ' Exits the For K loop. Dim test2 As Boolean = i = j If test2 Then Exit Do ' Exits the D o. Console.WriteLine(i & ", " & j & ", " & k) Next k Loop Next i End Sub End class

Use pentru fiecare bucl a prin Array


Opiunea stricte privind importurile System Public class Angajat private empID Ca Integer Public Sub New ( ByVal empID Me.empID = empID

Ca

Integer )

End Sub Public nlocuiete ToString Funcia () empID.ToString retur () End Function End Class clasa Tester Main () Ca String

Shared Sub

Dim intArray () Ca Integer Dim empArray () Ca Angajat intArray = nou Integer ( 5 ) {} empArray = nou angajat ( 3 ) {} Dim i Ca Integer Pentru i = 0 Pentru a empArray.Length - 1 empArray ( i ) = nou angajat ( i + 5 ) nainte I Console.WriteLine ( "matrice Integer ..." ) Dim intValue Ca Integer pentru fiecare intValue n intArray Console.WriteLine ( intValue.ToString ()) nainte Console.WriteLine ( "Angajatul matrice ..." ) Dim e Ca angajat pentru fiecare mesaj n empArray Console.WriteLine ( e ) Urmtorul End Sub "Ru n End Class

Matrice Integer ... 0 0 0 0 0 0 Matrice angajat ... 5 6 7 8

Original

Option Strict On Imports System

Public Class Employee Private empID As Integer Public Sub New(ByVal empID As Integer) Me.empID = empID End Sub Public Overrides Function ToString( ) As String Return empID.ToString( ) End Function End Class Class Tester Shared Sub Main( ) Dim intArray( ) As Integer Dim empArray( ) As Employee intArray = New Integer(5) {} empArray = New Employee(3) {} Dim i As Integer For i = 0 To empArray.Length - 1 empArray(i) = New Employee(i + 5) Next i Console.WriteLine("The Integer array...") Dim intValue As Integer For Each intValue In intArray Console.WriteLine(intValue.ToString( )) Next Console.WriteLine("The employee array...") Dim e As Employee For Each e In empArray Console.WriteLine(e) Next End Sub 'Run End Class

The Integer array... 0 0 0 0 0 0 The employee array... 5 6 7 8

Pentru fiecare cu Colectia

Importuri

System.Collections

public class de testare public comun Sub principale Dim m_employees Ca New Collection m_employees.Add ( nou angajat ( "A" , m_employees.Add ( nou angajat ( "B" , m_employees.Add ( nou angajat ( "C" ,

"F" , "E" , "D" ,

"F" )) "H" )) "I" ))

Pentru fiecare emp1 Ca angajat n m_employees Dac emp1.FirstName = "O" Apoi continua Console.WriteLine ( emp1.Title & "" & emp1.FirstName & nainte emp1 End Sub Clasa final Public class Angajat publice Prenume Ca String Public NumeDeFamilie Ca String Public titlu Ca String Public Sub New ( prenume ByVal Ca Prenume = prenume LastName = LAST_NAME Title = new_title End Sub End Class

""

& emp1.LastNam

String, LAST_NAME ByVal

Ca

String, ByVal new_

HBE ICD

Original
Imports System.Collections public class Test public Shared Sub Main Dim m_employees As New Collection m_employees.Add(New employee("A", "F", "F")) m_employees.Add(New employee("B", "E", "H")) m_employees.Add(New employee("C", "D", "I")) For Each emp1 As employee In m_employees If emp1.FirstName = "A" Then Continue For Console.WriteLine(emp1.Title & " " & emp1.FirstName & " " & emp1.LastName) Next emp1 End Sub End class

Public Class Employee Public FirstName As String Public LastName As String Public Title As String Public Sub New(ByVal first_name As String, ByVal last_name As String, ByVal new_titl FirstName = first_name LastName = last_name Title = new_title End Sub End Class

H B E I C D

Using Do / Bucl pn la structura de repetare


Tester modul Sub Main () Dim contor Ca Integer = 1 "" )

Face Console.Write ( contra & + contor = 1 Bucl pn la contor> 5 End Sub End Module

1 2 3 4 5 "

Original
Module Tester Sub Main() Dim counter As Integer = 1 Do Console.Write(counter & " ") counter += 1 Loop Until counter > 5 End Sub End Module

1 2 3 4 5 "

Do until
Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim counterVariable Ca Integer = 0

Face Pn counterVariable = 10 Console.WriteLine ( "counterVariable: {0}" , counterVariable ) counterVariable = counterVariable + 1 Bucl End Sub End Module

counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable:

0 1 2 3 4 5 6 7 8 9

Original

Option Strict On Imports System Module Module1 Sub Main( ) Dim counterVariable As Integer = 0 Do Until counterVariable = 10 Console.WriteLine("counterVariable: {0}", counterVariable) counterVariable = counterVariable + 1 Loop End Sub End Module

counterVariable: 0 counterVariable: 1 counterVariable: 2

counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable:

3 4 5 6 7 8 9

Do bucl n timp ce
Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim counterVariable Ca Integer = 0

n timp ce face counterVariable < 10 Console.WriteLine ( "counterVariable: {0}" , counterVariable ) counterVariable = counterVariable + 1 Bucl End End Sub Module

counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable:

0 1 2 3 4 5 6 7 8 9

Original

Option Strict On Imports System Module Module1 Sub Main( ) Dim counterVariable As Integer = 0 Do While counterVariable < 10 Console.WriteLine("counterVariable: {0}", counterVariable) counterVariable = counterVariable + 1

Loop End Sub End Module

counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable:

0 1 2 3 4 5 6 7 8 9

Exit face n timp ce


public class de testare public comun sub principal Dim j Ca Integer Pentru i Ca Integer = 1 la 3 J = 0 n timp ce face j < 3 + J = 1 pentru k Ca Integer = 1 la 3 Dim test1 Ca Boolean = k = Dac test1 Apoi, Exit Pentru

2 "E xits Pentru K bucla.

Dim test2 Ca Boolean = i = j Dac test2 Apoi Exit Do "E xits Do. Console.WriteLine ( I & nainte k Bucl Urmtor i End Sub Clasa final "," & J & "," & K )

2, 1, 1 3, 1, 1 3, 2, 1

Original
public class Test public Shared Sub Main Dim j As Integer For i As Integer = 1 To 3 j = 0

Do While j < 3 j += 1 For k As Integer = 1 To 3 Dim test1 As Boolean = k = 2 If test1 Then Exit For ' Exits the For K loop. Dim test2 As Boolean = i = j If test2 Then Exit Do ' Exits the Do. Console.WriteLine(i & ", " & j & ", " & k) Next k Loop Next i End Sub End class

2, 1, 1 3, 1, 1 3, 2, 1

Using cuvntul cheie Exit n structurile de repetiie


Tester modul Sub Main () Dim ieire Dim contra Ca Ca String Integer Apoi,

Pentru contor = 1 Pentru a 10 n cazul n care contorul = 3 de ieire pentru Sfrit dac Urmtor

ieire = "contra =" & contra & _ "dup ieirea Pentru structura / urmtoare" Pn face counter> n cazul n care Exit Do Dac End contor + = Bucl 1 10 contorul = 5 Apoi

& vbCrLf

Ieire & = "contra =" & contra & _ "dup ieirea te Pn structur / Bucl" n timp ce contor <= 10 Dac contor = 7 Apoi Ieire n timp ce End Dac

& vbCrLf

End

contor + = timp

Ieire & = "contra =" & contra & _ "dup ieirea timp ce structura" Console.WriteLine ( ieire ) End Sub End Module

contor = 3, dup ieirea Pentru structura / Urmatoarea contor = 5 dup ieirea te Pn structur / Bucl contracara = 7, dup ieirea timp ce structura

Original

Module Tester Sub Main() Dim output As String Dim counter As Integer For counter = 1 To 10 If counter = 3 Then Exit For End If Next output = "counter = " & counter & _ " after exiting For/Next structure" & vbCrLf Do Until counter > 10 If counter = 5 Then Exit Do End If counter += 1 Loop output &= "counter = " & counter & _ " after exiting Do Until/Loop structure" & vbCrLf While counter <= 10 If counter = 7 Then Exit While End If counter += 1 End While

output &= "counter = " & counter & _ " after exiting While structure" Console.WriteLine(output) End Sub End Module

counter = 3 after exiting For/Next structure counter = 5 after exiting Do Until/Loop structure counter = 7 after exiting While structure

.Do cu Exit Do
Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim counterVariable Ca Integer = 0

Face Console.WriteLine ( "counterVariable: {0}" , counterVariable ) counterVariable = counterVariable + 1 Dac counterVariable> Exit Do End Dac Bucl End Sub End Module 'Ma n 9 Apoi

counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable:

0 1 2 3 4 5 6 7 8 9

Original

Option Strict On

Imports System Module Module1 Sub Main( ) Dim counterVariable As Integer = 0 Do Console.WriteLine("counterVariable: {0}", counterVariable) counterVariable = counterVariable + 1 If counterVariable > 9 Then Exit Do End If Loop End Sub 'Main End Module

counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable:

0 1 2 3 4 5 6 7 8 9

Ieire pentru
public class de testare public comun sub principal Dim j Ca Integer Pentru i Ca Integer = 1 la 3 J = 0 n timp ce face j < 3 + J = 1 pentru k Ca Integer = 1 la 3 Dim test1 Ca Boolean = k = Dac test1 Apoi, Exit Pentru

2 "E xits Pentru K bucla.

Dim test2 Ca Boolean = i = j Dac test2 Apoi Exit Do "E xits Do. Console.WriteLine ( I & nainte k Bucl Urmtor i End Sub Clasa final "," & J & "," & K )

2, 1, 1

3, 1, 1 3, 2, 1

Original
public class Test public Shared Sub Main Dim j As Integer For i As Integer = 1 To 3 j = 0 Do While j < 3 j += 1 For k As Integer = 1 To 3 Dim test1 As Boolean = k = 2 If test1 Then Exit For ' Exits the For K loop. Dim test2 As Boolean = i = j If test2 Then Exit Do ' Exits the Do. Console.WriteLine(i & ", " & j & ", " & k) Next k Loop Next i End Sub End class

2, 1, 1 3, 1, 1 3, 2, 1

Continue Do
public class de testare public comun sub principal Dim j Ca Integer Pentru i Ca Integer = 1 la 3 J = 0 n timp ce face j < 3 + J = 1 pentru k Ca Integer = 1 la 3 Dim test1 Ca Boolean = k = 2 Dac test1 Apoi, Pentru a continua Dim test2 Ca Boolean = i = j Dac test2 Apoi continua s fac Console.WriteLine ( I & nainte k Bucl Urmtor i End Sub "," & J &

"C ontinues Pentru K bucla. "C ontinues Do. "," & K )

Clasa final

1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,

2, 2, 3, 3, 1, 1, 3, 3, 1, 1, 2, 2,

1 3 1 3 1 3 1 3 1 3 1 3

Original
public class de testare public comun sub principal Dim j Ca Integer Pentru i Ca Integer = 1 la 3 J = 0 n timp ce face j < 3 + J = 1 pentru k Ca Integer = 1 la 3 Dim test1 Ca Boolean = k = 2 Dac test1 Apoi, Pentru a continua Dim test2 Ca Boolean = i = j Dac test2 Apoi continua s fac Console.WriteLine ( I & nainte k Bucl Urmtor i End Sub Clasa final "," & J &

"C ontinues Pentru K bucla. "C ontinues Do. "," & K )

1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,

2, 2, 3, 3, 1, 1, 3, 3, 1, 1, 2, 2,

1 3 1 3 1 3 1 3 1 3 1 3

Continua
Opiunea stricte cu privire la Public Modul ContinueStatement Public Sub Main () Pentru CTR Ca Integer = 1 la 100 Dac CTR-Mod 2 = 1 Apoi Console.Write ( "{0} este ciudat" , ctr ) Else Console.WriteLine ( "{0} este chiar." , ctr ) continua End Dac Dac CTR-ul Mod 3 = 0 Apoi Console.Write ( "i este divizibil cu 3" ) Dac End Dac CTR-ul Mod 5 = 0 Apoi Console.Write ( "i este divizibil cu 5" ) End Dac Dac ctr Mod 7 = 0 Apoi Console.Write ( "i este divizibil cu 7" ) End Dac Console.WriteLine () Urmtor End Sub End Module

1 este impar 2 este chiar. 3 este impar i este divizibil cu 3 4 este chiar. 5 este impar i este divizibil cu 5 6 este chiar. 7 este impar i este divizibil cu 7 8 este chiar. 9 este impar i este divizibil cu 3 10 este chiar. 11 este impar 12 este chiar. 13 este impar 14 este chiar. 15 este impar i este divizibil cu 3 i este divizibil cu 5 16 este chiar. 17 este impar 18 este chiar. 19 este impar 20 este chiar. 21 este impar i este divizibil cu 3 i este divizibil cu 7 22 este chiar. 23 este impar 24 este chiar. 25 este impar i este divizibil cu 5 26 este chiar. 27 este impar i este divizibil cu 3

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este este

chiar. impar chiar. impar chiar. impar i chiar. impar i chiar. impar chiar. impar i chiar. impar chiar. impar chiar. impar i chiar. impar chiar. impar i chiar. impar i chiar. impar chiar. impar i chiar. impar i chiar. impar chiar. impar chiar. impar i chiar. impar i chiar. impar chiar. impar i chiar. impar chiar. impar chiar. impar i chiar. impar i chiar.

este divizibil cu 3 este divizibil cu 5 i este divizibil cu 7

este divizibil cu 3

este divizibil cu 3 i este divizibil cu 5

este divizibil cu 7 este divizibil cu 3

este divizibil cu 5 este divizibil cu 3

este divizibil cu 3 i este divizibil cu 7 este divizibil cu 5

este divizibil cu 3

este divizibil cu 3 i este divizibil cu 5 este divizibil cu 7

79 este impar 80 este chiar. 81 este impar i este divizibil cu 3 82 este chiar. 83 este impar 84 este chiar. 85 este impar i este divizibil cu 5 86 este chiar. 87 este ciudat i este divizibil cu 3 88 este chiar. 89 este impar 90 este chiar. 91 este impar i este divizibil cu 7 92 este chiar. 93 este impar i este divizibil cu 3 94 este chiar. 95 este impar i este divizibil cu 5 96 este chiar. 97 este impar 98 este chiar. 99 este impar i este divizibil cu 3 100 este chiar.

Original
Option Strict On Public Module ContinueStatement Public Sub Main() For ctr As Integer = 1 to 100 If ctr Mod 2 = 1 Then Console.Write("{0} is odd", ctr) Else Console.WriteLine("{0} is even.", ctr) Continue For End If If ctr Mod 3 = 0 Then Console.Write(" and it is divisible by 3") End If If ctr Mod 5 = 0 Then Console.Write(" and it is divisible by 5") End If If ctr Mod 7 = 0 Then Console.Write(" and it is divisible by 7") End If Console.WriteLine() Next End Sub End Module

1 is odd 2 is even. 3 is odd and it is divisible by 3

4 is even. 5 is odd and it is divisible by 5 6 is even. 7 is odd and it is divisible by 7 8 is even. 9 is odd and it is divisible by 3 10 is even. 11 is odd 12 is even. 13 is odd 14 is even. 15 is odd and it is divisible by 3 16 is even. 17 is odd 18 is even. 19 is odd 20 is even. 21 is odd and it is divisible by 3 22 is even. 23 is odd 24 is even. 25 is odd and it is divisible by 5 26 is even. 27 is odd and it is divisible by 3 28 is even. 29 is odd 30 is even. 31 is odd 32 is even. 33 is odd and it is divisible by 3 34 is even. 35 is odd and it is divisible by 5 36 is even. 37 is odd 38 is even. 39 is odd and it is divisible by 3 40 is even. 41 is odd 42 is even. 43 is odd 44 is even. 45 is odd and it is divisible by 3 46 is even. 47 is odd 48 is even. 49 is odd and it is divisible by 7 50 is even. 51 is odd and it is divisible by 3 52 is even. 53 is odd 54 is even.

and it is divisible by 5

and it is divisible by 7

and it is divisible by 7

and it is divisible by 5

55 is odd and 56 is even. 57 is odd and 58 is even. 59 is odd 60 is even. 61 is odd 62 is even. 63 is odd and 64 is even. 65 is odd and 66 is even. 67 is odd 68 is even. 69 is odd and 70 is even. 71 is odd 72 is even. 73 is odd 74 is even. 75 is odd and 76 is even. 77 is odd and 78 is even. 79 is odd 80 is even. 81 is odd and 82 is even. 83 is odd 84 is even. 85 is odd and 86 is even. 87 is odd and 88 is even. 89 is odd 90 is even. 91 is odd and 92 is even. 93 is odd and 94 is even. 95 is odd and 96 is even. 97 is odd 98 is even. 99 is odd and 100 is even.

it is divisible by 5 it is divisible by 3

it is divisible by 3 and it is divisible by 7 it is divisible by 5

it is divisible by 3

it is divisible by 3 and it is divisible by 5 it is divisible by 7

it is divisible by 3

it is divisible by 5 it is divisible by 3

it is divisible by 7 it is divisible by 3 it is divisible by 5

it is divisible by 3

Using structura de timp pentru a demonstra repetiie contra-contro

Tester modul Sub Main () Dim contor Ca Integer = 2 "" )

n timp ce contor <= 10 Console.Write ( contra & contor + = 2 End timp End Sub End Module

2 4 6 8 10

Original
Module Tester Sub Main() Dim counter As Integer = 2 While counter <= 10 Console.Write(counter & " ") counter += 2 End While End Sub End Module

2 4 6 8 10

Using Pentru structura / Next pentru a demonstra repetiie contracontrolat.


Tester modul Sub Main () Dim contra Ca Integer

Pentru contor = 2 a 10 Pasul 2 Console.Write ( contra & "" ) Urmatorul End Sub End Module

2 4 6 8 10

Original
Module Tester Sub Main() Dim counter As Integer For counter = 2 To 10 Step 2 Console.Write(counter & " ") Next End Sub End Module

2 4 6 8 10

Declaraia 4.16.1.GoTo cu eticheta


Opiunea stricte privind importurile sistem Modulul Module1 Sub Main () Dim counterVariable Ca Integer = 0

Repet: Console.WriteLine ( "counterVariable: {0}" , counterVariable ) counterVariable + = 1 Dac counterVariable < GoTo repetate Dac End End Sub End Module 10 Apoi

counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable:

0 1 2 3 4 5 6 7 8 9

Original

Option Strict On Imports System Module Module1 Sub Main( ) Dim counterVariable As Integer = 0 repeat: Console.WriteLine("counterVariable: {0}", counterVariable) counterVariable += 1 If counterVariable < 10 Then GoTo repeat End If End Sub End Module

counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable: counterVariable:

0 1 2 3 4 5 6 7 8 9

On Eroare GoTo errorhandle


Importurile System.IO principal

public class Tester public comun sub

Dim myfile Ca System.IO.File Dim W Ca System.IO.StreamWriter On Error GoTo errorhandle w = myfile.AppendText ( "a: \ temp.txt" ) w.Write ( "A" ) w.Close () Exit Sub errorhandle: Console.WriteLine ( "se introduce" ) Exit Sub CV End Sub clasa End

Va rugam sa introduceti

Original

Imports System.IO public class Tester public Shared Sub Main Dim myfile As System.IO.File Dim w As System.IO.StreamWriter On Error GoTo errorhandle w = myfile.AppendText("a:\temp.txt") w.Write("a") w.Close() Exit Sub errorhandle: Console.WriteLine("Please Insert") Exit Sub Resume End Sub End class

Please Insert

Select Err.Number Case


Importurile System.IO principal

public class Tester public comun sub

On Error GoTo ErrorHandle Exit Sub ErrorHandle: Select Case Err.Number Case 52 Console.WriteLine Cauza 53 Console.WriteLine Cauza 54 Console.WriteLine Cauza 55 Console.WriteLine Cauza 58 Console.WriteLine

( "Nume fiier excepie" ) ( "Fiierul nu poate fi gsit" ) ( "File Mode excepie" ) ( "fiier este aleady deschis" ) ( "Fiierul exist" )

Cauza 68 Console.WriteLine Cauza 75 Console.WriteLine Cauza 76 Console.WriteLine Else Cazul Console.WriteLine End Select End Sub clasa End

( "Dispozitivul nu este disponibil" ) ( "Exception Path" ) ( "Calea nu poate fi gsit " ) ( "Altele" )

Original

Imports System.IO public class Tester public Shared Sub Main On Error GoTo ErrorHandle Exit Sub ErrorHandle: Select Case Err.Number Case 52 Console.WriteLine("File Name Exception") Case 53 Console.WriteLine("File cannot be found") Case 54 Console.WriteLine("File Mode Exception") Case 55 Console.WriteLine("File is aleady open") Case 58 Console.WriteLine("File exists") Case 68 Console.WriteLine("Device is not available") Case 75 Console.WriteLine("Path Exception") Case 76 Console.WriteLine("Path cannot be found") Case Else Console.WriteLine("Other") End Select End Sub End class

Resume (A relua)
Modulul Module1 Sub Main () On Error GoTo manipulare Dim I1 Ca Integer = 0 Dim I2 Ca Integer = 128 Dim intResult Ca Integer intResult = I2 / I1 Console.WriteLine ( "Apsai Enter pentru a continua ..." ) Console.ReadLine () Exit Sub Handler: Console.WriteLine ( ". aprut o eroare de depire" ) CV Urmtor End Sub End Module

A aprut o eroare de depire. Apsai Enter pentru a continua ...

Original

Module Module1 Sub Main() On Error GoTo Handler Dim i1 As Integer = 0 Dim i2 As Integer = 128 Dim intResult As Integer intResult = i2 / i1 Console.WriteLine("Press Enter to continue...") Console.ReadLine() Exit Sub Handler: Console.WriteLine("An overflow error occurred.") Resume Next End Sub End Module

An overflow error occurred. Press Enter to continue...

Define o rutin sub i s-l


Opiunea stricte privind importurile sistemului Modulul Module1

Sub

Main () Console.WriteLine ( "In principal!" ) someMethod () Console.WriteLine ( "napoi n principal ()." ) End Sub Ma " n Sub someMethod () Console.WriteLine ( "Salutri de la someMethod!" ) End Sub End Module

n principal! Salutri de la someMethod! napoi n Main ().

Original

Option Strict On Imports System Module Module1 Sub Main( ) Console.WriteLine("In Main! ") SomeMethod( ) Console.WriteLine("Back in Main( ).") End Sub 'Main Sub SomeMethod( ) Console.WriteLine("Greetings from SomeMethod!") End Sub End Module

In Main! Greetings from SomeMethod! Back in Main( ).

Procedura sub care imprim informaii de plat.


Tester modul Sub Main () PrintSub PrintSub PrintSub PrintSub End Sub ( ( ( ( 40 38 20 50 , , , , 10.5 ) 21,75 ) 13 ) 14 )

Sub

PrintSub ( ore ByVal

Ca

dubla salariul, ByVal

Ca

Zecimal )

Console.WriteLine ( "plat este {0: C}" , ore * salariu ) End Sub End Module

Plata Plata Plata Plata

este este este este

de de de de

420.00 826.50 260.00 700.00

dolari dolari dolari dolari

Original

Sub Main() PrintSub(40, PrintSub(38, PrintSub(20, PrintSub(50, End Sub Sub PrintSub(ByVal hours As Double, ByVal wage As Decimal) Console.WriteLine("The payment is {0:C}", hours * wage) End Sub End Module 10.5) 21.75) 13) 14)

The The The The

payment payment payment payment

is is is is

$420.00 $826.50 $260.00 $700.00

Define funcie ntr-un modul


Modulul Module1 Vnzare const Const TaxRate Ca Ca Zecimal = Zecimal = 100 0.04D

GetTotalSale funcia () cum zecimal vnzare retur * ( 1 + TaxRate ) End Function Sub Main ()

Dim TotalSale Ca Zecimal = GetTotalSale () Console.WriteLine ( TotalSale )

End Sub End Module

104.00

Original

Module Module1 Const Sale As Decimal = 100 Const TaxRate As Decimal = 0.04D Function GetTotalSale() As Decimal Return Sale * (1 + TaxRate) End Function Sub Main() Dim TotalSale As Decimal = GetTotalSale() Console.WriteLine(TotalSale) End Sub End Module

104.00

Functions cu alt numr de parametru


Modulul Module1 Sub OneValue ( nume ByVal Ca String ) Console.WriteLine ( "Bun ziua," & Nume ) End Sub Sub TwoValues ( ByVal Vrsta Ca Integer, numele ByVal Console.WriteLine ( "Varsta:" & Age ) Console.WriteLine ( "Nume:" & Nume ) End Sub Sub ThreeValues ( Numele ByVal Ca String, Varsta ByVal Console.WriteLine ( "Nume:" & Nume ) Console.WriteLine ( "Varsta:" & Age ) Console.WriteLine ( "Salariu:" & Salariu ) End Sub Sub Main () OneValue ( "Gates" ) Ca String )

Ca

Integer Salariul, ByV

Console.WriteLine () TwoValues ( 50 , "Gates" ) Console.WriteLine () ThreeValues ( "Gates" , 50 , End Sub End Module

250000.0 )

Bun ziua, domnule Gates Vrsta: 50 Nume: Mr. Gates Nume: Mr. Gates Vrsta: 50 Salariu: 250000

Pune cod ntr-un modul


Modulul Module1 Sub Main () Console.WriteLine ( "primul meu program VB.NET" ) End Sub End Module

Prima mea Programul VB.NET

Declararea clas cu o metod care are un parametru


Modul YourClassTest Sub Main () Dim obj Ca New YourClass obj.DisplayMessage ( "AAA" ) End Sub "M Ain End Module Public class YourClass Public Sub DisplayMessage ( courseName ByVal Ca String ) Console.WriteLine ( _ "Bine ai venit la" & vbCrLf & courseName & "!" ) End Sub End Class

Bine ai venit l

Change textul etichetei i limea n aciune Button

Importurile

System.Windows.Forms

public class LabelWidthTextSettingInButtonAction public comun Sub principal Application.Run ( New frmFirstProgram ) End Sub End clasa Public class Motenete # Region frmFirstProgram System.Windows.Forms.Form

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer Ca apel

Boolea

"Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents lblName Ca System.Windows.Forms.Label prieten WithEvents btnChange Ca System.Windows.Forms.Button prieten WithEvents btnExit Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.lblName = New System.Windows.Forms.Label () Me.btnChange = nou System.Windows.Forms.Button () Me.btnExit = New System.Windows.Forms.Button () Me.SuspendLayout () " "lb lName ' Me.lblName.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me . lblName.Location = New System.Drawing.Point ( 16 , 16 ) Me.lblName.Name = "lblName" Me.lblName.Size = New System.Drawing.Size ( 104 , 24 ) Me.lblName.TabIndex = 0 Me lblName.Text =. "test" Me.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'bt nChange ' Me.btnChange.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 8,25 !, Syst Me.btnChange.Location = New System.Drawing.Point ( 16 , 176 ) Me.btnChange.Name = "btnChange" Me.btnChange . tabindex = 1 Me.btnChange.Text = "& Change" ' "bt nExit ' Me.btnExit.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 8,25 !, System Me.btnExit.Location = New System.Drawing.Point ( 176 , 176 ) Me.btnExit.Name = "btnExit" Me.btnExit.TabIndex = 2 Me.btnExit. Text = "& Ieire" " "fr mFirstProgram ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows . Forms.Control () { Me.btnExit, Me.btnCha Me.Name = "frmFirstProgram" Me.Text = "My First Programul" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub btnChange_Click ( ByVal expeditor lblName.Width = 200 lblName.Text = "un text" End Sub Private Sub btnExit_Click ( ByVal expeditor frmFirstProgram.ActiveForm.Dispose () End Sub End Class Ca

System

System.Object, ByVal e

ca

System.E

Original

Imports System.Windows.Forms public class LabelWidthTextSettingInButtonAction public Shared Sub Main Application.Run(New frmFirstProgram) End Sub End class Public Class frmFirstProgram Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents lblName As System.Windows.Forms.Label Friend WithEvents btnChange As System.Windows.Forms.Button Friend WithEvents btnExit As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.lblName = New System.Windows.Forms.Label() Me.btnChange = New System.Windows.Forms.Button() Me.btnExit = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'lblName ' Me.lblName.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblName.Location = New System.Drawing.Point(16, 16) Me.lblName.Name = "lblName" Me.lblName.Size = New System.Drawing.Size(104, 24) Me.lblName.TabIndex = 0 Me.lblName.Text = "test" Me.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'btnChange ' Me.btnChange.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Dr Me.btnChange.Location = New System.Drawing.Point(16, 176) Me.btnChange.Name = "btnChange" Me.btnChange.TabIndex = 1 Me.btnChange.Text = "&Change" ' 'btnExit ' Me.btnExit.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Draw Me.btnExit.Location = New System.Drawing.Point(176, 176) Me.btnExit.Name = "btnExit" Me.btnExit.TabIndex = 2 Me.btnExit.Text = "E&xit" ' 'frmFirstProgram ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnExit, Me.btnChange, M Me.Name = "frmFirstProgram" Me.Text = "My First Program" Me.ResumeLayout(False) End Sub #End Region

Private Sub btnChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs lblName.Width = 200 lblName.Text = "Some text" End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) frmFirstProgram.ActiveForm.Dispose() End Sub End Class

Font Label 14.2.3.Change

Importurile Importurile Importurile

System.Windows.Forms System.Drawing System.Drawing.Drawing2D

public class CheckBoxEvent public comun Sub principal Application.Run ( New FrmCheckBox ) End Sub End clasa Public class FrmCheckBox Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub WithEvents prieten chkItalic Ca System.Windows.Forms.CheckBox prieten WithEvents lblOutput Ca System.Windows.Forms.Label prieten WithEvents chkBold Ca System.Windows.Forms.CheckBox "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . lblOutput = New System.Windows.Forms.Label () Ca apel

Boole

Me.chkItalic = System.Windows.Forms.CheckBox Nou () Me.chkBold = System.Windows.Forms.CheckBox Nou () Me.SuspendLayout () " "lb lOutput " Me.lblOutput.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 11.25 !, S Me.lblOutput. Locaie = New System.Drawing.Point ( 48 , 24 ) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size ( 208 , 24 ) Me.lblOutput.TabIndex = 0 Me.lblOutput. Text = "Uita-te la schimbarea stilul de font" " "ch kItalic ' Me.chkItalic.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, Sy Me.chkItalic.Location = New System.Drawing.Point ( 152 , 64 ) Me.chkItalic.Name = "chkItalic" Me.chkItalic.Size = New System.Drawing.Size ( 64 , 24 ) Me.chkItalic.TabIndex = 2 Me.chkItalic.Text = "Italic" " "ch kBold ' Me.chkBold.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, Syst Me.chkBold.Location = New System.Drawing.Point ( 80 , 64 ) Me.chkBold.Name = "chkBold" Me.chkBold.Size = New System.Drawing.Size ( 56 , 24 ) Me.chkBold.TabIndex = 1 Me.chkBold.Text = "Bold" ' "Parintele mCheckBox ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 6 , 14 ) Me.ClientSize = New System.Drawing.Size ( 292 , 117 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.chkItalic, Me.chkB Me.Font = New System.Drawing . Font ( "Microsoft Sans Serif" , 9 !, System.Drawin Me.Name = "FrmCheckBox" Me.Text = "CheckBoxTest" Me . ResumeLayout ( Fals ) End Sub # End Regiunea ca System.EventArgs ) _

Sub Private chkItalic_CheckedChanged _ ( ByVal expeditor Ca System.Object, ByVal e Manere chkItalic.CheckedChanged

lblOutput.Font = New Font ( "Microsoft Sans Serif" , _ lblOutput.Font.Size, lblOutput.Font.Style XOR FontStyle.Italic ) End Sub Sub Private chkBold_CheckedChanged _ ( ByVal expeditor Ca System.Object, ByVal e Manere chkBold.CheckedChanged ca System.EventArgs ) _

lblOutput.Font = New Font ( "Microsoft Sans Serif" , _ lblOutput.Font.Size, lblOutput.Font.Style XOR FontStyle.Bold ) End Sub

End Class

Original

Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D public class CheckBoxEvent public Shared Sub Main Application.Run(New FrmCheckBox) End Sub End class Public Class FrmCheckBox Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents chkItalic As System.Windows.Forms.CheckBox Friend WithEvents lblOutput As System.Windows.Forms.Label Friend WithEvents chkBold As System.Windows.Forms.CheckBox 'Required by the Windows Form Designer Private components As System.ComponentModel.Container

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.lblOutput = New System.Windows.Forms.Label() Me.chkItalic = New System.Windows.Forms.CheckBox() Me.chkBold = New System.Windows.Forms.CheckBox() Me.SuspendLayout() ' 'lblOutput ' Me.lblOutput.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System Me.lblOutput.Location = New System.Drawing.Point(48, 24) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size(208, 24) Me.lblOutput.TabIndex = 0 Me.lblOutput.Text = "Watch the font style change" ' 'chkItalic ' Me.chkItalic.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System. Me.chkItalic.Location = New System.Drawing.Point(152, 64) Me.chkItalic.Name = "chkItalic" Me.chkItalic.Size = New System.Drawing.Size(64, 24) Me.chkItalic.TabIndex = 2 Me.chkItalic.Text = "Italic" ' 'chkBold ' Me.chkBold.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Dr Me.chkBold.Location = New System.Drawing.Point(80, 64) Me.chkBold.Name = "chkBold" Me.chkBold.Size = New System.Drawing.Size(56, 24) Me.chkBold.TabIndex = 1 Me.chkBold.Text = "Bold" ' 'FrmCheckBox ' Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14) Me.ClientSize = New System.Drawing.Size(292, 117) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.chkItalic, Me.chkBold, Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontS Me.Name = "FrmCheckBox" Me.Text = "CheckBoxTest" Me.ResumeLayout(False) End Sub #End Region Private Sub chkItalic_CheckedChanged _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles chkItalic.CheckedChanged lblOutput.Font = New Font("Microsoft Sans Serif", _ lblOutput.Font.Size, lblOutput.Font.Style Xor FontStyle.Italic) End Sub Private Sub chkBold_CheckedChanged _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles chkBold.CheckedChanged

lblOutput.Font = New Font("Microsoft Sans Serif", _ lblOutput.Font.Size, lblOutput.Font.Style Xor FontStyle.Bold) End Sub End Class

Dialog Culoare 14.2.4.Use pentru a seta culoarea de prim-plan La

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class UseColorDialogToSetLabelForeGroundColor public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents ColorDialog1 Ca System.Windows.Forms.ColorDialog prieten WithEvents Label1 Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.ColorDialog1 = New System.Windows.Forms.ColorDialog Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = Nou System.Drawing.Point ( 88 , 152 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 96 , 32 ) Me.Button1.TabIndex = 1 Me.Button1.Text = " schimbare de culoare " " "La bel1 ' Me.Label1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 27.75 !, Sy Me.Label1.Location = New System.Drawing.Point ( 72 , 24 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 120 , 104 ) Me.Label1. tabindex = 2 Me.Label1.Text = "www.java2s.com" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 256 , 214 ) Me.Controls.Add ( Me.Label1 ) Me.Controls.Add ( Me.Button1 ) Me.Name = "Form1" Me.Text = "Color Setting" Me.ResumeLayout ( Fals ) End Sub Private Sub Button1_Click ( ByVal expeditor ColorDialog1.ShowDialog () Label1.ForeColor = ColorDialog1.Color End Sub End Class Ca System.Object, ByVal e ca

System

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class UseColorDialogToSetLabelForeGroundColor public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents ColorDialog1 As System.Windows.Forms.ColorDialog Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.ColorDialog1 = New System.Windows.Forms.ColorDialog Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(88, 152) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(96, 32)

Me.Button1.TabIndex = 1 Me.Button1.Text = "Change Color" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 27.75!, System. Me.Label1.Location = New System.Drawing.Point(72, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(120, 104) Me.Label1.TabIndex = 2 Me.Label1.Text = "www.java2s.com" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(256, 214) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Color Setting" Me.ResumeLayout(False) End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ColorDialog1.ShowDialog() Label1.ForeColor = ColorDialog1.Color End Sub End Class

14.2.5.Label click eveniment

Importurile

System.Windows.Forms

public class GenericEventHandler public comun Sub principal Application.Run ( New FrmSimple ) End Sub End clasa Public class FrmSimple Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New ()

"T apelul su este cerut de formularul de Designer Windows. InitializeComponent () "O dd orice iniializare dup "I nitializeComponent () apel End Sub 'N ew "F ORM prevaleaz dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Aruncai ( _ ByVal eliminare Ca Boolean ) Dac aruncai Apoi, Apoi

Dac nu ( componente este nimic ) components.Dispose () End If End If MyBase.Dispose ( eliminare ) End Sub 'D ispose Prietenul WithEvents lblOutput Ca

System.Windows.Forms.Label

"R equired de forma Designer pentru Windows private componente Ca System.ComponentModel.Container "N NOT: Urmtoarea procedur este prevzut de 't el pentru Windows Form Designer. " Eu nu pot fi modificate cu ajutorul Form Designer pentru Windows. " D o nu se modifica folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.lblOutput = New System.Windows.Forms.Label () Me.SuspendLayout () " "lb lOutput " Me . lblOutput.Location = New System.Drawing.Point ( 16 , 16 ) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size ( 152 , 80 ) Me.lblOutput.TabIndex = 0 Me lblOutput.Text =. "Click aici!" Me.lblOutput.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' "Parintele mSimple ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Sistem. Drawing.Size ( 176 , 101 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.lblOutput }) Me.Name = "FrmSimple" Me.Text = "SimpleEventExample" Me.ResumeLayout ( Fals ) End Sub # End Regiunea lblOutput_Click ( expeditor ByVal Ca obiect, _

Private Sub

ByVal e

ca

System.EventArgs )

Manere lblOutput.Click

MessageBox.Show ( "eticheta a fost fcut clic" ) End Sub End Class

Original

Imports System.Windows.Forms public class GenericEventHandler public Shared Sub Main Application.Run(New FrmSimple) End Sub End class Public Class FrmSimple Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the ' InitializeComponent() call End Sub ' New ' Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose( _ ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing)

End Sub ' Dispose Friend WithEvents lblOutput As System.Windows.Forms.Label ' Required by the Windows Form Designer Private components As System.ComponentModel.Container ' NOTE: The following procedure is required by ' the Windows Form Designer. ' It can be modified using the Windows Form Designer. ' Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lblOutput = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'lblOutput ' Me.lblOutput.Location = New System.Drawing.Point(16, 16) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size(152, 80) Me.lblOutput.TabIndex = 0 Me.lblOutput.Text = "Click Me!" Me.lblOutput.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'FrmSimple ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(176, 101) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblOutput}) Me.Name = "FrmSimple" Me.Text = "SimpleEventExample" Me.ResumeLayout(False) End Sub #End Region Private Sub lblOutput_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles lblOutput.Click MessageBox.Show("Label was clicked") End Sub End Class

Imagine 14.2.6.Add pentru a eticheta

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class LabelImage: motenete Formular publice sub Nou () Dimensiune = new Dimensiune ( 300 , 250 ) dim img ca imagine = Image.FromFile ( "yourfile.jpg" ) lblImage dim fi Label = new Label () lblImage.Parent = ma lblImage.Location = new Punct ( 0 , 0 ) lblImage.Image = img lblImage.Anchor = AnchorStyles . Sus sau AnchorStyles.Right lblImage.Size = new Dimensiuni ( img.Width, img.Height ) finali sub public comun sub Main () Application.Run ( nou LabelImage ()) end sub clasa final

Original

imports System imports System.Drawing imports System.Windows.Forms public class LabelImage: inherits Form public sub New() Size = new Size(300,250) dim img as Image = Image.FromFile("yourfile.jpg") dim lblImage as Label = new Label() lblImage.Parent = me lblImage.Location = new Point(0, 0) lblImage.Image = img lblImage.Anchor = AnchorStyles.Top or AnchorStyles.Right lblImage.Size = new Size(img.Width, img.Height) end sub public shared sub Main() Application.Run(new LabelImage()) end sub end class

ImageList Label 14.2.7.Set lui

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class ImageLists: motenete Form

imgList dim ca ImageList = new ImageList () LBL dim ca etichet lnk dim ca LinkLabel dim BTN ca Button nmbrUpDown dim ca NumericUpDown publice sub noi () Dimensiune = new dim img ca imagine dim i ca ntreg arFiles Dim ca ir () = { "1.ico" , "2.ico" , "3.ico" , "4.ico" } Dimensiune ( 300 , 300 )

pentru i = 0 la arFiles.Length - 1 img = Image.FromFile ( arFiles ( i )) imgList.Images.Add ( img ) urmtor imgList.ImageSize = new Dimensiune ( 32 , 1 ) 32 ) = img

img = Image.FromFile ( "5.ico" ) imgList.Images ( imgList.Images.Count -

LBL = new Label () lbl.Parent = ma lbl.Text = "Label" lbl.Location = new Punct ( 0 , 0 ) lbl.Size = new Dimensiune ( 200 , 20 ) lbl.BorderStyle = BorderStyle.Fixed3D lbl.ImageList = imgList lbl.ImageIndex = 0 lbl.ImageAlign = ContentAlignment.MiddleRight " Crearea updown numeric pentru a selecta imaginea

nmbrUpDown = new NumericUpDown () nmbrUpDown.Parent = ma nmbrUpDown.Location = new Punct ( 0 , 60 ) nmbrUpDown.Value = 0 nmbrUpDown.Minimum = 0 nmbrUpDown.Maximum = imgList.Images.Count - 1 nmbrUpDown.Width = 50 nmbrUpDown.ReadOnly = true AddHandler nmbrUpDown.ValueChanged, AddressOf nmbrUpDown_ValueChanged finali sub public comun sub Main () Application.Run ( nou ImageLists ()) finali sub

privat sub nmbrUpDown_ValueChanged ( expeditor ByVal ca obiect, e ByVal ca EventArg dim n ca NumericUpDown = Ctype ( expeditor, NumericUpDown ) lbl.ImageIndex = Ctype ( n.Value, Integer ) capt sub clasa de final

Original

imports System imports System.Drawing imports System.Windows.Forms public class ImageLists : inherits Form dim imgList as ImageList = new ImageList() dim lbl as Label dim lnk as LinkLabel dim btn as Button dim nmbrUpDown as NumericUpDown

public sub New() Size = new Size(300,300) dim img as Image dim i as integer dim arFiles as string() = {"1.ico","2.ico","3.ico","4.ico"} for i = 0 to arFiles.Length - 1 img = Image.FromFile(arFiles(i)) imgList.Images.Add(img) next imgList.ImageSize = new Size(32, 32) img = Image.FromFile("5.ico") imgList.Images(imgList.Images.Count - 1) = img lbl = new Label() lbl.Parent = me lbl.Text = "Label" lbl.Location = new Point(0,0) lbl.Size = new Size (200,20) lbl.BorderStyle = BorderStyle.Fixed3D lbl.ImageList = imgList lbl.ImageIndex = 0 lbl.ImageAlign = ContentAlignment.MiddleRight ' Create numeric updown to select the image nmbrUpDown = new NumericUpDown() nmbrUpDown.Parent = me nmbrUpDown.Location = new Point(0, 60) nmbrUpDown.Value = 0 nmbrUpDown.Minimum = 0 nmbrUpDown.Maximum = imgList.Images.Count - 1 nmbrUpDown.Width = 50 nmbrUpDown.ReadOnly = true AddHandler nmbrUpDown.ValueChanged,AddressOf nmbrUpDown_ValueChanged end sub public shared sub Main() Application.Run(new ImageLists()) end sub private sub nmbrUpDown_ValueChanged(ByVal sender as object,ByVal e as EventArgs) dim n as NumericUpDown = CType(sender, NumericUpDown) lbl.ImageIndex = CType(n.Value, Integer) end sub end class

Eticheta 14.2.8.Multiline

Importurile

System.Windows.Forms

public class MultilineLabel public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e ca lblInstructions.Text = "Afieaz acest mesaj i fie:" & vbCrLf & _ "- mail la destinatar" & vbCrLf & _ "- prin fax la destinatar" & vbCrLf & _ "- l arunca" End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.lblInstructions = New System.Windows.Forms.Label Me.SuspendLayout () " "lb lInstructions ' Me.lblInstructions.AutoSize = True Me.lblInstructions.Location = New System.Drawing.Point ( 8 , 8 ) Me.lblInstructions. name = "lblInstructions" Me.lblInstructions.Size = New System.Drawing.Size ( 67 , 13 ) Me.lblInstructions.TabIndex = 0 Me.lblInstructions.Text = "lblInstructions" " "Fo RM1 '

System.Ev

Ca

Bool

Me.AutoScaleDimensions = nou sistem. Drawing.SizeF ( 6.0 !, Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 286 , 116 ) Me.Controls.Add ( Me.lblInstructions ) Me. name = "Form1" Me.Text = "MultiLineLabel" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents lblInstructions End Class Ca

13.0 ! )

System.Windows.Forms.Label

Original

Imports System.Windows.Forms public class MultilineLabel public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H lblInstructions.Text = "Print this message and either:" & vbCrLf & _ " - Mail it to the recipient" & vbCrLf & _ " - Fax it to the recipient" & vbCrLf & _ " - Throw it away" End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lblInstructions = New System.Windows.Forms.Label Me.SuspendLayout() ' 'lblInstructions ' Me.lblInstructions.AutoSize = True Me.lblInstructions.Location = New System.Drawing.Point(8, 8) Me.lblInstructions.Name = "lblInstructions" Me.lblInstructions.Size = New System.Drawing.Size(67, 13) Me.lblInstructions.TabIndex = 0 Me.lblInstructions.Text = "lblInstructions" ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(286, 116) Me.Controls.Add(Me.lblInstructions) Me.Name = "Form1" Me.Text = "MultiLineLabel" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents lblInstructions As System.Windows.Forms.Label End Class

Button PerformClick

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ButtonPerformClick public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Button2 Ca System.Windows.Forms.Button prieten WithEvents Label1 Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.Button2 = Noul Sistem . Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 72 , 80 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 184 , 23 ) Me.Button1.TabIndex = 0 Me.Button1.Text = "Click Me a Facei clic pe alt buton" " "Bu tton2 " Me. Button2.Location = New System.Drawing.Point ( 72 , 160 ) Ca apel

Bool

Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size ( 184 , 23 ) Me.Button2.TabIndex = 1 Me. Button2.Text = "alt buton" " "La bel1 ' Me.Label1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , Me.Label1.Location = New System.Drawing.Point ( 0 , 0 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 328 , 40 ) Me.Label1.TabIndex = 2 Me.Label1.Text = "Clic" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

14.0 !, Sys

= "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub Button1_Click ( ByVal expeditor Button2.PerformClick () End Sub Private Sub Button2_Click ( ByVal expeditor Button2.Text = "Am fost fcut clic!" End Sub End Class

System

Ca

System.Object, ByVal e

ca

System

Originar

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ButtonPerformClick public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.

Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(72, 80) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(184, 23) Me.Button1.TabIndex = 0 Me.Button1.Text = "Click Me to Click the Other Button" ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(72, 160) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(184, 23) Me.Button2.TabIndex = 1 Me.Button2.Text = "The Other Button" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.D Me.Label1.Location = New System.Drawing.Point(0, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(328, 40) Me.Label1.TabIndex = 2 Me.Label1.Text = "Clicked" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(328, 273) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Button2.PerformClick() End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Button2.Text = "I've been clicked!" End Sub End Class

Button Proprieti

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class ButtonFlatStyle: motenete Forma BTN dim ca Button i dim ca ntregi theStyles Dim FlatStyle () dim img ca imagine = Image.FromFile ( "yourfile.jpg" ) publice sub noi () Text = "Proprieti butonul" Size = new Dimensiune ( 300 , 200 ) BTN = new Button () btn.Parent = ma btn.Text = btn.FlatStyle.ToString () btn.Location = new Punct ( 10 , 10 ) btn.Size = new Dimensiune ( 200 , 100 ) btn.BackColor = Color. LightGreen AddHandler btn.Click, AddressOf btn_Click btn.Image = img btn.ImageAlign = ContentAlignment.MiddleRight btn.TextAlign = ContentAlignment.MiddleLeft theEnum dim ca noi FlatStyle () theStyles = Ctype ([ Enum ] . GetValues ( theEnum.GetType ()) , FlatStyle ()) finali sub publice comune sub Main () Application.Run ( nou ButtonFlatStyle ()) end sub privat sub btn_Click ( expeditor ByVal ca obiect, e ByVal ca EventArgs ) Dim BTN ca Button = Ctype ( expeditor, Button ) btn.FlatStyle = theStyles ( i ) btn.Text = btn.FlatStyle.ToString () n cazul n care i = i + 1 altfel i = 0 final, dac ( i <theStyles.Length 1 ) , atunci

sfritul sub clasa de final

Original

imports System imports System.Drawing imports System.Windows.Forms public class ButtonFlatStyle : inherits Form dim btn as Button dim i as integer dim theStyles as FlatStyle() dim img as Image = Image.FromFile("yourfile.jpg") public sub New() Text = "Button Properties" Size = new Size(300,200) btn = new Button() btn.Parent = me btn.Text = btn.FlatStyle.ToString() btn.Location = new Point(10,10) btn.Size = new Size(200,100) btn.BackColor = Color.LightGreen AddHandler btn.Click, AddressOf btn_Click btn.Image = img btn.ImageAlign = ContentAlignment.MiddleRight btn.TextAlign = ContentAlignment.MiddleLeft dim theEnum as new FlatStyle() theStyles = CType([Enum].GetValues(theEnum.GetType()), FlatStyle()) end sub public shared sub Main() Application.Run(new ButtonFlatStyle()) end sub private sub btn_Click(ByVal sender as object, ByVal e as EventArgs) Dim btn as Button = CType(sender, Button) btn.FlatStyle = theStyles(i) btn.Text = btn.FlatStyle.ToString()

if (i < theStyles.Length - 1) then i = i + 1 else i = 0 end if end sub end class

Button FlatStyle

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class ButtonFlatStyle: motenete Forma BTN dim ca Button i dim ca ntregi theStyles Dim FlatStyle () dim img ca imagine = Image.FromFile ( "yourfile.jpg" ) publice sub noi () Text = "Proprieti butonul" Size = new Dimensiune ( 300 , 200 ) BTN = new Button () btn.Parent = ma btn.Text = btn.FlatStyle.ToString () btn.Location = new Punct ( 10 , 10 ) btn.Size = new Dimensiune ( 200 , 100 ) btn.BackColor = Color. LightGreen AddHandler btn.Click, AddressOf btn_Click btn.Image = img btn.ImageAlign = ContentAlignment.MiddleRight btn.TextAlign = ContentAlignment.MiddleLeft theEnum dim ca noi FlatStyle () theStyles = Ctype ([ Enum ] . GetValues ( theEnum.GetType ()) , FlatStyle ()) finali sub publice comune sub Main () Application.Run ( nou ButtonFlatStyle ()) end sub

privat sub btn_Click ( expeditor ByVal ca obiect, e ByVal ca EventArgs ) Dim BTN ca Button = Ctype ( expeditor, Button ) btn.FlatStyle = theStyles ( i ) btn.Text = btn.FlatStyle.ToString () n cazul n care i = i + 1 altfel i = 0 final, dac sfritul sub clasa de final ( i <theStyles.Length 1 ) , atunci

Original

imports System imports System.Drawing imports System.Windows.Forms public class ButtonFlatStyle : inherits Form dim btn as Button dim i as integer dim theStyles as FlatStyle() dim img as Image = Image.FromFile("yourfile.jpg") public sub New() Text = "Button Properties" Size = new Size(300,200) btn = new Button() btn.Parent = me btn.Text = btn.FlatStyle.ToString() btn.Location = new Point(10,10) btn.Size = new Size(200,100) btn.BackColor = Color.LightGreen AddHandler btn.Click, AddressOf btn_Click btn.Image = img btn.ImageAlign = ContentAlignment.MiddleRight btn.TextAlign = ContentAlignment.MiddleLeft dim theEnum as new FlatStyle()

theStyles = CType([Enum].GetValues(theEnum.GetType()), FlatStyle()) end sub public shared sub Main() Application.Run(new ButtonFlatStyle()) end sub private sub btn_Click(ByVal sender as object, ByVal e as EventArgs) Dim btn as Button = CType(sender, Button) btn.FlatStyle = theStyles(i) btn.Text = btn.FlatStyle.ToString() if (i < theStyles.Length - 1) then i = i + 1 else i = 0 end if end sub end class

Button click eveniment

Importurile

System.Windows.Forms

public class GetTextPasswordField public comun Sub principal Application.Run ( New FrmButtonTest ) End Sub End clasa

Public class FrmButtonTest Inherits System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () apel

End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub prieten WithEvents lblOutput Ca System.Windows.Forms.Label prieten WithEvents txtInput Ca System.Windows.Forms.TextBox prieten WithEvents cmdShow Ca System.Windows.Forms.Button "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container Ca

Boole

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . cmdShow = New System.Windows.Forms.Button () Me.txtInput = New System.Windows.Forms.TextBox () Me.lblOutput = New System.Windows.Forms.Label () Me.SuspendLayout () " "cm dShow " Me.cmdShow.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 11.25 !, Sys Me.cmdShow. Locaie = New System.Drawing.Point ( 88 , 88 ) Me.cmdShow.Name = "cmdShow" Me.cmdShow.Size = New System.Drawing.Size ( 96 , 40 ) Me.cmdShow.TabIndex = 2 Me.cmdShow. Text = "Show Me", " "TX tInput ' Me.txtInput.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, Sys Me.txtInput.Location = New System.Drawing.Point ( 16 , 16 ) Me.txtInput.Name = "txtInput" Me.txtInput.PasswordChar = Microsoft.VisualBasic.ChrW ( 42 ) Me.txtInput. size = New System.Drawing.Size ( 232 , 22 ) Me.txtInput.TabIndex = 0 Me.txtInput.Text = "" ' 'lb lOutput ' Me.lblOutput.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D mine. lblOutput.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, Me.lblOutput.Location = Nou System.Drawing.Point ( 16 , 56 ) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size ( 232 , 23 ) Me.lblOutput.TabIndex = 1 ' "Parintele mButtonTest " Me. AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 264 , 141 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.cmdShow, Me . lblO Me.Name = "FrmButtonTest"

Me.Text = "LabelTextBoxButtonExample" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

Private Sub cmdShow_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere cmdShow.Click lblOutput.Text = txtInput.Text End Sub End Class

Original

Imports System.Windows.Forms public class GetTextPasswordField public Shared Sub Main Application.Run(New FrmButtonTest) End Sub End class

Public Class FrmButtonTest Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents lblOutput As System.Windows.Forms.Label Friend WithEvents txtInput As System.Windows.Forms.TextBox Friend WithEvents cmdShow As System.Windows.Forms.Button 'Required by the Windows Form Designer Private components As System.ComponentModel.Container

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.cmdShow = New System.Windows.Forms.Button() Me.txtInput = New System.Windows.Forms.TextBox() Me.lblOutput = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'cmdShow ' Me.cmdShow.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.D Me.cmdShow.Location = New System.Drawing.Point(88, 88) Me.cmdShow.Name = "cmdShow" Me.cmdShow.Size = New System.Drawing.Size(96, 40) Me.cmdShow.TabIndex = 2 Me.cmdShow.Text = "Show Me" ' 'txtInput ' Me.txtInput.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.D Me.txtInput.Location = New System.Drawing.Point(16, 16) Me.txtInput.Name = "txtInput" Me.txtInput.PasswordChar = Microsoft.VisualBasic.ChrW(42) Me.txtInput.Size = New System.Drawing.Size(232, 22) Me.txtInput.TabIndex = 0 Me.txtInput.Text = "" ' 'lblOutput ' Me.lblOutput.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblOutput.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System. Me.lblOutput.Location = New System.Drawing.Point(16, 56) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size(232, 23) Me.lblOutput.TabIndex = 1 ' 'FrmButtonTest ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(264, 141) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdShow, Me.lblOutput, Me.Name = "FrmButtonTest" Me.Text = "LabelTextBoxButtonExample" Me.ResumeLayout(False) End Sub

#End Region Private Sub cmdShow_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles cmdShow.Click lblOutput.Text = txtInput.Text End Sub End Class

Add Buton pentru un formular i ataai tratare a evenimentului

Importurile

System.Windows.Forms

public class AddButtonAndAddEventHandler public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Public Class Form1 Private Sub ShowTheTime ( expeditor ByVal Ca System.Object, ByVal e Console.WriteLine ( Now.ToLongTimeString ()) End Sub

ca

System.E

Private Sub Form1_Load ( expeditor ByVal Ca obiect, ByVal e ca System.EventArgs Dim dynamicButton Ca Button dynamicButton = New Windows.Forms.Button dynamicButton.Location = New System.Drawing.Point ( 144 , 32 ) dynamicButton.Size = New System.Drawing.Size ( 99 , 23 ) dynamicButton.Text = "Ia Time" dynamicButton.UseVisualStyleBackColor = True dynamicButton.TabIndex = 1 Me.Controls.Add ( dynamicButton ) "- ---- Conectai butonul pentru o tratare a evenimentului. AddHandler dynamicButton.Click, AddressOf ShowTheTime End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente.

<System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Boolean )

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.SuspendLayout () " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 260 , 76 ) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = false Me.Name = "Form1" Me.Text = "Dynamic Control" Me.ResumeLayout ( Fals ) End Sub End Class

Original

Imports System.Windows.Forms public class AddButtonAndAddEventHandler public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub ShowTheTime(ByVal sender As System.Object, ByVal e As System.EventArgs)

Console.WriteLine( Now.ToLongTimeString()) End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dim dynamicButton As Button dynamicButton = New Windows.Forms.Button dynamicButton.Location = New System.Drawing.Point(144, 32) dynamicButton.Size = New System.Drawing.Size(99, 23) dynamicButton.Text = "Get Time" dynamicButton.UseVisualStyleBackColor = True dynamicButton.TabIndex = 1 Me.Controls.Add(dynamicButton) ' ----- Connect the button to an event handler. AddHandler dynamicButton.Click, AddressOf ShowTheTime End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SuspendLayout() ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(260, 76) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "Dynamic Controls" Me.ResumeLayout(False) End Sub End Class

Owner butonul remiz


Importurile System.Drawing Importurile System.Drawing.Drawing2D public class OwnerDrawnButton Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents button4 Ca System.Windows.Forms.Button <System.Diagnostics . DebuggerStepThrough () > Private Sub InitializeComponent () Me.button4 = New System.Windows.Forms.Button () Me.SuspendLayout () " "bu tton4 ' Me.button4.Location = New System.Drawing.Point ( 40 , 35 ) Me.button4.Name = "button4" Me.button4.Size = New System.Drawing.Size ( 200 , 40 ) Me.button4.TabIndex = 2 Me.button4.Text = "button4" " "Au nerDrawnButton " Me. AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 280 , 110 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.button4 }) Me.Name = "OwnerDrawnButton" Me.Text = "OwnerDrawnButton" Me.ResumeLayout ( Fals ) End Sub Ca apel

Bool

# End

Regiunea

Private Sub button4_Paint ( expeditor ByVal Ca obiect, ByVal e ca System.Window Dim stilou Ca Pen = New Pen ( Color.Red, 2 ) e.Graphics.DrawRectangle ( stilou, 5 , 5 , button4.Width - 10 , button4.Heigh End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Public Class OwnerDrawnButton Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents button4 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.button4 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'button4 ' Me.button4.Location = New System.Drawing.Point(40, 35) Me.button4.Name = "button4" Me.button4.Size = New System.Drawing.Size(200, 40) Me.button4.TabIndex = 2

Me.button4.Text = "button4" ' 'OwnerDrawnButton ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(280, 110) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button4}) Me.Name = "OwnerDrawnButton" Me.Text = "OwnerDrawnButton" Me.ResumeLayout(False) End Sub #End Region

Private Sub button4_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.Pa Dim pen As Pen = New Pen(Color.Red, 2) e.Graphics.DrawRectangle(pen, 5, 5, button4.Width - 10, button4.Height - 10) End Sub End Class

Button eveniment click i text eveniment a schimbat

Importurile

System.Windows.Forms

public class ButtonClickTextChanged public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () Ca apel

Bool

End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button <System.Diagnostics . DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button () Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 96 , 72 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 280 , 181 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Button1 }) Me.Name = "Form1" Me.Text = "EventDemo" Me.ResumeLayout ( Fals ) End Sub # End Regiunea obiect, ByVal e ca

Private Sub Button1_Click ( expeditor ByVal Ca MsgBox ( "Evenimentul a avut loc clic" ) Dac ( Button1.Text = "Button1" ) Apoi Button1.Text = "Clic" Else Button1.Text = "Button1" Dac End End Sub

System.EventA

Sub Private Button1_TextChanged ( expeditor ByVal Ca MsgBox ( "Evenimentul a avut loc Textchanged" ) End Sub End Class

obiect, e ByVal

Ca

System.

Original

Imports System.Windows.Forms public class ButtonClickTextChanged public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(96, 72) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(280, 181)

Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1}) Me.Name = "Form1" Me.Text = "EventDemo" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handl MsgBox("Click event occurred") If (Button1.Text = "Button1") Then Button1.Text = "Clicked" Else Button1.Text = "Button1" End If End Sub

Private Sub Button1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox("Textchanged event occurred") End Sub End Class

Button ImageList

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class ButtonImageList: motenete Form new ImageList ()

imgList dim ca ImageList = LBL dim ca etichet lnk dim ca LinkLabel dim BTN ca Button

nmbrUpDown dim ca NumericUpDown publice sub noi () Dimensiune = new dim img ca imagine dim i ca ntreg arFiles Dim ca ir () = { "1.ico" , "2.ico" , "3.ico" , "4.ico" } Dimensiune ( 300 , 300 )

pentru i = 0 la arFiles.Length - 1 img = Image.FromFile ( arFiles ( i )) imgList.Images.Add ( img ) urmtor BTN = new Button () btn.Parent = ma btn.ImageList = imgList btn.ImageIndex = imgList.Images.Count - 1 btn.Location = new Punct ( 0 , 0 ) btn.Size = new Dimensiune ( 200 , 20 ) " Crearea updown numeric pentru a selecta imaginea nmbrUpDown = new NumericUpDown () nmbrUpDown.Parent = ma nmbrUpDown.Location = new Punct ( 0 , 60 ) nmbrUpDown.Value = 0 nmbrUpDown.Minimum = 0 nmbrUpDown.Maximum = imgList.Images.Count - 1 nmbrUpDown.Width = 50 nmbrUpDown.ReadOnly = true AddHandler nmbrUpDown.ValueChanged, AddressOf nmbrUpDown_ValueChanged finali sub public comun sub Main () Application.Run ( nou ButtonImageList ()) end sub

privat sub nmbrUpDown_ValueChanged ( expeditor ByVal ca obiect, e ByVal ca EventArg dim n ca NumericUpDown = Ctype ( expeditor, NumericUpDown ) btn.ImageIndex = Ctype ( n.Value, Integer ) capt sub clasa de final

Original

imports System imports System.Drawing imports System.Windows.Forms public class ButtonImageList : inherits Form dim imgList as ImageList = new ImageList() dim lbl as Label dim lnk as LinkLabel dim btn as Button dim nmbrUpDown as NumericUpDown public sub New() Size = new Size(300,300) dim img as Image dim i as integer dim arFiles as string() = {"1.ico","2.ico","3.ico","4.ico"} for i = 0 to arFiles.Length - 1 img = Image.FromFile(arFiles(i)) imgList.Images.Add(img) next btn = new Button() btn.Parent = me btn.ImageList = imgList btn.ImageIndex = imgList.Images.Count - 1 btn.Location = new Point(0, 0) btn.Size = new Size(200,20) ' Create numeric updown to select the image nmbrUpDown = new NumericUpDown() nmbrUpDown.Parent = me nmbrUpDown.Location = new Point(0, 60) nmbrUpDown.Value = 0 nmbrUpDown.Minimum = 0 nmbrUpDown.Maximum = imgList.Images.Count - 1 nmbrUpDown.Width = 50 nmbrUpDown.ReadOnly = true

AddHandler nmbrUpDown.ValueChanged,AddressOf nmbrUpDown_ValueChanged end sub public shared sub Main() Application.Run(new ButtonImageList()) end sub private sub nmbrUpDown_ValueChanged(ByVal sender as object,ByVal e as EventArgs) dim n as NumericUpDown = CType(sender, NumericUpDown) btn.ImageIndex = CType(n.Value, Integer) end sub end class

Button cu imagine de fundal

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ButtonBackgroundImage public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub apel

"Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Label1 Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.TextBox1 = Noul Sistem . Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout () " "Bu tton1 ' Me.Button1.BackgroundImage = System.Drawing.Image.FromFile ( "yourfile.jpg" ) Me. Button1.Location = New System.Drawing.Point ( 8 , 64 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 368 , 20 ) Me.Button1.TabIndex = 0 ' ' Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 104 , 184 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 168 , 20 ) Me.TextBox1. tabindex = 1 Me.TextBox1.Text = "" " "La bel1 ' Me.Label1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 24.0 !, Sys Me.Label1.Location = New System.Drawing.Point ( 0 , 0 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 232 , 48 ) Me.Label1.TabIndex = 2 Me.Label1.Text = "Butoane imagini" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals )

End Sub # End Regiunea ca

Private Sub Button1_Click ( ByVal expeditor Ca System.Object, ByVal e TextBox1.Text = "Ai fcut clic pe butonul." End Sub End Class

System

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ButtonBackgroundImage public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'Button1 ' Me.Button1.BackgroundImage = System.Drawing.Image.FromFile("yourfile.jpg") Me.Button1.Location = New System.Drawing.Point(8, 64) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(368, 20) Me.Button1.TabIndex = 0 ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(104, 184) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(168, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.D Me.Label1.Location = New System.Drawing.Point(0, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(232, 48) Me.Label1.TabIndex = 2 Me.Label1.Text = "Image Buttons" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(384, 229) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs TextBox1.Text = "You clicked the button." End Sub End Class

Button Anchor

Importurile

System.Windows.Forms

public class ButtonAnchor public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e Button1.Location = New System.Drawing.Point ( _ Me.ClientRectangle.Width - Button1.Width, _ Me. ClientRectangle.Height - Button1.Height ) Button1.Anchor = AnchorStyles.Bottom Sau AnchorStyles.Right End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form

ca

System.Ev

"Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button

Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 24 , 24 ) Me.Button1.Name = "Button1" Me. Button1.Size = New System.Drawing.Size ( 75 , 23 ) Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 185 , 84 ) Me.Controls.Add ( Me.Button1 ) Me.Name = "Form1" Me. Text = "Form1" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents Button1 End Class Ca System.Windows.Forms.Button

Original

Imports System.Windows.Forms public class ButtonAnchor public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H Button1.Location = New System.Drawing.Point( _ Me.ClientRectangle.Width - Button1.Width, _ Me.ClientRectangle.Height - Button1.Height) Button1.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(24, 24) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 23) Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(185, 84) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub Friend WithEvents Button1 As System.Windows.Forms.Button End Class

Forma 14.3.11.Irregular de Button

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class IrregularShapeButton public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa

Publice clasa Form1 Motenete System.Windows.Forms.Form privare de originalSize Ca Dimensiune # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents AnimationBtn Ca System.Windows.Forms.Button prieten WithEvents VideoBtn Ca System.Windows.Forms.Button prieten WithEvents AudioBtn Ca System.Windows.Forms.Button prieten WithEvents ContextMenu1 Ca System.Windows.Forms.ContextMenu prieten WithEvents Circlemenu Ca System.Windows.Forms.MenuItem prieten WithEvents RectMenu Ca System.Windows.Forms. MenuItem prieten WithEvents TriangleMenu Ca System.Windows.Forms.MenuItem prieten WithEvents CloseMenu Ca System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.AnimationBtn = New System.Windows.Forms.Button Me . VideoBtn = New System.Windows.Forms.Button Me.AudioBtn = New System.Windows.Forms.Button Me.ContextMenu1 = New System.Windows.Forms.ContextMenu Me.Circlemenu = New System.Windows.Forms.MenuItem Me.RectMenu = New System.Windows.Forms.MenuItem Me.TriangleMenu = New System.Windows.Forms.MenuItem Me.CloseMenu = New System.Windows.Forms.MenuItem Me.SuspendLayout () " "O imationBtn ' Me.AnimationBtn.BackColor = Sistem . Drawing.Color.Blue Me.AnimationBtn.Font = New System.Drawing.Font ( "Tahoma" , 10.0 !, System.Draw Me.AnimationBtn.ForeColor = System.Drawing.SystemColors.ControlLightLight Me.AnimationBtn . Locaia = New System.Drawing.Point ( 120 , 146 ) Me.AnimationBtn.Name = "AnimationBtn" Me.AnimationBtn.Size = New System.Drawing.Size ( 152 , 104 ) Me.AnimationBtn.TabIndex = 6 Me.AnimationBtn . Text = "Animation" " "Vi deoBtn ' Me.VideoBtn.BackColor = System.Drawing.Color.Green Me.VideoBtn.Font = New System.Drawing.Font ( "Tahoma" , 10.0 !, System.Drawing. Me.VideoBtn.ForeColor = System.Drawing.SystemColors.ControlLightLight Me.VideoBtn.Location = New System.Drawing.Point ( 208 , 26 ) Me.VideoBtn.Name = "VideoBtn" Me.VideoBtn.Size = Sistem. Drawing.Size ( 160 , 96 ) Me.VideoBtn.TabIndex = 5 Me.VideoBtn.Text = "Video Joaca" " "Au dioBtn ' Me.AudioBtn.BackColor = System.Drawing.Color.FromArgb ( Ctype ( 255 , Byte ) , C Me.AudioBtn.Font = New System.Drawing.Font ( "Tahoma" , 10.0 !, System.Drawing. Me.AudioBtn.ForeColor = sistem Drawing.SystemColors.ControlLightLight. Me.AudioBtn.Location = New System.Drawing.Point ( 96 , 26 ) Me.AudioBtn.Name = "AudioBtn" Me.AudioBtn.Size = New System.Drawing.Size ( 160 , 96 ) Me AudioBtn.TabIndex =. 4 Me.AudioBtn.Text = "Play Audio" " "Co ntextMenu1 " Me.ContextMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.C " "Ci rclemenu

' Me.Circlemenu.Index = 0 Me.Circlemenu.Text = "Cercul" " "Re ctMenu ' Me.RectMenu.Index = 1 Me.RectMenu.Text = "Original" " "Tr iangleMenu ' Me.TriangleMenu.Index = 2 Me.TriangleMenu.Text = "TriangleMenu" " "Cl oseMenu ' Me.CloseMenu.Index = 3 Me.CloseMenu.Text = "Close" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , Me.ClientSize = Nou

13 )

End Sub # End Regiunea ca

Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e originalSize = Me.Size Dim path1 Ca New graphicspath ( FillMode.Alternate ) path1.AddEllipse ( dreptunghi nou ( 30 , 30 , AudioBtn. latime AudioBtn.Region = Nou [ Region ] ( path1 ) Dim path2 Ca New graphicspath ( FillMode.Alternate ) path2.AddEllipse ( dreptunghi nou ( 30 , 30 , VideoBtn.Width VideoBtn.Region = nou [ Region ] ( path2 ) Dim path3 Ca New graphicspath ( FillMode.Alternate ) path3.AddEllipse ( dreptunghi nou ( 20 , 20 , VideoBtn.Width AnimationBtn.Region = noi [ Region ] ( path3 ) End Sub

System.Ev

60 , AudioBtn

60 , VideoBtn.H

40 , VideoBtn.H

Private Sub AudioBtn_Click ( ByVal expeditor Ca System.Object, ByVal e MessageBox.Show ( "butonul de redare audio clic!" ) End Sub Private Sub VideoBtn_Click ( ByVal expeditor Ca System.Object, ByVal e MessageBox.Show ( "Butonul Play Video clic!" ) End Sub

ca

Syste

ca

Syste

Private Sub AnimationBtn_Click ( ByVal expeditor Ca System.Object, ByVal e MessageBox.Show ( "Butonul Animaie Joaca clic!" ) End Sub End Class

ca

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class IrregularShapeButton public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Inherits System.Windows.Forms.Form Private originalSize As Size #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose()

End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents AnimationBtn As System.Windows.Forms.Button Friend WithEvents VideoBtn As System.Windows.Forms.Button Friend WithEvents AudioBtn As System.Windows.Forms.Button Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu Friend WithEvents Circlemenu As System.Windows.Forms.MenuItem Friend WithEvents RectMenu As System.Windows.Forms.MenuItem Friend WithEvents TriangleMenu As System.Windows.Forms.MenuItem Friend WithEvents CloseMenu As System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.AnimationBtn = New System.Windows.Forms.Button Me.VideoBtn = New System.Windows.Forms.Button Me.AudioBtn = New System.Windows.Forms.Button Me.ContextMenu1 = New System.Windows.Forms.ContextMenu Me.Circlemenu = New System.Windows.Forms.MenuItem Me.RectMenu = New System.Windows.Forms.MenuItem Me.TriangleMenu = New System.Windows.Forms.MenuItem Me.CloseMenu = New System.Windows.Forms.MenuItem Me.SuspendLayout() ' 'AnimationBtn ' Me.AnimationBtn.BackColor = System.Drawing.Color.Blue Me.AnimationBtn.Font = New System.Drawing.Font("Tahoma", 10.0!, System.Drawing.F Me.AnimationBtn.ForeColor = System.Drawing.SystemColors.ControlLightLight Me.AnimationBtn.Location = New System.Drawing.Point(120, 146) Me.AnimationBtn.Name = "AnimationBtn" Me.AnimationBtn.Size = New System.Drawing.Size(152, 104) Me.AnimationBtn.TabIndex = 6 Me.AnimationBtn.Text = "Animation" ' 'VideoBtn ' Me.VideoBtn.BackColor = System.Drawing.Color.Green Me.VideoBtn.Font = New System.Drawing.Font("Tahoma", 10.0!, System.Drawing.FontS Me.VideoBtn.ForeColor = System.Drawing.SystemColors.ControlLightLight Me.VideoBtn.Location = New System.Drawing.Point(208, 26) Me.VideoBtn.Name = "VideoBtn" Me.VideoBtn.Size = New System.Drawing.Size(160, 96) Me.VideoBtn.TabIndex = 5 Me.VideoBtn.Text = "Play Video" ' 'AudioBtn ' Me.AudioBtn.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(12 Me.AudioBtn.Font = New System.Drawing.Font("Tahoma", 10.0!, System.Drawing.FontS Me.AudioBtn.ForeColor = System.Drawing.SystemColors.ControlLightLight Me.AudioBtn.Location = New System.Drawing.Point(96, 26) Me.AudioBtn.Name = "AudioBtn" Me.AudioBtn.Size = New System.Drawing.Size(160, 96) Me.AudioBtn.TabIndex = 4

Me.AudioBtn.Text = "Play Audio" ' 'ContextMenu1 ' Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.Circl ' 'Circlemenu ' Me.Circlemenu.Index = 0 Me.Circlemenu.Text = "Circle" ' 'RectMenu ' Me.RectMenu.Index = 1 Me.RectMenu.Text = "Original" ' 'TriangleMenu ' Me.TriangleMenu.Index = 2 Me.TriangleMenu.Text = "TriangleMenu" ' 'CloseMenu ' Me.CloseMenu.Index = 3 Me.CloseMenu.Text = "Close" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(464, 277) Me.Controls.Add(Me.AnimationBtn) Me.Controls.Add(Me.VideoBtn) Me.Controls.Add(Me.AudioBtn) Me.ResumeLayout(False) End Sub #End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H originalSize = Me.Size Dim path1 As New GraphicsPath(FillMode.Alternate) path1.AddEllipse(New Rectangle(30, 30, AudioBtn.Width - 60, AudioBtn.Height - 60 AudioBtn.Region = New [Region](path1)

Dim path2 As New GraphicsPath(FillMode.Alternate) path2.AddEllipse(New Rectangle(30, 30, VideoBtn.Width - 60, VideoBtn.Height - 60 VideoBtn.Region = New [Region](path2)

Dim path3 As New GraphicsPath(FillMode.Alternate) path3.AddEllipse(New Rectangle(20, 20, VideoBtn.Width - 40, VideoBtn.Height - 40 AnimationBtn.Region = New [Region](path3) End Sub

Private Sub AudioBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArg MessageBox.Show("Play Audio Button clicked!") End Sub

Private Sub VideoBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArg MessageBox.Show("Play Video Button clicked!") End Sub

Private Sub AnimationBtn_Click(ByVal sender As System.Object, ByVal e As System.Even MessageBox.Show("Play Animation Button clicked!") End Sub End Class

CheckBox Verificai statele

Importurile

System.Windows.Forms

public class CheckBoxSelectedState public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi Ca apel

Bool

components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub prieten WithEvents checkBoxA Ca System.Windows.Forms.CheckBox prieten WithEvents checkBoxB Ca System.Windows.Forms.CheckBox prieten WithEvents btnStatus Ca System.Windows.Forms.Button prieten WithEvents btnEnable Ca System.Windows.Forms.Button "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . checkBoxA = System.Windows.Forms.CheckBox Nou () Me.checkBoxB = System.Windows.Forms.CheckBox Nou () Me.btnStatus = New System.Windows.Forms.Button () Me.btnEnable = New System.Windows. Forms.Button () Me.SuspendLayout () " "ch eckBoxA ' Me.checkBoxA.Checked = True Me.checkBoxA.CheckState = System.Windows.Forms.CheckState.Checked Me.checkBoxA.Location = New System.Drawing.Point ( 48 , 72 ) Me.checkBoxA.Name = "checkBoxA" Me.checkBoxA.Size = New System.Drawing.Size ( 200 , 24 ) Me.checkBoxA.TabIndex = 0 Me.checkBoxA.Text = "checkbox A" " "CH eckBoxB ' Me.checkBoxB.AutoCheck = Fals Me.checkBoxB.Checked = True Me.checkBoxB.CheckState = System.Windows.Forms.CheckState.Indeterminate Me.checkBoxB.Location = New System.Drawing.Point ( 48 , 120 ) Eu. checkBoxB.Name = "checkBoxB" Me.checkBoxB.Size = New System.Drawing.Size ( 200 , 24 ) Me.checkBoxB.TabIndex = 1 Me.checkBoxB.Text = "checkbox B" Me.checkBoxB.ThreeState = True ' " bt nStatus ' Me.btnStatus.Anchor = ( System.Windows.Forms.AnchorStyles.Bottom Sau System.Win Me.btnStatus.Location = New System.Drawing.Point ( 56 , 192 ) Me.btnStatus . Nume = "btnStatus" Me.btnStatus.Size = New System.Drawing.Size ( 136 , 23 ) Me.btnStatus.TabIndex = 2 Me.btnStatus.Text = "Vizualizare stare csua" " "bt nEnable " Me.btnEnable. Anchor = ( System.Windows.Forms.AnchorStyles.Bottom Sau System.Wi Me.btnEnable.Location = New System.Drawing.Point ( 224 , 192 ) Me.btnEnable.Name = "btnEnable" Me . btnEnable.Size = New System.Drawing.Size ( 96 , 23 ) Me.btnEnable.TabIndex = 3

Me.btnEnable.Text = "Activeaz" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 368 , 266 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.btnEnable, Me.bt Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

Private Sub btnStatus_Click ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere btnStatus.Click Dim statutul Ca String Dac checkBoxA.Checked = True Apoi stare = "checkBoxA este verificat." & ControlChars.Cr Altfel stare = "checkBoxA este necontrolate ". & ControlChars.Cr End Dac Dac checkBoxB.ThreeState = True Apoi, starea = statutul & "CheckState checkBoxB este" & checkBoxB.CheckState.ToS Altfel Dac checkBoxB.Checked = True Apoi, starea = statutul & " checkBoxB este verificat. " Altfel stare = statutul & "checkBoxB este bifat". End Dac End Dac MessageBox.Show ( starea ) End Sub Private Sub btnEnable_Click ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere btnEnable.Click checkBoxB.AutoCheck = True checkBoxB.CheckState = CheckState.Checked checkBoxB.ThreeState = False End Sub End Class

Original

Imports System.Windows.Forms public class CheckBoxSelectedState public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents checkBoxA As System.Windows.Forms.CheckBox Friend WithEvents checkBoxB As System.Windows.Forms.CheckBox Friend WithEvents btnStatus As System.Windows.Forms.Button Friend WithEvents btnEnable As System.Windows.Forms.Button 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.checkBoxA = New System.Windows.Forms.CheckBox() Me.checkBoxB = New System.Windows.Forms.CheckBox() Me.btnStatus = New System.Windows.Forms.Button() Me.btnEnable = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'checkBoxA ' Me.checkBoxA.Checked = True Me.checkBoxA.CheckState = System.Windows.Forms.CheckState.Checked Me.checkBoxA.Location = New System.Drawing.Point(48, 72) Me.checkBoxA.Name = "checkBoxA" Me.checkBoxA.Size = New System.Drawing.Size(200, 24) Me.checkBoxA.TabIndex = 0 Me.checkBoxA.Text = "CheckBox A" ' 'checkBoxB ' Me.checkBoxB.AutoCheck = False Me.checkBoxB.Checked = True Me.checkBoxB.CheckState = System.Windows.Forms.CheckState.Indeterminate Me.checkBoxB.Location = New System.Drawing.Point(48, 120) Me.checkBoxB.Name = "checkBoxB" Me.checkBoxB.Size = New System.Drawing.Size(200, 24) Me.checkBoxB.TabIndex = 1 Me.checkBoxB.Text = "CheckBox B" Me.checkBoxB.ThreeState = True ' 'btnStatus ' Me.btnStatus.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Window Me.btnStatus.Location = New System.Drawing.Point(56, 192) Me.btnStatus.Name = "btnStatus" Me.btnStatus.Size = New System.Drawing.Size(136, 23) Me.btnStatus.TabIndex = 2 Me.btnStatus.Text = "View Checkbox Status" ' 'btnEnable ' Me.btnEnable.Anchor = (System.Windows.Forms.AnchorStyles.Bottom Or System.Window Me.btnEnable.Location = New System.Drawing.Point(224, 192) Me.btnEnable.Name = "btnEnable" Me.btnEnable.Size = New System.Drawing.Size(96, 23) Me.btnEnable.TabIndex = 3 Me.btnEnable.Text = "Enable" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(368, 266) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnEnable, Me.btnSta Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub

#End Region

Private Sub btnStatus_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles btnStatus.Click Dim status As String If checkBoxA.Checked = True Then status = "checkBoxA is checked. " & ControlChars.Cr Else status = "checkBoxA is unchecked. " & ControlChars.Cr End If If checkBoxB.ThreeState = True Then status = status & "checkBoxB's CheckState is " & checkBoxB.CheckState.ToStri Else If checkBoxB.Checked = True Then status = status & "checkBoxB is checked." Else status = status & "checkBoxB is unchecked." End If End If MessageBox.Show(status) End Sub Private Sub btnEnable_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles btnEnable.Click checkBoxB.AutoCheck = True checkBoxB.CheckState = CheckState.Checked checkBoxB.ThreeState = False End Sub End Class

Using csuele pentru a comuta stiluri italic i bold

Importurile Importurile Importurile

System.Windows.Forms System.Drawing System.Drawing.Drawing2D

public class CheckBoxEvent public comun Sub principal Application.Run ( New FrmCheckBox ) End Sub End clasa Public class FrmCheckBox Motenete System.Windows.Forms.Form

# Region

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub WithEvents prieten chkItalic Ca System.Windows.Forms.CheckBox prieten WithEvents lblOutput Ca System.Windows.Forms.Label prieten WithEvents chkBold Ca System.Windows.Forms.CheckBox "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container Ca apel

Boole

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . lblOutput = New System.Windows.Forms.Label () Me.chkItalic = System.Windows.Forms.CheckBox Nou () Me.chkBold = System.Windows.Forms.CheckBox Nou () Me.SuspendLayout () " "lb lOutput " Me.lblOutput.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 11.25 !, S Me.lblOutput. Locaie = New System.Drawing.Point ( 48 , 24 ) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size ( 208 , 24 ) Me.lblOutput.TabIndex = 0 Me.lblOutput. Text = "Uita-te la schimbarea stilul de font" " "ch kItalic ' Me.chkItalic.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, Sy Me.chkItalic.Location = New System.Drawing.Point ( 152 , 64 ) Me.chkItalic.Name = "chkItalic" Me.chkItalic.Size = New System.Drawing.Size ( 64 , 24 ) Me.chkItalic.TabIndex = 2 Me.chkItalic.Text = "Italic" " "ch kBold ' Me.chkBold.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, Syst Me.chkBold.Location = New System.Drawing.Point ( 80 , 64 ) Me.chkBold.Name = "chkBold" Me.chkBold.Size = New System.Drawing.Size ( 56 , 24 )

Me.chkBold.TabIndex = 1 Me.chkBold.Text = "Bold" ' "Parintele mCheckBox ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 6 , 14 ) Me.ClientSize = New System.Drawing.Size ( 292 , 117 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.chkItalic, Me.chkB Me.Font = New System.Drawing . Font ( "Microsoft Sans Serif" , 9 !, System.Drawin Me.Name = "FrmCheckBox" Me.Text = "CheckBoxTest" Me . ResumeLayout ( Fals ) End Sub # End Regiunea ca System.EventArgs ) _

Sub Private chkItalic_CheckedChanged _ ( ByVal expeditor Ca System.Object, ByVal e Manere chkItalic.CheckedChanged

lblOutput.Font = New Font ( "Microsoft Sans Serif" , _ lblOutput.Font.Size, lblOutput.Font.Style XOR FontStyle.Italic ) End Sub Sub Private chkBold_CheckedChanged _ ( ByVal expeditor Ca System.Object, ByVal e Manere chkBold.CheckedChanged ca System.EventArgs ) _

lblOutput.Font = New Font ( "Microsoft Sans Serif" , _ lblOutput.Font.Size, lblOutput.Font.Style XOR FontStyle.Bold ) End Sub End Class

Original

Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D public class CheckBoxEvent public Shared Sub Main Application.Run(New FrmCheckBox) End Sub End class

Public Class FrmCheckBox Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents chkItalic As System.Windows.Forms.CheckBox Friend WithEvents lblOutput As System.Windows.Forms.Label Friend WithEvents chkBold As System.Windows.Forms.CheckBox 'Required by the Windows Form Designer Private components As System.ComponentModel.Container

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.lblOutput = New System.Windows.Forms.Label() Me.chkItalic = New System.Windows.Forms.CheckBox() Me.chkBold = New System.Windows.Forms.CheckBox() Me.SuspendLayout() ' 'lblOutput ' Me.lblOutput.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System Me.lblOutput.Location = New System.Drawing.Point(48, 24) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size(208, 24) Me.lblOutput.TabIndex = 0 Me.lblOutput.Text = "Watch the font style change" ' 'chkItalic ' Me.chkItalic.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System. Me.chkItalic.Location = New System.Drawing.Point(152, 64) Me.chkItalic.Name = "chkItalic" Me.chkItalic.Size = New System.Drawing.Size(64, 24) Me.chkItalic.TabIndex = 2 Me.chkItalic.Text = "Italic" ' 'chkBold

' Me.chkBold.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Dr Me.chkBold.Location = New System.Drawing.Point(80, 64) Me.chkBold.Name = "chkBold" Me.chkBold.Size = New System.Drawing.Size(56, 24) Me.chkBold.TabIndex = 1 Me.chkBold.Text = "Bold" ' 'FrmCheckBox ' Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14) Me.ClientSize = New System.Drawing.Size(292, 117) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.chkItalic, Me.chkBold, Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 9!, System.Drawing.FontS Me.Name = "FrmCheckBox" Me.Text = "CheckBoxTest" Me.ResumeLayout(False) End Sub #End Region Private Sub chkItalic_CheckedChanged _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles chkItalic.CheckedChanged lblOutput.Font = New Font("Microsoft Sans Serif", _ lblOutput.Font.Size, lblOutput.Font.Style Xor FontStyle.Italic) End Sub Private Sub chkBold_CheckedChanged _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles chkBold.CheckedChanged lblOutput.Font = New Font("Microsoft Sans Serif", _ lblOutput.Font.Size, lblOutput.Font.Style Xor FontStyle.Bold) End Sub End Class

Verificarea 14.4.3.CheckBox / debifai eveniment

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class CheckBoxCheckEvent public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Private componente Ca System.ComponentModel.IContainer prieten WithEvents CheckBox1 Ca System.Windows.Forms.CheckBox prieten WithEvents CheckBox2 Ca System.Windows.Forms.CheckBox prieten WithEvents CheckBox3 Ca System.Windows.Forms.CheckBox prieten WithEvents CheckBox4 Ca System.Windows.Forms . CheckBox prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents CheckBox5 Ca System.Windows.Forms.CheckBox prieten WithEvents CheckBox6 Ca System.Windows.Forms.CheckBox prieten WithEvents Label1 Ca System.Windows.Forms.Label <System.Diagnostics . DebuggerStepThrough () > Private Sub InitializeComponent () Me.CheckBox1 = System.Windows.Forms.CheckBox New Me.CheckBox2 = System.Windows.Forms.CheckBox New Me.CheckBox3 = System.Windows.Forms.CheckBox New Me.CheckBox4 = System.Windows.Forms.CheckBox nou Me.TextBox1 = New System.Windows.Forms.TextBox Me.CheckBox5 = System.Windows.Forms.CheckBox New Me.CheckBox6 = System.Windows.Forms.CheckBox New Me.Label1 = Sistem . Windows.Forms.Label Me.SuspendLayout () " "Ch eckBox1 ' Me.CheckBox1.Location = New System.Drawing.Point ( 24 , 64 )

Me.CheckBox1.Name = "CheckBox1" Me.CheckBox1.TabIndex = 0 Me CheckBox1.Text =. "CheckBox1" " "Ch eckBox2 ' Me.CheckBox2.Location = New System.Drawing.Point ( 152 , 64 ) Me.CheckBox2.Name = "CheckBox2" Me.CheckBox2.TabIndex = 1 Me.CheckBox2. Text = "CheckBox2" " "Ch eckBox3 ' Me.CheckBox3.Location = New System.Drawing.Point ( 24 , 120 ) Me.CheckBox3.Name = "CheckBox3" Me.CheckBox3.TabIndex = 2 Me.CheckBox3.Text = " CheckBox3 " " "Ch eckBox4 ' Me.CheckBox4.Location = New System.Drawing.Point ( 152 , 120 ) Me.CheckBox4.Name = "CheckBox4" Me.CheckBox4.TabIndex = 3 Me.CheckBox4.Text = "CheckBox4" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 32 , 232 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 216 , 20 ) Me.TextBox1 tabindex =. 4 Me.TextBox1.Text = "TextBox1" " "Ch eckBox5 ' Me.CheckBox5.Location = New System.Drawing.Point ( 24 , 176 ) Me.CheckBox5.Name = "CheckBox5" Me.CheckBox5.TabIndex = 5 Me.CheckBox5.Text = "CheckBox5" " "Ch eckBox6 ' Me.CheckBox6.Location = New System.Drawing.Point ( 152 , 176 ) Me.CheckBox6.Name = "CheckBox6" Me.CheckBox6.TabIndex = 6 Mine. CheckBox6.Text = "CheckBox6" " "La bel1 ' Me.Label1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , Me.Label1.Location = New System.Drawing.Point ( 0 , 0 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 208 , 48 ) Me.Label1.TabIndex = 7 Me.Label1.Text = "casetele de" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

24.0 !, Sys

= "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub Private Sub CheckBox1_CheckedChanged ( expeditor ByVal Ca System.Object, ByVal e Dac CheckBox1.Checked Apoi TextBox1.Text = "Verificai dac n cutia 1 este verificat." Else TextBox1.Text = "Verificai dac n cutia 1 nu este verificat ". Dac End End Sub Private Sub CheckBox2_CheckedChanged ( expeditor ByVal Ca System.Object, ByVal e Dac CheckBox2.Checked Apoi TextBox1.Text = "Verificai dac n cutia 2 este verificat." Else TextBox1.Text = "Verificai dac n cutia 2 nu este verificat ". Dac End End Sub Private Sub CheckBox3_CheckedChanged ( expeditor ByVal Ca System.Object, ByVal e Dac CheckBox3.Checked Apoi TextBox1.Text = "Verificai dac n cutia 3 este verificat." Else TextBox1.Text = "Verificai dac n cutia 3 nu este verificat ". Dac End End Sub Private Sub CheckBox4_CheckedChanged ( expeditor ByVal Ca System.Object, ByVal e Dac CheckBox4.Checked Apoi TextBox1.Text = "Verificai dac n cutia 4 este verificat." Else TextBox1.Text = "Verificai dac n cutia 4 nu este verificat ". Dac End End Sub Private Sub CheckBox5_CheckedChanged ( expeditor ByVal Ca System.Object, ByVal e Dac CheckBox5.Checked Apoi TextBox1.Text = "Verificai dac n cutia 5 este verificat." Else TextBox1.Text = "Verificai dac n cutia 5 nu este verificat ". Dac End End Sub Private Sub CheckBox6_CheckedChanged ( expeditor ByVal Ca System.Object, ByVal e Dac CheckBox6.Checked Apoi TextBox1.Text = "Verificai dac n cutia 6 este verificat." Else TextBox1.Text = "Verificai dac n cutia 6 nu este verificat ". Dac End End Sub

End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class CheckBoxCheckEvent public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Private components As System.ComponentModel.IContainer Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox Friend WithEvents CheckBox2 As System.Windows.Forms.CheckBox Friend WithEvents CheckBox3 As System.Windows.Forms.CheckBox Friend WithEvents CheckBox4 As System.Windows.Forms.CheckBox Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents CheckBox5 As System.Windows.Forms.CheckBox Friend WithEvents CheckBox6 As System.Windows.Forms.CheckBox Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.CheckBox1 = New System.Windows.Forms.CheckBox Me.CheckBox2 = New System.Windows.Forms.CheckBox Me.CheckBox3 = New System.Windows.Forms.CheckBox

Me.CheckBox4 = New System.Windows.Forms.CheckBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.CheckBox5 = New System.Windows.Forms.CheckBox Me.CheckBox6 = New System.Windows.Forms.CheckBox Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'CheckBox1 ' Me.CheckBox1.Location = New System.Drawing.Point(24, 64) Me.CheckBox1.Name = "CheckBox1" Me.CheckBox1.TabIndex = 0 Me.CheckBox1.Text = "CheckBox1" ' 'CheckBox2 ' Me.CheckBox2.Location = New System.Drawing.Point(152, 64) Me.CheckBox2.Name = "CheckBox2" Me.CheckBox2.TabIndex = 1 Me.CheckBox2.Text = "CheckBox2" ' 'CheckBox3 ' Me.CheckBox3.Location = New System.Drawing.Point(24, 120) Me.CheckBox3.Name = "CheckBox3" Me.CheckBox3.TabIndex = 2 Me.CheckBox3.Text = "CheckBox3" ' 'CheckBox4 ' Me.CheckBox4.Location = New System.Drawing.Point(152, 120) Me.CheckBox4.Name = "CheckBox4" Me.CheckBox4.TabIndex = 3 Me.CheckBox4.Text = "CheckBox4" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(32, 232) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(216, 20) Me.TextBox1.TabIndex = 4 Me.TextBox1.Text = "TextBox1" ' 'CheckBox5 ' Me.CheckBox5.Location = New System.Drawing.Point(24, 176) Me.CheckBox5.Name = "CheckBox5" Me.CheckBox5.TabIndex = 5 Me.CheckBox5.Text = "CheckBox5" ' 'CheckBox6 ' Me.CheckBox6.Location = New System.Drawing.Point(152, 176) Me.CheckBox6.Name = "CheckBox6" Me.CheckBox6.TabIndex = 6 Me.CheckBox6.Text = "CheckBox6" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.D Me.Label1.Location = New System.Drawing.Point(0, 0)

Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(208, 48) Me.Label1.TabIndex = 7 Me.Label1.Text = "Check Boxes" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.CheckBox6) Me.Controls.Add(Me.CheckBox5) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.CheckBox4) Me.Controls.Add(Me.CheckBox3) Me.Controls.Add(Me.CheckBox2) Me.Controls.Add(Me.CheckBox1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste If CheckBox1.Checked Then TextBox1.Text = "Check box 1 is checked." Else TextBox1.Text = "Check box 1 is not checked." End If End Sub

Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste If CheckBox2.Checked Then TextBox1.Text = "Check box 2 is checked." Else TextBox1.Text = "Check box 2 is not checked." End If End Sub

Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste If CheckBox3.Checked Then TextBox1.Text = "Check box 3 is checked." Else TextBox1.Text = "Check box 3 is not checked." End If End Sub

Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste If CheckBox4.Checked Then TextBox1.Text = "Check box 4 is checked." Else TextBox1.Text = "Check box 4 is not checked." End If End Sub

Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste If CheckBox5.Checked Then TextBox1.Text = "Check box 5 is checked." Else TextBox1.Text = "Check box 5 is not checked." End If

End Sub

Private Sub CheckBox6_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste If CheckBox6.Checked Then TextBox1.Text = "Check box 6 is checked." Else TextBox1.Text = "Check box 6 is not checked." End If End Sub End Class

.CheckBox cu trei state

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class CheckBoxThreeStates public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. apel

protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub

Distrugerea ( ByVal eliminare Apoi

Ca

Bool

"Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. WithEvents prieten CheckBox1 Ca System.Windows.Forms.CheckBox prieten WithEvents CheckBox2 Ca System.Windows.Forms.CheckBox prieten WithEvents CheckBox3 Ca System.Windows.Forms.CheckBox prieten WithEvents Label1 Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.CheckBox1 = Sistem. Windows.Forms.CheckBox Me.CheckBox2 = System.Windows.Forms.CheckBox New Me.CheckBox3 = System.Windows.Forms.CheckBox New Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout () " "Cap eckBox1 " Me.CheckBox1.Location = New System.Drawing.Point ( 88 , 64 ) Me.CheckBox1.Name = "CheckBox1" Me.CheckBox1.TabIndex = 0 Me.CheckBox1.Text = "nenregistrat" " "Ch eckBox2 " Me. CheckBox2.Checked = True Me.CheckBox2.CheckState = System.Windows.Forms.CheckState.Checked Me.CheckBox2.Location = New System.Drawing.Point ( 88 , 120 ) Me.CheckBox2.Name = "CheckBox2" Me.CheckBox2. tabindex = 1 Me.CheckBox2.Text = "verificat" " "Ch eckBox3 ' Me.CheckBox3.Checked = True Me.CheckBox3.CheckState = System.Windows.Forms.CheckState.Indeterminate Me.CheckBox3.Location = New System.Drawing. punctul ( 88 , 176 ) Me.CheckBox3.Name = "CheckBox3" Me.CheckBox3.TabIndex = 2 Me.CheckBox3.Text = "nedeterminat" Me.CheckBox3.ThreeState = True ' 'Fo RM1 ' Me.AutoScaleBaseSize = Sistem. Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

"Form1"

Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class CheckBoxThreeStates public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox Friend WithEvents CheckBox2 As System.Windows.Forms.CheckBox Friend WithEvents CheckBox3 As System.Windows.Forms.CheckBox Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.CheckBox1 = New System.Windows.Forms.CheckBox Me.CheckBox2 = New System.Windows.Forms.CheckBox Me.CheckBox3 = New System.Windows.Forms.CheckBox Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'CheckBox1 ' Me.CheckBox1.Location = New System.Drawing.Point(88, 64) Me.CheckBox1.Name = "CheckBox1" Me.CheckBox1.TabIndex = 0 Me.CheckBox1.Text = "Unchecked" ' 'CheckBox2 ' Me.CheckBox2.Checked = True Me.CheckBox2.CheckState = System.Windows.Forms.CheckState.Checked Me.CheckBox2.Location = New System.Drawing.Point(88, 120) Me.CheckBox2.Name = "CheckBox2" Me.CheckBox2.TabIndex = 1 Me.CheckBox2.Text = "Checked" ' 'CheckBox3 ' Me.CheckBox3.Checked = True Me.CheckBox3.CheckState = System.Windows.Forms.CheckState.Indeterminate Me.CheckBox3.Location = New System.Drawing.Point(88, 176) Me.CheckBox3.Name = "CheckBox3" Me.CheckBox3.TabIndex = 2 Me.CheckBox3.Text = "Indeterminate" Me.CheckBox3.ThreeState = True ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(272, 229) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.CheckBox3) Me.Controls.Add(Me.CheckBox2) Me.Controls.Add(Me.CheckBox1) Me.Name = "Form1" Me.Text = "Form1"

Me.ResumeLayout(False) End Sub #End Region End Class

Obiecte 14.4.5.Add la CheckedListBox

Importurile

System.Windows.Forms

public class CheckedListBoxAddObjects public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Private Sub Form1_Load ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere MyBase.Load clbEmployees.Items.Add ( Angajat noi ( "A" , "A" ) , True ) clbEmployees.Items.Add ( nou angajat ( "B" , "B" ) , False ) clbEmployees.Items.Add ( nou angajat ( "C" , "C" ) , CheckState.Indeterminate ) Sub End

Private Sub btnListSelections_Click ( ByVal expeditor Ca System.Object, ByVal e Dim checked_items Ca CheckedListBox.CheckedItemCollection = clbEmployees.Chec Console.WriteLine ( "angajaii selectai:" ) pentru fiecare element ca obiect n checked_items Console . WriteLine ( item.ToString ) Urmtorul articol End Sub End Class Public class Angajat publice Prenume Ca String Public NumeDeFamilie Ca String Public Sub New ( prenume ByVal Prenume = prenume NumeDeFamilie = LAST_NAME Ca String, LAST_NAME ByVal Ca String )

End Sub Public nlocuiete ToString Funcia () Ca String napoi Prenume & "" & NumeDeFamilie End Function End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.clbEmployees = New System.Windows.Forms.CheckedListBox Me.btnListSelections = New System.Windows.Forms.Button Me.SuspendLayout () " "cl bEmployees ' Me.clbEmployees.FormattingEnabled = True Me.clbEmployees.Location = Sistem. Drawing.Point ( 8 , 8 ) Me.clbEmployees.Name = "clbEmployees" Me.clbEmployees.Size = New System.Drawing.Size ( 160 , 123 ) Me.clbEmployees.TabIndex = 0 ' 'bt nListSelections ' Me.btnListSelections. Locaie = New System.Drawing.Point ( 8 , 152 ) Me.btnListSelections.Name = "btnListSelections" Me.btnListSelections.Size = New System.Drawing.Size ( 160 , 23 ) Me.btnListSelections.TabIndex = 1 Me.btnListSelections. Text = "Lista Selecii" " "Fo RM1 " Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou = "Form1" Me.Text = "UseCheckedListBox" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents clbEmployees Ca prieten WithEvents btnListSelections System.Windows.Forms.CheckedListBox Ca System.Windows.Forms.Button

Ca

Bool

End Class

Original

Imports System.Windows.Forms public class CheckedListBoxAddObjects public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load clbEmployees.Items.Add(New Employee("A", "A"), True) clbEmployees.Items.Add(New Employee("B", "B"), False) clbEmployees.Items.Add(New Employee("C", "C"), CheckState.Indeterminate) End Sub

Private Sub btnListSelections_Click(ByVal sender As System.Object, ByVal e As System Dim checked_items As CheckedListBox.CheckedItemCollection = clbEmployees.Checked Console.WriteLine("Selected Employees:") For Each item As Object In checked_items Console.WriteLine(item.ToString) Next item End Sub End Class Public Class Employee Public FirstName As String Public LastName As String Public Sub New(ByVal first_name As String, ByVal last_name As String) FirstName = first_name LastName = last_name End Sub Public Overrides Function ToString() As String Return FirstName & " " & LastName

End Function End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.clbEmployees = New System.Windows.Forms.CheckedListBox Me.btnListSelections = New System.Windows.Forms.Button Me.SuspendLayout() ' 'clbEmployees ' Me.clbEmployees.FormattingEnabled = True Me.clbEmployees.Location = New System.Drawing.Point(8, 8) Me.clbEmployees.Name = "clbEmployees" Me.clbEmployees.Size = New System.Drawing.Size(160, 123) Me.clbEmployees.TabIndex = 0 ' 'btnListSelections ' Me.btnListSelections.Location = New System.Drawing.Point(8, 152) Me.btnListSelections.Name = "btnListSelections" Me.btnListSelections.Size = New System.Drawing.Size(160, 23) Me.btnListSelections.TabIndex = 1 Me.btnListSelections.Text = "List Selections" ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(180, 187) Me.Controls.Add(Me.btnListSelections) Me.Controls.Add(Me.clbEmployees) Me.Name = "Form1" Me.Text = "UseCheckedListBox" Me.ResumeLayout(False) End Sub Friend WithEvents clbEmployees As System.Windows.Forms.CheckedListBox Friend WithEvents btnListSelections As System.Windows.Forms.Button End Class

Textul 14.6.1.Get din ComboBox

Importurile

System.Windows.Forms

public class GetComboBoxText public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Private Sub Dim Form1 Button1_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) _ Manere Button1.Click Limba Ca String

Limba = ComboBox1.Text Dac Language = "Visual Basic" Apoi MsgBox ( "Avem un ctigtor!" ) Else MsgBox ( Limb i "nu este un limbaj ru." ) End If End Sub End Class parial publice clasa Form1 Motenete System.Windows.Forms.Form <System.Diagnostics.DebuggerNonUserCode () > _ Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.SuspendLayout () " "La bel1 " Me.Label1. AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 13 , 22 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 160 , 14 ) Me.Label1. tabindex = 0 = Me.Label1.Text "Care este limba ta preferat?" " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 13 , 70 ) Me.Button1.Name = "Button1" Me.Button1 . Dimensiune = New System.Drawing.Size ( 267 , 23 ) Me.Button1.TabIndex = 2 Me.Button1.Text = "Evalueaz alegerea mea" " "Co mboBox1 " Me.ComboBox1.FormattingEnabled = true Me.ComboBox1.Items. AddRange ( Object Nou () { "C + +" , "C #" , "Java" , "Vi Me.ComboBox1.Location = New System.Drawing.Point ( 13 , 43 ) Me.ComboBox1. name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size ( 267 , 21 ) Me.ComboBox1.TabIndex = 1 ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me . ClientSize = Nou

= "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox End Class

Original

Get Text from ComboBox

Imports System.Windows.Forms public class GetComboBoxText public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click Dim Language As String Language = ComboBox1.Text If Language = "Visual Basic" Then MsgBox("We have a winner!") Else MsgBox(Language & " is not a bad language.") End If End Sub End Class Partial Public Class Form1 Inherits System.Windows.Forms.Form <System.Diagnostics.DebuggerNonUserCode()> _ Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() End Sub 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.SuspendLayout() ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(13, 22) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(160, 14) Me.Label1.TabIndex = 0 Me.Label1.Text = "What's your favorite language?" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(13, 70) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(267, 23) Me.Button1.TabIndex = 2 Me.Button1.Text = "Evaluate my choice" ' 'ComboBox1 ' Me.ComboBox1.FormattingEnabled = True Me.ComboBox1.Items.AddRange(New Object() {"C++", "C#", "Java", "Visual Basic", " Me.ComboBox1.Location = New System.Drawing.Point(13, 43) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(267, 21) Me.ComboBox1.TabIndex = 1 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 117) Me.Controls.Add(Me.ComboBox1) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox End Class

Textul 14.6.2.Set pentru ComboBox

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ComboBoxSelectionEventAddValue public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod Ca apel

Bool

prieten WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Co mboBox1 ' Me.ComboBox1.Location = New System.Drawing.Point ( 72 , 72 ) Me.ComboBox1.Name = "ComboBox1" Me. ComboBox1.Size = New System.Drawing.Size ( 121 , 21 ) Me.ComboBox1.TabIndex = 0 Me.ComboBox1.Text = "ComboBox1" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 16 , 168 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 256 , 20 ) Me. TextBox1.TabIndex = 2 Me.TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Eu. Controls.Add ( Me.TextBox1 ) Me.Controls.Add ( Me.ComboBox1 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea ca

Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e Pentru i Ca Integer = 0 la 10 ComboBox1.Items.Add ( "punctul" + i.ToString ()) nainte ComboBox1.Text = "Alege unul ..." End Sub Private Sub ComboBox1_SelectedIndexChanged ( expeditor ByVal Dim intSelectedIndex Ca Integer intSelectedIndex = ComboBox1.SelectedIndex Dim objSelectedItem ca obiect objSelectedItem = ComboBox1.SelectedItem Ca

System.Ev

System.Object, By

TextBox1.Text = "index element:" & intSelectedIndex & _ ", un articol de text a lui:." & objSelectedItem.ToString () End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ComboBoxSelectionEventAddValue public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'ComboBox1 ' Me.ComboBox1.Location = New System.Drawing.Point(72, 72) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(121, 21) Me.ComboBox1.TabIndex = 0 Me.ComboBox1.Text = "ComboBox1" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(16, 168) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(256, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.ComboBox1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H For i As Integer = 0 To 10 ComboBox1.Items.Add("Item " + i.ToString()) Next ComboBox1.Text = "Choose one..." End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As Dim intSelectedIndex As Integer intSelectedIndex = ComboBox1.SelectedIndex Dim objSelectedItem As Object objSelectedItem = ComboBox1.SelectedItem TextBox1.Text = "Item's index: " & intSelectedIndex & _ ". Item's text: " & objSelectedItem.ToString() End Sub End Class

Pagina de start a selectat 14.6.3.ComboBox schimbat eveniment

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ComboBoxSelectionEventAddValue public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Ca apel

Bool

"Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Co mboBox1 ' Me.ComboBox1.Location = New System.Drawing.Point ( 72 , 72 ) Me.ComboBox1.Name = "ComboBox1" Me. ComboBox1.Size = New System.Drawing.Size ( 121 , 21 ) Me.ComboBox1.TabIndex = 0 Me.ComboBox1.Text = "ComboBox1" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 16 , 168 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 256 , 20 ) Me. TextBox1.TabIndex = 2 Me.TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Eu. Controls.Add ( Me.TextBox1 ) Me.Controls.Add ( Me.ComboBox1 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea ca

Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e Pentru i Ca Integer = 0 la 10 ComboBox1.Items.Add ( "punctul" + i.ToString ()) nainte ComboBox1.Text = "Alege unul ..." End Sub Private Sub ComboBox1_SelectedIndexChanged ( expeditor ByVal Dim intSelectedIndex Ca Integer intSelectedIndex = ComboBox1.SelectedIndex Dim objSelectedItem ca obiect objSelectedItem = ComboBox1.SelectedItem Ca

System.Ev

System.Object, By

TextBox1.Text = "index element:" & intSelectedIndex & _ ", un articol de text a lui:." & objSelectedItem.ToString () End Sub

End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ComboBoxSelectionEventAddValue public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If

End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'ComboBox1 ' Me.ComboBox1.Location = New System.Drawing.Point(72, 72) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(121, 21) Me.ComboBox1.TabIndex = 0 Me.ComboBox1.Text = "ComboBox1" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(16, 168) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(256, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.ComboBox1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H For i As Integer = 0 To 10 ComboBox1.Items.Add("Item " + i.ToString()) Next ComboBox1.Text = "Choose one..." End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As Dim intSelectedIndex As Integer intSelectedIndex = ComboBox1.SelectedIndex Dim objSelectedItem As Object objSelectedItem = ComboBox1.SelectedItem

TextBox1.Text = "Item's index: " & intSelectedIndex & _ ". Item's text: " & objSelectedItem.ToString() End Sub End Class

Valoarea 14.6.4.Add a ComboBox

Importurile

System.Windows.Forms

public class ComboBoxAddSelection public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Motenete Form1 System.Windows.Forms.Form

Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Label1 Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent ()

Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Label1 = Sistem . Windows.Forms.Label Me.SuspendLayout () " "Co mboBox1 " Me.ComboBox1.Items.AddRange ( Object Nou () { "AAAAA" , "bbbbb" , Me.ComboBox1.Location = Sistem . Drawing.Point ( 48 , 16 ) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size ( 144 , 21 ) Me.ComboBox1.TabIndex = 0 Me.ComboBox1.Text = "Selecteaza " " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 24 , 64 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 96 , 20 ) Me TextBox1.TabIndex =. 1 Me.TextBox1.Text = "" " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 144 , 64 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 96 , 24 ) Me.Button1.TabIndex = 2 Me.Button1.Text = "Add" " "La bel1 ' Me.Label1.Location = New System.Drawing.Point ( 40 , 120 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 168 , 24 ) Me.Label1.TabIndex = 3 Me.Label1.Text = "Selecteaz" ' 'Fo RM1 " Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

"CCCCC" })

End Sub Private Sub Button1_Click ( ByVal expeditor ComboBox1.Items.Add ( TextBox1.Text ) TextBox1.Text = "" End Sub Ca System.Object, ByVal e ca

System

Private Sub ComboBox1_SelectedIndexChanged ( expeditor ByVal Selectai Case ComboBox1.SelectedIndex Case 0 Label1.Text = "A" Cazul 1

Ca

System.Object, By

Label1.Text = Cazul 2 Label1.Text = End Select End Sub End Class

"B" "C"

Original

Imports System.Windows.Forms public class ComboBoxAddSelection public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button

Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'ComboBox1 ' Me.ComboBox1.Items.AddRange(New Object() {"AAAAA", "BBBBB", "CCCCC"}) Me.ComboBox1.Location = New System.Drawing.Point(48, 16) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(144, 21) Me.ComboBox1.TabIndex = 0 Me.ComboBox1.Text = "Select" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(24, 64) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(96, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(144, 64) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(96, 24) Me.Button1.TabIndex = 2 Me.Button1.Text = "Add" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(40, 120) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(168, 24) Me.Label1.TabIndex = 3 Me.Label1.Text = "Select" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(264, 182) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.ComboBox1) Me.ResumeLayout(False) End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ComboBox1.Items.Add(TextBox1.Text) TextBox1.Text = "" End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As Select Case ComboBox1.SelectedIndex Case 0

Label1.Text = "A" Case 1 Label1.Text = "B" Case 2 Label1.Text = "C" End Select End Sub End Class

Eveniment Selecie 14.6.5.ComboBox i aduga elemente

Importurile

System.Windows.Forms

public class ComboBoxAddSelection public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Motenete Form1 System.Windows.Forms.Form

Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox

prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Label1 Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Label1 = Sistem . Windows.Forms.Label Me.SuspendLayout () " "Co mboBox1 " Me.ComboBox1.Items.AddRange ( Object Nou () { "AAAAA" , "bbbbb" , "CCCCC" }) Me.ComboBox1.Location = Sistem . Drawing.Point ( 48 , 16 ) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size ( 144 , 21 ) Me.ComboBox1.TabIndex = 0 Me.ComboBox1.Text = "Selecteaza " " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 24 , 64 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 96 , 20 ) Me TextBox1.TabIndex =. 1 Me.TextBox1.Text = "" " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 144 , 64 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 96 , 24 ) Me.Button1.TabIndex = 2 Me.Button1.Text = "Add" " "La bel1 ' Me.Label1.Location = New System.Drawing.Point ( 40 , 120 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 168 , 24 ) Me.Label1.TabIndex = 3 Me.Label1.Text = "Selecteaz" ' 'Fo RM1 " Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

End Sub Private Sub Button1_Click ( ByVal expeditor ComboBox1.Items.Add ( TextBox1.Text ) TextBox1.Text = "" End Sub Ca System.Object, ByVal e ca

System

Private Sub ComboBox1_SelectedIndexChanged ( expeditor ByVal Selectai Case ComboBox1.SelectedIndex

Ca

System.Object, By

0 Label1.Text = Cazul 1 Label1.Text = Cazul 2 Label1.Text = End Select End Sub End Class

Case

"A" "B" "C"

Original

Imports System.Windows.Forms public class ComboBoxAddSelection public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer

Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'ComboBox1 ' Me.ComboBox1.Items.AddRange(New Object() {"AAAAA", "BBBBB", "CCCCC"}) Me.ComboBox1.Location = New System.Drawing.Point(48, 16) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(144, 21) Me.ComboBox1.TabIndex = 0 Me.ComboBox1.Text = "Select" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(24, 64) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(96, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(144, 64) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(96, 24) Me.Button1.TabIndex = 2 Me.Button1.Text = "Add" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(40, 120) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(168, 24) Me.Label1.TabIndex = 3 Me.Label1.Text = "Select" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(264, 182) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.ComboBox1) Me.ResumeLayout(False) End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ComboBox1.Items.Add(TextBox1.Text) TextBox1.Text = "" End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As Select Case ComboBox1.SelectedIndex Case 0 Label1.Text = "A" Case 1 Label1.Text = "B" Case 2 Label1.Text = "C" End Select End Sub End Class

Using ComboBox pentru a selecta forma de a atrage

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class DrawShapes public comun Sub principal Application.Run ( New FrmComboBox ) End Sub End clasa Public class FrmComboBox Motenete Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () apel

End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "C ontains lista de forma ( cerc, ptrat, elips, placinta ) prieten WithEvents cboImage Ca System.Windows.Forms.ComboBox "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . cboImage = New System.Windows.Forms.ComboBox () Me.SuspendLayout () " "CB oImage ' Me.cboImage.DropDownWidth = 121 Me.cboImage.Items.AddRange ( Object Nou () { "Circle" , "Piaa" , "Ellipse" , Me.cboImage.Location = New System.Drawing.Point ( 24 , 16 ) Me.cboImage . Nume = "cboImage" Me.cboImage.Size = New System.Drawing.Size ( 121 , 21 ) Me.cboImage.TabIndex = 0 ' "Parintele mComboBox ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.cboImage }) Me.Name = "FrmComboBox" Me.Text = "ComboBoxTest " Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca

Boole

"

Private Sub cboImage_SelectedIndexChanged _ ( expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) _ Manere cboImage.SelectedIndexChanged Dim Dim Dim myGraphics Ca Graphics = MyBase.CreateGraphics () myPen Ca New Pen ( Color.DarkRed ) mySolidBrush Ca New SolidBrush ( Color.DarkRed )

myGraphics.Clear ( Color.White ) Selectai Case cboImage.SelectedIndex Case 0 "C cerc ASE este

Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DrawShapes public Shared Sub Main Application.Run(New FrmComboBox) End Sub End class Public Class FrmComboBox Inherits Form

#Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub ' contains shape list (circle, square, ellipse, pie) Friend WithEvents cboImage As System.Windows.Forms.ComboBox 'Required by the Windows Form Designer Private components As System.ComponentModel.Container

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.cboImage = New System.Windows.Forms.ComboBox() Me.SuspendLayout() ' 'cboImage ' Me.cboImage.DropDownWidth = 121 Me.cboImage.Items.AddRange(New Object() {"Circle", "Square", "Ellipse", "Pie", "Fi Me.cboImage.Location = New System.Drawing.Point(24, 16) Me.cboImage.Name = "cboImage" Me.cboImage.Size = New System.Drawing.Size(121, 21) Me.cboImage.TabIndex = 0 ' 'FrmComboBox ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cboImage}) Me.Name = "FrmComboBox" Me.Text = "ComboBoxTest" Me.ResumeLayout(False) End Sub #End Region Private Sub cboImage_SelectedIndexChanged _ (ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles cboImage.SelectedIndexChanged

Dim myGraphics As Graphics = MyBase.CreateGraphics() Dim myPen As New Pen(Color.DarkRed) Dim mySolidBrush As New SolidBrush(Color.DarkRed) myGraphics.Clear(Color.White) Select Case cboImage.SelectedIndex Case 0 ' case circle is selected myGraphics.DrawEllipse(myPen, 50, 50, 150, 150) Case 1 myGraphics.DrawRectangle(myPen, 50, 50, 150, 150) Case 2 myGraphics.DrawEllipse(myPen, 50, 85, 150, 115) Case 3 myGraphics.DrawPie(myPen, 50, 50, 150, 150, 0, 45) Case 4 myGraphics.FillEllipse(mySolidBrush, 50, 50, 150, 150) Case 5 myGraphics.FillRectangle(mySolidBrush, 50, 50, 150, 150) Case 6 myGraphics.FillEllipse(mySolidBrush, 50, 85, 150, 115) Case 7 myGraphics.FillPie(mySolidBrush, 50, 50, 150, 150, 0, 45) End Select End Sub End Class

ComboBox celule de redare

Importurile Importurile Importurile

System.Windows.Forms System.Drawing System.Drawing.Drawing2D

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente.

<System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Boolean )

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.XButton = New System.Windows.Forms.Button Me.ColorList = New System.Windows.Forms.ComboBox Me.SuspendLayout () " "XB UTTON ' Me.XButton.Location = New System.Drawing.Point ( 112 , 24 ) Me.XButton.Name = "XButton" Me.XButton.Size = New System.Drawing.Size ( 75 , 23 ) Me.XButton.TabIndex = 0 Me.XButton.Text = "Button1" Me.XButton.UseVisualStyleBackColor = True " "Co lorList ' Me.ColorList.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed Me.ColorList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.ColorList.FormattingEnabled = True Me.ColorList.Location = Sistem . Drawing.Point ( 88 , 64 ) Me.ColorList.Name = "ColorList" Me.ColorList.Size = New System.Drawing.Size ( 121 , 21 ) Me.ColorList.TabIndex = 1 ' 'Fo RM1 " Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = false Me.Name = "Form1" Me.Text = "Control Drawing" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents XButton Ca System.Windows.Forms.Button prieten WithEvents ColorList Ca System.Windows.Forms.ComboBox Sfrit clasa public class Form1 Private Sub Form1_Load ( ByVal expeditor

Ca

obiect, ByVal e

ca

System.EventArgs

Sub Private Sub Form1_Paint ( expeditor ByVal Ca e.Graphics.DrawEllipse ( Pens.Black, 10 , Me.ClientRectangle . Inaltime - 20 ) End Sub Private Sub XButton_Paint ( expeditor ByVal Dim usePen Ca Pen e.Graphics.Clear ( SystemColors.Control ) usePen = New Pen ( SystemColors.ControlText, 3 ) e.Graphics.DrawRectangle ( usePen, XButton.ClientRectangle ) usePen.Dispose () End Sub Private Sub ColorList_DrawItem ( expeditor ByVal Dim useBrush Ca Brush n cazul n care ( e.Index = - 1 ) Ca obiect, e ByVal Ca Ca

obiect, e ByVal Ca System.Windows. 10 , Me.ClientRectangle.Width - 20

obiect, e ByVal

Ca

System.Window

System.W

apoi s se ntoarc

e.DrawBackground ()

useBrush = New SolidBrush ( Color.FromName ( CStr ( ColorList.Items ( e.Index )) e.Graphics.FillRectangle ( useBrush, _ e.Bounds.Left + 2 , e.Bounds.Top + 2 , _ e. Bounds.Width - 4 , e.Bounds.Height - 4 ) useBrush.Dispose () e.Graphics.DrawRectangle ( Pens.Black, _ e.Bounds.Left + 2 , e.Bounds.Top + 2 , _ e.Bounds.Width - 4 , e.Bounds.Height - 4 ) e.DrawFocusRectangle () End Sub Private Sub XButton_Click ( ByVal expeditor MsgBox ( "Button clic." ) End Sub End Class public class ComboBoxCellRenderer public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Ca System.Object, ByVal e ca

System

Original

Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.XButton = New System.Windows.Forms.Button Me.ColorList = New System.Windows.Forms.ComboBox Me.SuspendLayout() ' 'XButton ' Me.XButton.Location = New System.Drawing.Point(112, 24) Me.XButton.Name = "XButton" Me.XButton.Size = New System.Drawing.Size(75, 23) Me.XButton.TabIndex = 0 Me.XButton.Text = "Button1" Me.XButton.UseVisualStyleBackColor = True ' 'ColorList ' Me.ColorList.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed Me.ColorList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.ColorList.FormattingEnabled = True Me.ColorList.Location = New System.Drawing.Point(88, 64)

Me.ColorList.Name = "ColorList" Me.ColorList.Size = New System.Drawing.Size(121, 21) Me.ColorList.TabIndex = 1 ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 221) Me.Controls.Add(Me.ColorList) Me.Controls.Add(Me.XButton) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "Control Drawing" Me.ResumeLayout(False) End Sub Friend WithEvents XButton As System.Windows.Forms.Button Friend WithEvents ColorList As System.Windows.Forms.ComboBox End Class Public Class Form1 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles ColorList.Items.Add("Red") ColorList.Items.Add("Orange") ColorList.Items.Add("Yellow") ColorList.Items.Add("Green") ColorList.Items.Add("Blue") ColorList.Items.Add("Indigo") ColorList.Items.Add("Violet") End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.Pain e.Graphics.DrawEllipse(Pens.Black, 10, 10, Me.ClientRectangle.Width - 20, _ Me.ClientRectangle.Height - 20) End Sub

Private Sub XButton_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.Pa Dim usePen As Pen e.Graphics.Clear(SystemColors.Control) usePen = New Pen(SystemColors.ControlText, 3) e.Graphics.DrawRectangle(usePen, XButton.ClientRectangle) usePen.Dispose() End Sub

Private Sub ColorList_DrawItem(ByVal sender As Object, ByVal e As System.Windows.For Dim useBrush As Brush If (e.Index = -1) Then Return e.DrawBackground() useBrush = New SolidBrush(Color.FromName(CStr(ColorList.Items(e.Index)))) e.Graphics.FillRectangle(useBrush, _ e.Bounds.Left + 2, e.Bounds.Top + 2, _ e.Bounds.Width - 4, e.Bounds.Height - 4) useBrush.Dispose()

e.Graphics.DrawRectangle(Pens.Black, _ e.Bounds.Left + 2, e.Bounds.Top + 2, _ e.Bounds.Width - 4, e.Bounds.Height - 4) e.DrawFocusRectangle() End Sub

Private Sub XButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs MsgBox("Button clicked.") End Sub End Class public class ComboBoxCellRenderer public Shared Sub Main Application.Run(New Form1) End Sub End class

ComboBox 14.6.8.Use de control TextBox culoarea fontului

Importurile

System.Windows.Forms

public class ComboBoxSelectionEvent public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Form1 Ca

Private Sub ComboBox1_SelectedIndexChanged ( expeditor ByVal Selectai Case ComboBox1.SelectedIndex Case 0 TextBox1.ForeColor = System.Drawing.Color.Yellow Cazul 1 TextBox1.ForeColor = System.Drawing. Color.Red Cazul 2 TextBox1.ForeColor = System.Drawing.Color.Blue Cazul 3 TextBox1.ForeColor = System.Drawing.Color.Black

System.Object, By

End End Sub End Class

Selectai

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Co mboBox1 " Me.ComboBox1. DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.ComboBox1.FormattingEnabled = True Me.ComboBox1.Items.AddRange ( Object Nou () { "Yellow" , "Red" , "albastru" , Me. ComboBox1.Location = New System.Drawing.Point ( 19 , 30 ) Me.ComboBox1.Margin = New System.Windows.Forms.Padding ( 4 , 4 , 4 , 4 ) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1 . Dimensiune = New System.Drawing.Size ( 476 , 23 ) Me.ComboBox1.TabIndex = 0 ' 'La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 16 , 11 ) Me.Label1.Margin = New System.Windows.Forms.Padding ( 4 , 0 , 4 , 0 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 67 , 15 ) Me . Label1.TabIndex = 1 Me.Label1.Text = "color" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 16 , 62 ) Me.TextBox1.Margin = System.Windows.Forms noi. umplutur ( 4 , 4 , 4 , 4 ) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 479 , 169 ) Me.TextBox1.TabIndex = 2

Boolean )

Me.TextBox1.Text = "www.java2s.com" " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 8.0 !, Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font mine. ClientSize = Nou

15.0 ! )

= New System.Windows.Forms.Padding ( 4 , Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) Me.PerformLayout ()

4 ,

4 ,

4 )

Sub End prieten WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox End Class

Original

Imports System.Windows.Forms public class ComboBoxSelectionEvent public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As Select Case ComboBox1.SelectedIndex Case 0 TextBox1.ForeColor = System.Drawing.Color.Yellow

Case 1 TextBox1.ForeColor = System.Drawing.Color.Red Case 2 TextBox1.ForeColor = System.Drawing.Color.Blue Case 3 TextBox1.ForeColor = System.Drawing.Color.Black End Select End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'ComboBox1 ' Me.ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.ComboBox1.FormattingEnabled = True Me.ComboBox1.Items.AddRange(New Object() {"Yellow", "Red", "Blue", "Black"}) Me.ComboBox1.Location = New System.Drawing.Point(19, 30) Me.ComboBox1.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(476, 23) Me.ComboBox1.TabIndex = 0 ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(16, 11) Me.Label1.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(67, 15) Me.Label1.TabIndex = 1 Me.Label1.Text = "Color" ' 'TextBox1 '

Me.TextBox1.Location = New System.Drawing.Point(16, 62) Me.TextBox1.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(479, 169) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "www.java2s.com" ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(513, 242) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.ComboBox1) Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox End Class

Ilustraie 14.6.9.HatchBrush prin utilizarea ComboBox

Imports System Imports System.Drawing

Imports Imports Imports Imports Imports

System.Collections System.ComponentModel System.Windows.Forms System.Data System.Drawing.Drawing2D

public class HatchBrushStyleComboBox public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form privare de stil Ca New HatchStyle private forClr Ca color = Color.Blue private backClr Ca color = Color.Red # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Label3 Ca System.Windows.Forms.Label prieten WithEvents TextBox2 Ca System.Windows.Forms. TextBox prieten WithEvents ForColorBtn Ca System.Windows.Forms.Button prieten WithEvents BackGroundBtn Ca System.Windows.Forms.Button prieten WithEvents ApplyBtn Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me. Label1 = New System.Windows.Forms.Label Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.Label2 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Ca apel

Bool

Me.Label3 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox Me.ForColorBtn = New System.Windows.Forms.Button Me.BackGroundBtn = New System.Windows.Forms.Button Me.ApplyBtn = Sistem . Windows.Forms.Button Me.SuspendLayout () " "La bel1 ' Me.Label1.Location = New System.Drawing.Point ( 8 , 8 ) Me.Label1.Name = "Label1" Me.Label1.Size = Sistem . Drawing.Size ( 72 , 23 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "Select Style:" " "Co mboBox1 ' Me.ComboBox1.Location = New System.Drawing.Point ( 96 , 8 ) Me . ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size ( 121 , 21 ) Me.ComboBox1.TabIndex = 1 Me.ComboBox1.Text = "ComboBox1" " "La bel2 " Me.Label2. Locaie = New System.Drawing.Point ( 8 , 40 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 96 , 23 ) Me.Label2.TabIndex = 2 Me.Label2. Text = "Forground Culoare:" " "Te xtBox1 ' Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.TextBox1.Location = New System.Drawing.Point ( 112 , 40 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.ReadOnly = True Me.TextBox1.Size = New System.Drawing.Size ( 32 , 20 ) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "" " "La bel3 " Me.Label3 . Locaia = New System.Drawing.Point ( 0 , 72 ) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size ( 104 , 23 ) Me.Label3.TabIndex = 4 Me.Label3 . Text = "Culoarea de fundal:" " "Te xtBox2 ' Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.TextBox2.Location = New System.Drawing.Point ( 112 , 72 ) Me.TextBox2.Name = "TextBox2" Me.TextBox2.ReadOnly = True Me.TextBox2.Size = New System.Drawing.Size ( 32 , 20 ) Me.TextBox2.TabIndex = 5 Me.TextBox2.Text = "" ' 'Fo rColorBtn "

Me. ForColorBtn.Location = New System.Drawing.Point ( 152 , 40 ) Me.ForColorBtn.Name = "ForColorBtn" Me.ForColorBtn.Size = New System.Drawing.Size ( 48 , 23 ) Me.ForColorBtn.TabIndex = 6 Mine. ForColorBtn.Text = "Alege ..." " "Ba ckGroundBtn ' Me.BackGroundBtn.Location = New System.Drawing.Point ( 152 , 72 ) Me.BackGroundBtn.Name = "BackGroundBtn" Me.BackGroundBtn.Size = Sistem. Drawing.Size ( 48 , 23 ) Me.BackGroundBtn.TabIndex = 7 Me.BackGroundBtn.Text = "Pic ..." " "Ap. plyBtn ' Me.ApplyBtn.Location = New System.Drawing.Point ( 224 , 72 ) Me . ApplyBtn.Name = "ApplyBtn" Me.ApplyBtn.TabIndex = 8 Me.ApplyBtn.Text = "Aplic" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= "Form1" Me.Text = "Perii Hatch" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub Form1_Load ( ByVal expeditor FillHatchStyles () End Sub Privat

System.Ev

= HatchStyle.BackwardDiagonal.ToString () End Sub "Fi llHatchStyles Private Sub ApplyBtn_Click ( ByVal expeditor Ca Dim g Ca Graphics = Me.CreateGraphics () g.Clear ( Me.BackColor ) System.Object, ByVal e ca

Syste

Dim str. Ca String = ComboBox1.Text Select Case str. Cazul "BackwardDiagonal" style = HatchStyle.BackwardDiagonal Cazul "DashedVertical" style = HatchStyle.DashedVertical Cazul "Crucea" style = HatchStyle.Cross Cazul "DiagonalCross" style = HatchStyle.DiagonalCross Cazul "HorizontalBrick" style = HatchStyle.HorizontalBrick Cazul "LightDownwardDiagonal" style = HatchStyle.LightDownwardDiagonal Cazul "LightUpwardDiagonal" style = HatchStyle.LightUpwardDiagonal Case Else End Selectai Dim perie Ca HatchBrush nou ( stil, forClr, backClr ) g.FillRectangle ( perie, 50 , 100 , 200 , 200 ) brush.Dispose () g . Evacuarea () End Sub End Class

Original

Imports Imports Imports Imports

System System.Drawing System.Collections System.ComponentModel

Imports System.Windows.Forms Imports System.Data Imports System.Drawing.Drawing2D public class HatchBrushStyleComboBox public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Private style As New HatchStyle Private forClr As Color = Color.Blue Private backClr As Color = Color.Red #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents ForColorBtn As System.Windows.Forms.Button Friend WithEvents BackGroundBtn As System.Windows.Forms.Button Friend WithEvents ApplyBtn As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.Label2 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox

Me.ForColorBtn = New System.Windows.Forms.Button Me.BackGroundBtn = New System.Windows.Forms.Button Me.ApplyBtn = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(8, 8) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(72, 23) Me.Label1.TabIndex = 0 Me.Label1.Text = "Select Style:" ' 'ComboBox1 ' Me.ComboBox1.Location = New System.Drawing.Point(96, 8) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(121, 21) Me.ComboBox1.TabIndex = 1 Me.ComboBox1.Text = "ComboBox1" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(8, 40) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(96, 23) Me.Label2.TabIndex = 2 Me.Label2.Text = "Forground Color:" ' 'TextBox1 ' Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.TextBox1.Location = New System.Drawing.Point(112, 40) Me.TextBox1.Name = "TextBox1" Me.TextBox1.ReadOnly = True Me.TextBox1.Size = New System.Drawing.Size(32, 20) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "" ' 'Label3 ' Me.Label3.Location = New System.Drawing.Point(0, 72) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(104, 23) Me.Label3.TabIndex = 4 Me.Label3.Text = "Background Color:" ' 'TextBox2 ' Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.TextBox2.Location = New System.Drawing.Point(112, 72) Me.TextBox2.Name = "TextBox2" Me.TextBox2.ReadOnly = True Me.TextBox2.Size = New System.Drawing.Size(32, 20) Me.TextBox2.TabIndex = 5 Me.TextBox2.Text = "" ' 'ForColorBtn ' Me.ForColorBtn.Location = New System.Drawing.Point(152, 40) Me.ForColorBtn.Name = "ForColorBtn"

Me.ForColorBtn.Size = New System.Drawing.Size(48, 23) Me.ForColorBtn.TabIndex = 6 Me.ForColorBtn.Text = "Pick..." ' 'BackGroundBtn ' Me.BackGroundBtn.Location = New System.Drawing.Point(152, 72) Me.BackGroundBtn.Name = "BackGroundBtn" Me.BackGroundBtn.Size = New System.Drawing.Size(48, 23) Me.BackGroundBtn.TabIndex = 7 Me.BackGroundBtn.Text = "Pic..." ' 'ApplyBtn ' Me.ApplyBtn.Location = New System.Drawing.Point(224, 72) Me.ApplyBtn.Name = "ApplyBtn" Me.ApplyBtn.TabIndex = 8 Me.ApplyBtn.Text = "Apply" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(416, 325) Me.Controls.Add(Me.ApplyBtn) Me.Controls.Add(Me.BackGroundBtn) Me.Controls.Add(Me.ForColorBtn) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.ComboBox1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Hatch Brushes" Me.ResumeLayout(False) End Sub #End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H FillHatchStyles() End Sub Private Sub FillHatchStyles() comboBox1.Items.Add(HatchStyle.BackwardDiagonal.ToString()) comboBox1.Items.Add(HatchStyle.Cross.ToString()) comboBox1.Items.Add(HatchStyle.DashedVertical.ToString()) comboBox1.Items.Add(HatchStyle.DiagonalCross.ToString()) comboBox1.Items.Add(HatchStyle.HorizontalBrick.ToString()) comboBox1.Items.Add(HatchStyle.LightDownwardDiagonal.ToString()) comboBox1.Items.Add(HatchStyle.LightUpwardDiagonal.ToString()) comboBox1.Text = HatchStyle.BackwardDiagonal.ToString() End Sub 'FillHatchStyles

Private Sub ApplyBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArg Dim g As Graphics = Me.CreateGraphics() g.Clear(Me.BackColor) Dim str As String = ComboBox1.Text Select Case str

Case "BackwardDiagonal" style = HatchStyle.BackwardDiagonal Case "DashedVertical" style = HatchStyle.DashedVertical Case "Cross" style = HatchStyle.Cross Case "DiagonalCross" style = HatchStyle.DiagonalCross Case "HorizontalBrick" style = HatchStyle.HorizontalBrick Case "LightDownwardDiagonal" style = HatchStyle.LightDownwardDiagonal Case "LightUpwardDiagonal" style = HatchStyle.LightUpwardDiagonal Case Else End Select Dim brush As New HatchBrush(style, forClr, backClr) g.FillRectangle(brush, 50, 100, 200, 200) brush.Dispose() g.Dispose() End Sub End Class

MenuItem 14.7.1.CheckBox

Importurile

System.Windows.Forms

public class RadioButtonCheckBox public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Public class MDIChild Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New ()

"Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents RichTextBox1 Ca System.Windows.Forms.RichTextBox prieten WithEvents mainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents mnuMDIOptions Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMDIOpiton1 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMDIOpiton2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMDIOpiton3 Ca System.Windows.Forms. MenuItem <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.RichTextBox1 = New System.Windows.Forms.RichTextBox () Me.mainMenu1 = New System.Windows.Forms.MainMenu () Me.mnuMDIOptions = Sistem. Windows.Forms.MenuItem () Me.mnuMDIOpiton1 = New System.Windows.Forms.MenuItem () Me.mnuMDIOpiton2 = New System.Windows.Forms.MenuItem () Me.mnuMDIOpiton3 = New System.Windows.Forms.MenuItem () Me . SuspendLayout () " "Ri chTextBox1 ' Me.RichTextBox1.Name = "RichTextBox1" Me.RichTextBox1.Size = New System.Drawing.Size ( 296 , 176 ) Me.RichTextBox1.TabIndex = 0 Me.RichTextBox1.Text = "RichTextBox1 " " "ma inMenu1 " Me.mainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuM " "mil lei uMDIOptions ' Me.mnuMDIOptions.Index = 0 Me.mnuMDIOptions.MenuItems.AddRange ( nou System.Windows.Forms.MenuItem () { Me. Me.mnuMDIOptions.MergeOrder = 1 Me.mnuMDIOptions.Text = "MDIChildOptions" " "milioane uMDIOpiton1 " Me.mnuMDIOpiton1.Index = 0 Me.mnuMDIOpiton1.Text = "MDI Opiunea 1" '

'mil. uMDIOpiton2 ' Me.mnuMDIOpiton2.Index = 1 Me.mnuMDIOpiton2.Text = "MDI Opiunea 2" ' 'mil. uMDIOpiton3 ' Me.mnuMDIOpiton3.Index = 2 Me. mnuMDIOpiton3.Text = "MDI Opiunea 3" " "MD IChild ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 174 ) Me.Controls.AddRange ( nou System.Windows.Forms.Control () { Me.RichTextBox1 }) Me.Menu = Me.mainMenu1 Me.Name = "MDIChild" Me.Text = "MDIChild" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Private Sub Option_Click ( ByVal expeditor Ca System.Object, ByVal e Manere mnuMDIOpiton1.Click, mnuMDIOpiton2.Click, mnuMDIOpiton3.Click Dim punctul Ca MenuItem = Ctype ( expeditor, MenuItem ) item.Checked = Nu item.Checked End Sub End Class Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat" ca

System.

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer Ca apel

Bool

"Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod WithEvents prieten mainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents mnuFile Ca System.Windows.Forms.MenuItem prieten WithEvents mnuNew Ca System.Windows.Forms.MenuItem prieten WithEvents mnuFileOpen Ca System.Windows.Forms.MenuItem prieten WithEvents mnuFileClose Ca System.Windows.Forms.MenuItem prieten WithEvents mnuFileSave Ca System.Windows.Forms. MenuItem prieten WithEvents mnuFileSaveAs Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEdit Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEditCopy Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEditPaste Ca System.Windows.Forms.MenuItem prieten mnuOptions WithEvents Ca sistem . Windows.Forms.MenuItem prieten WithEvents mnuOption1 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuOption2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuOption3 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOptions Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOption1 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOption2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOption3 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuWindow Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu1 Ca sistem. Windows.Forms.MenuItem prieten WithEvents mnuMenu11 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu12 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu13 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu14 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMerge Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu21 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu22 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu23 Ca System.Windows . Forms.MenuItem prieten WithEvents mnuMenu24 Ca System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.mainMenu1 = New System.Windows.Forms.MainMenu () Me.mnuFile = Sistem. Windows.Forms.MenuItem () Me.mnuNew = New System.Windows.Forms.MenuItem () Me.mnuFileOpen = New System.Windows.Forms.MenuItem () Me.mnuFileClose = New System.Windows.Forms.MenuItem () Me . mnuFileSave = New System.Windows.Forms.MenuItem () Me.mnuFileSaveAs = New System.Windows.Forms.MenuItem () Me.mnuEdit = New System.Windows.Forms.MenuItem () Me.mnuEditCopy = New System.Windows. Forms.MenuItem () Me.mnuEditPaste = New System.Windows.Forms.MenuItem () Me.mnuOptions = New System.Windows.Forms.MenuItem () Me.mnuOption1 = New System.Windows.Forms.MenuItem () Me.mnuOption2 = New System.Windows.Forms.MenuItem () Me.mnuOption3 = New System.Windows.Forms.MenuItem () Me.mnuRadioOptions = New System.Windows.Forms.MenuItem () Me.mnuRadioOption1 = System.Windows.Forms noi. MenuItem () Me.mnuRadioOption2 = New System.Windows.Forms.MenuItem () Me.mnuRadioOption3 = New System.Windows.Forms.MenuItem () Me.mnuWindow = New System.Windows.Forms.MenuItem () Me.mnuMenu1 = Nou System.Windows.Forms.MenuItem () Me.mnuMenu11 = New System.Windows.Forms.MenuItem () Me.mnuMenu12 = New System.Windows.Forms.MenuItem () Me.mnuMenu13 = New System.Windows.Forms.MenuItem ( ) Me.mnuMenu14 = New System.Windows.Forms.MenuItem () Me.mnuMerge = New System.Windows.Forms.MenuItem () Me.mnuMenu2 = New System.Windows.Forms.MenuItem () Me.mnuMenu21 = Sistem. Windows.Forms.MenuItem () Me.mnuMenu22 = New System.Windows.Forms.MenuItem ()

Me.mnuMenu23 = New System.Windows.Forms.MenuItem () Me.mnuMenu24 = New System.Windows.Forms.MenuItem () " "ma inMenu1 " Me.mainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () " "mil lei uFile ' Me.mnuFile.Index = 0 Me.mnuFile.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuFile.Text = "File" " "milioane uNew ' Me.mnuNew.Index = 0 Me.mnuNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN Me.mnuNew.Text = "& New" " "mil. uFileOpen ' Me.mnuFileOpen.Index = 1 Me.mnuFileOpen.Text = "Open" " "milioane uFileClose ' Me.mnuFileClose.Index = 2 Me.mnuFileClose.Text = "Close" " "milioane uFileSave " Me.mnuFileSave. index = 3 Me.mnuFileSave.Text = "Salvare" " "milioane uFileSaveAs ' Me.mnuFileSaveAs.Index = 4 Me.mnuFileSaveAs.Text = "Salvare & A" " "milioane uEdit " Me.mnuEdit.Index = 1 Me.mnuEdit.MenuItems . AddRange ( New System.Windows.Forms.MenuItem () Me.mnuEdit.Text = "Edit" " "milioane uEditCopy ' Me.mnuEditCopy.Index = 0 Me.mnuEditCopy.Text = "& Copy", " 'mil. uEditPaste ' Me.mnuEditPaste.Index = 1 Me.mnuEditPaste.Text = "Paste" " "milioane uOptions ' Me.mnuOptions.Index = 2 Me.mnuOptions.MenuItems.AddRange ( New System.Windows.Forms . MenuItem Me.mnuOptions.Text = "Opiuni" "

{ Me.mnuF

Me.mnuNew

{ Me.mnuE

() { Me.m

"milioane uOption1 ' Me.mnuOption1.Index = 0 Me.mnuOption1.Text = "Opiunea 1" " " mil. uOption2 ' Me.mnuOption2.Index = 1 Me.mnuOption2.Text = "Opiunea 2" ' 'mil. uOption3 ' Me.mnuOption3.Index = 2 Me.mnuOption3.Text = "Option3" " "milioane uRadioOptions " Me.mnuRadioOptions.Index = 3 Me.mnuRadioOptions.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { M Me.mnuRadioOptions.Text = "Opiuni de radio" " "milioane uROption1 " Me . mnuRadioOption1.Index = 0 Me.mnuRadioOption1.RadioCheck = True Me.mnuRadioOption1.Text = "Opiunea Radio 1" ' 'mil. uROption2 ' Me.mnuRadioOption2.Index = 1 Me.mnuRadioOption2.RadioCheck = True Me.mnuRadioOption2.Text = " Opiunea Radio 2 " ' 'mil. uROption3 ' Me.mnuRadioOption3.Index = 2 Me.mnuRadioOption3.RadioCheck = True Me.mnuRadioOption3.Text = "Opiunea Radio 3", " 'mil. uWindow ' Me.mnuWindow.Index = 4 Me.mnuWindow. MdiList = True Me.mnuWindow.MergeOrder = 99 Me.mnuWindow.Text = "& Window" " "milioane uMenu1 ' Me.mnuMenu1.Index = 5 Me.mnuMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuMe Me.mnuMenu1.Text = "Meniul 1" ' 'mil. uMenu11 ' Me.mnuMenu11.Index = 0 Me.mnuMenu11.MergeOrder = 1 Me.mnuMenu11.Text = "Meniu 1.1" " "milioane uMenu12 ' Me.mnuMenu12.Index = 1

Me.mnuMenu12.MergeOrder = 2 Me.mnuMenu12.Text = "Meniu 1.2" " "milioane uMenu13 ' Me.mnuMenu13.Index = 2 Me.mnuMenu13.MergeOrder = 3 Me.mnuMenu13.Text = "Meniu 1.3" " "milioane uMenu14 ' Me.mnuMenu14.Index = 3 Me.mnuMenu14.MergeOrder = 4 Me.mnuMenu14.Text = "Meniu 1.4", " milioane " uMerge ' Me.mnuMerge.Index = 4 Me.mnuMerge.MergeOrder = 99 Me.mnuMerge.Text = "Merge!" " "milioane uMenu2 ' Me.mnuMenu2.Index = 6 Me.mnuMenu2.MenuItems.AddRange ( New System.Windows . Forms.MenuItem () { Me.mnu Me.mnuMenu2.Text = "Meniul 2" ' 'mil. uMenu21 ' Me.mnuMenu21.Index = 0 Me.mnuMenu21. MergeOrder = 1 Me.mnuMenu21.Text = "Meniu 2.1" " "milioane uMenu22 ' Me.mnuMenu22.Index = 1 Me.mnuMenu22.MergeOrder = 2 Me.mnuMenu22.MergeType = System.Windows.Forms.MenuMerge.Replace Me.mnuMenu22 . Text = "Meniu 2.2" " "milioane uMenu23 ' Me.mnuMenu23.Index = 2 Me.mnuMenu23.MergeOrder = 3 Me.mnuMenu23.MergeType = System.Windows.Forms.MenuMerge.Remove Me.mnuMenu23.Text = "Meniul 2.3 " " "milioane uMenu24 ' Me.mnuMenu24.Index = 3 Me.mnuMenu24.MergeOrder = 5 Me.mnuMenu24.Text = "Meniu 2.4" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 456 , 146 ) Me.IsMdiContainer = True Me.Menu = Me.mainMenu1 Me.Name = "Form1" Me.Text = "Form1"

End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub mnuNew_Click ( ByVal expeditor Manere mnuNew.Click Dim newMDIChild Ca New MDIChild () newMDIChild.MdiParent = Me newMDIChild.Show () End Sub

System.

Private Sub mnuFileOpen_Click ( ByVal expeditor Ca System.Object, ByVal e Manere mnuFileOpen.Click MessageBox.Show ( "Ai fcut clic fiier deschis!" , _ "tester eveniment Menu" , _ MessageBoxButtons.OK, _ MessageBoxIcon. Informaii ) End Sub

ca

Sy

Private Sub mnuFileClose_Click ( ByVal expeditor Ca System.Object, ByVal e ca S Manere mnuFileClose.Click MessageBox.Show ( "Ai fcut clic fiier aproape!" , "tester Meniu eveniment" , End Sub Private Sub mnuEditCopy_Click ( ByVal expeditor Ca Manere mnuEditCopy.Click MessageBox.Show ( "Ai fcut clic Edit copie!" , End Sub System.Object, ByVal e ca

Sy

"tester Meniu eveniment" , Mes

Private Sub mnuEditPaste_Click ( ByVal expeditor Ca System.Object, ByVal e ca S Manere mnuEditPaste.Click MessageBox.Show ( "Ai fcut clic pe Editare paste!" , "tester Meniu eveniment" End Sub Private Sub Option_Click ( ByVal expeditor Ca System.Object, ByVal e Manere mnuOption1.Click, mnuOption2.Click, mnuOption3.Click Dim punctul Ca MenuItem = Ctype ( expeditor, MenuItem ) item.Checked = Nu item.Checked End Sub ca

System.

Private Sub RadioOption_Click ( ByVal expeditor Ca System.Object, ByVal e Manere mnuRadioOption1.Click, mnuRadioOption2.Click, mnuRadioOption3.Click Dim punctul Ca MenuItem = Ctype ( expeditor, MenuItem ) Dim printe Ca Meniu = item.Parent Dim tempMi Ca MenuItem pentru fiecare tempMi n parent.MenuItems tempMi.Checked = false nainte item.Checked = True End Sub Private Sub mnuMerge_Click ( ByVal expeditor Ca System.Object, ByVal e Dim element Ca MenuItem = Ctype ( expeditor, MenuItem ) item.Parent.MergeMenu ( mnuMenu2 ) End Sub End Class ca

ca

Sy

Syste

Original

Imports System.Windows.Forms public class RadioButtonCheckBox public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class MDIChild Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox Friend WithEvents mainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents mnuMDIOptions As System.Windows.Forms.MenuItem

Friend WithEvents mnuMDIOpiton1 As System.Windows.Forms.MenuItem Friend WithEvents mnuMDIOpiton2 As System.Windows.Forms.MenuItem Friend WithEvents mnuMDIOpiton3 As System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.RichTextBox1 = New System.Windows.Forms.RichTextBox() Me.mainMenu1 = New System.Windows.Forms.MainMenu() Me.mnuMDIOptions = New System.Windows.Forms.MenuItem() Me.mnuMDIOpiton1 = New System.Windows.Forms.MenuItem() Me.mnuMDIOpiton2 = New System.Windows.Forms.MenuItem() Me.mnuMDIOpiton3 = New System.Windows.Forms.MenuItem() Me.SuspendLayout() ' 'RichTextBox1 ' Me.RichTextBox1.Name = "RichTextBox1" Me.RichTextBox1.Size = New System.Drawing.Size(296, 176) Me.RichTextBox1.TabIndex = 0 Me.RichTextBox1.Text = "RichTextBox1" ' 'mainMenu1 ' Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMDIOp ' 'mnuMDIOptions ' Me.mnuMDIOptions.Index = 0 Me.mnuMDIOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuM Me.mnuMDIOptions.MergeOrder = 1 Me.mnuMDIOptions.Text = "MDIChildOptions" ' 'mnuMDIOpiton1 ' Me.mnuMDIOpiton1.Index = 0 Me.mnuMDIOpiton1.Text = "MDI Option 1" ' 'mnuMDIOpiton2 ' Me.mnuMDIOpiton2.Index = 1 Me.mnuMDIOpiton2.Text = "MDI Option 2" ' 'mnuMDIOpiton3 ' Me.mnuMDIOpiton3.Index = 2 Me.mnuMDIOpiton3.Text = "MDI Option 3" ' 'MDIChild ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 174) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.RichTextBox1}) Me.Menu = Me.mainMenu1 Me.Name = "MDIChild" Me.Text = "MDIChild" Me.ResumeLayout(False) End Sub

#End Region Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuMDIOpiton1.Click, mnuMDIOpiton2.Click, mnuMDIOpiton3.Click Dim item As MenuItem = CType(sender, MenuItem)

item.Checked = Not item.Checked End Sub End Class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents mainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents mnuFile As System.Windows.Forms.MenuItem Friend WithEvents mnuNew As System.Windows.Forms.MenuItem Friend WithEvents mnuFileOpen As System.Windows.Forms.MenuItem Friend WithEvents mnuFileClose As System.Windows.Forms.MenuItem Friend WithEvents mnuFileSave As System.Windows.Forms.MenuItem Friend WithEvents mnuFileSaveAs As System.Windows.Forms.MenuItem Friend WithEvents mnuEdit As System.Windows.Forms.MenuItem Friend WithEvents mnuEditCopy As System.Windows.Forms.MenuItem Friend WithEvents mnuEditPaste As System.Windows.Forms.MenuItem Friend WithEvents mnuOptions As System.Windows.Forms.MenuItem Friend WithEvents mnuOption1 As System.Windows.Forms.MenuItem Friend WithEvents mnuOption2 As System.Windows.Forms.MenuItem Friend WithEvents mnuOption3 As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOptions As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOption1 As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOption2 As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOption3 As System.Windows.Forms.MenuItem Friend WithEvents mnuWindow As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu1 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu11 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu12 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu13 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu14 As System.Windows.Forms.MenuItem

Friend WithEvents mnuMerge As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu2 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu21 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu22 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu23 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu24 As System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.mainMenu1 = New System.Windows.Forms.MainMenu() Me.mnuFile = New System.Windows.Forms.MenuItem() Me.mnuNew = New System.Windows.Forms.MenuItem() Me.mnuFileOpen = New System.Windows.Forms.MenuItem() Me.mnuFileClose = New System.Windows.Forms.MenuItem() Me.mnuFileSave = New System.Windows.Forms.MenuItem() Me.mnuFileSaveAs = New System.Windows.Forms.MenuItem() Me.mnuEdit = New System.Windows.Forms.MenuItem() Me.mnuEditCopy = New System.Windows.Forms.MenuItem() Me.mnuEditPaste = New System.Windows.Forms.MenuItem() Me.mnuOptions = New System.Windows.Forms.MenuItem() Me.mnuOption1 = New System.Windows.Forms.MenuItem() Me.mnuOption2 = New System.Windows.Forms.MenuItem() Me.mnuOption3 = New System.Windows.Forms.MenuItem() Me.mnuRadioOptions = New System.Windows.Forms.MenuItem() Me.mnuRadioOption1 = New System.Windows.Forms.MenuItem() Me.mnuRadioOption2 = New System.Windows.Forms.MenuItem() Me.mnuRadioOption3 = New System.Windows.Forms.MenuItem() Me.mnuWindow = New System.Windows.Forms.MenuItem() Me.mnuMenu1 = New System.Windows.Forms.MenuItem() Me.mnuMenu11 = New System.Windows.Forms.MenuItem() Me.mnuMenu12 = New System.Windows.Forms.MenuItem() Me.mnuMenu13 = New System.Windows.Forms.MenuItem() Me.mnuMenu14 = New System.Windows.Forms.MenuItem() Me.mnuMerge = New System.Windows.Forms.MenuItem() Me.mnuMenu2 = New System.Windows.Forms.MenuItem() Me.mnuMenu21 = New System.Windows.Forms.MenuItem() Me.mnuMenu22 = New System.Windows.Forms.MenuItem() Me.mnuMenu23 = New System.Windows.Forms.MenuItem() Me.mnuMenu24 = New System.Windows.Forms.MenuItem() ' 'mainMenu1 ' Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, ' 'mnuFile ' Me.mnuFile.Index = 0 Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNew, Me Me.mnuFile.Text = "File" ' 'mnuNew ' Me.mnuNew.Index = 0 Me.mnuNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN Me.mnuNew.Text = "&New" ' 'mnuFileOpen ' Me.mnuFileOpen.Index = 1 Me.mnuFileOpen.Text = "Open" ' 'mnuFileClose '

Me.mnuFileClose.Index = 2 Me.mnuFileClose.Text = "Close" ' 'mnuFileSave ' Me.mnuFileSave.Index = 3 Me.mnuFileSave.Text = "Save" ' 'mnuFileSaveAs ' Me.mnuFileSaveAs.Index = 4 Me.mnuFileSaveAs.Text = "Save&As" ' 'mnuEdit ' Me.mnuEdit.Index = 1 Me.mnuEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEditCop Me.mnuEdit.Text = "Edit" ' 'mnuEditCopy ' Me.mnuEditCopy.Index = 0 Me.mnuEditCopy.Text = "&Copy" ' 'mnuEditPaste ' Me.mnuEditPaste.Index = 1 Me.mnuEditPaste.Text = "Paste" ' 'mnuOptions ' Me.mnuOptions.Index = 2 Me.mnuOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpti Me.mnuOptions.Text = "Options" ' 'mnuOption1 ' Me.mnuOption1.Index = 0 Me.mnuOption1.Text = "Option1" ' 'mnuOption2 ' Me.mnuOption2.Index = 1 Me.mnuOption2.Text = "Option2" ' 'mnuOption3 ' Me.mnuOption3.Index = 2 Me.mnuOption3.Text = "Option3" ' 'mnuRadioOptions ' Me.mnuRadioOptions.Index = 3 Me.mnuRadioOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mn Me.mnuRadioOptions.Text = "Radio Options" ' 'mnuROption1 ' Me.mnuRadioOption1.Index = 0 Me.mnuRadioOption1.RadioCheck = True Me.mnuRadioOption1.Text = "Radio Option 1"

' 'mnuROption2 ' Me.mnuRadioOption2.Index = 1 Me.mnuRadioOption2.RadioCheck = True Me.mnuRadioOption2.Text = "Radio Option 2" ' 'mnuROption3 ' Me.mnuRadioOption3.Index = 2 Me.mnuRadioOption3.RadioCheck = True Me.mnuRadioOption3.Text = "Radio Option 3" ' 'mnuWindow ' Me.mnuWindow.Index = 4 Me.mnuWindow.MdiList = True Me.mnuWindow.MergeOrder = 99 Me.mnuWindow.Text = "&Window" ' 'mnuMenu1 ' Me.mnuMenu1.Index = 5 Me.mnuMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMenu11 Me.mnuMenu1.Text = "Menu 1" ' 'mnuMenu11 ' Me.mnuMenu11.Index = 0 Me.mnuMenu11.MergeOrder = 1 Me.mnuMenu11.Text = "Menu 1.1" ' 'mnuMenu12 ' Me.mnuMenu12.Index = 1 Me.mnuMenu12.MergeOrder = 2 Me.mnuMenu12.Text = "Menu 1.2" ' 'mnuMenu13 ' Me.mnuMenu13.Index = 2 Me.mnuMenu13.MergeOrder = 3 Me.mnuMenu13.Text = "Menu 1.3" ' 'mnuMenu14 ' Me.mnuMenu14.Index = 3 Me.mnuMenu14.MergeOrder = 4 Me.mnuMenu14.Text = "Menu 1.4" ' 'mnuMerge ' Me.mnuMerge.Index = 4 Me.mnuMerge.MergeOrder = 99 Me.mnuMerge.Text = "Merge!" ' 'mnuMenu2 ' Me.mnuMenu2.Index = 6 Me.mnuMenu2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMenu21 Me.mnuMenu2.Text = "Menu 2"

' 'mnuMenu21 ' Me.mnuMenu21.Index = 0 Me.mnuMenu21.MergeOrder = 1 Me.mnuMenu21.Text = "Menu 2.1" ' 'mnuMenu22 ' Me.mnuMenu22.Index = 1 Me.mnuMenu22.MergeOrder = 2 Me.mnuMenu22.MergeType = System.Windows.Forms.MenuMerge.Replace Me.mnuMenu22.Text = "Menu 2.2" ' 'mnuMenu23 ' Me.mnuMenu23.Index = 2 Me.mnuMenu23.MergeOrder = 3 Me.mnuMenu23.MergeType = System.Windows.Forms.MenuMerge.Remove Me.mnuMenu23.Text = "Menu 2.3" ' 'mnuMenu24 ' Me.mnuMenu24.Index = 3 Me.mnuMenu24.MergeOrder = 5 Me.mnuMenu24.Text = "Menu 2.4" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(456, 146) Me.IsMdiContainer = True Me.Menu = Me.mainMenu1 Me.Name = "Form1" Me.Text = "Form1" End Sub #End Region

Private Sub mnuNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNew.Click Dim newMDIChild As New MDIChild() newMDIChild.MdiParent = Me newMDIChild.Show() End Sub

Private Sub mnuFileOpen_Click(ByVal sender As System.Object, ByVal e As System.Event Handles mnuFileOpen.Click MessageBox.Show("You clicked file open!", _ "Menu event tester", _ MessageBoxButtons.OK, _ MessageBoxIcon.Information) End Sub

Private Sub mnuFileClose_Click(ByVal sender As System.Object, ByVal e As System.Even Handles mnuFileClose.Click MessageBox.Show("You clicked file close!", "Menu event tester", MessageBoxButton End Sub

Private Sub mnuEditCopy_Click(ByVal sender As System.Object, ByVal e As System.Event Handles mnuEditCopy.Click MessageBox.Show("You clicked Edit copy!", "Menu event tester", MessageBoxButtons End Sub

Private Sub mnuEditPaste_Click(ByVal sender As System.Object, ByVal e As System.Even Handles mnuEditPaste.Click MessageBox.Show("You clicked Edit paste!", "Menu event tester", MessageBoxButton End Sub

Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOption1.Click, mnuOption2.Click, mnuOption3.Click Dim item As MenuItem = CType(sender, MenuItem) item.Checked = Not item.Checked End Sub Private Handles Dim Dim Dim For

Sub RadioOption_Click(ByVal sender As System.Object, ByVal e As System.Event mnuRadioOption1.Click, mnuRadioOption2.Click, mnuRadioOption3.Click item As MenuItem = CType(sender, MenuItem) parent As Menu = item.Parent tempMi As MenuItem Each tempMi In parent.MenuItems tempMi.Checked = False

Next item.Checked = True End Sub

Private Sub mnuMerge_Click(ByVal sender As System.Object, ByVal e As System.EventArg Dim item As MenuItem = CType(sender, MenuItem) item.Parent.MergeMenu(mnuMenu2) End Sub End Class

Valoarea 14.8.1.Add a verificat lista Box

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class CheckBoxListAddValueSelectionEvent public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents CheckedListBox1 Ca System.Windows.Forms.CheckedListBox prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.CheckedListBox1 = New System.Windows.Forms.CheckedListBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Ch eckedListBox1 ' Me.CheckedListBox1.CheckOnClick = True Me.CheckedListBox1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , Me.CheckedListBox1.Location = New System.Drawing.Point ( 96 , 6 ) Me.CheckedListBox1.Name = "CheckedListBox1" Me.CheckedListBox1.Size = New System.Drawing.Size ( 120 , 150 ) Me.CheckedListBox1.TabIndex = 0 " "Te xtBox1 ' Me.TextBox1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , Me.TextBox1.Location = New System.Drawing.Point ( 16 , 184 ) Me.TextBox1.Name = "TextBox1" Ca apel

Bool

8.

8,25 !, S

Me.TextBox1.Size = New System.Drawing.Size ( 296 , 20 ) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "TextBox1" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 15 , 37 ) Me.ClientSize = New System.Drawing.Size ( 336 , 229 ) Me.Controls.Add ( Me.TextBox1 ) Me.Controls.Add ( Me.CheckedListBox1 ) Me.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

24.0 !, System.Dra

Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e CheckedListBox1.Items.Add ( "punctul 1" , Adevrat ) CheckedListBox1.Items.Add ( "punctul 2" , adevrat ) CheckedListBox1. Items.Add ( "punctul 3" , adevrat ) CheckedListBox1.Items.Add ( "punctul 4" , False ) CheckedListBox1.Items.Add ( "punctul 5" , adevrat ) CheckedListBox1.Items.Add ( "punctul 6" , adevrat ) CheckedListBox1.Items.Add ( "punctul 7" , adevrat ) CheckedListBox1.Items.Add ( "punctul 8" , False ) CheckedListBox1.Items.Add ( "punctul 9" , adevrat ) CheckedListBox1.Items.Add ( "punctul 10" , Adevraii ) CheckedListBox1.Items.Add ( "punctul 11" , adevrat ) End Sub

ca

System.Ev

Sub privat CheckedListBox1_ItemCheck ( expeditor ByVal Ca obiect, e ByVal Select Case e.NewValue caz CheckState.Checked TextBox1.Text = "Ai verificat articol" & e.Index Case CheckState.Unchecked TextBox1.Text = "Ai produs nenregistrat" & e.Index End Select End Sub End Class

Ca

Sy

Ortiginal

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class CheckBoxListAddValueSelectionEvent public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents CheckedListBox1 As System.Windows.Forms.CheckedListBox Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.CheckedListBox1 = New System.Windows.Forms.CheckedListBox

Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'CheckedListBox1 ' Me.CheckedListBox1.CheckOnClick = True Me.CheckedListBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, Me.CheckedListBox1.Location = New System.Drawing.Point(96, 6) Me.CheckedListBox1.Name = "CheckedListBox1" Me.CheckedListBox1.Size = New System.Drawing.Size(120, 150) Me.CheckedListBox1.TabIndex = 0

' 'TextBox1 ' Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System Me.TextBox1.Location = New System.Drawing.Point(16, 184) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(296, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "TextBox1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(15, 37) Me.ClientSize = New System.Drawing.Size(336, 229) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.CheckedListBox1) Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.Drawing. Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Form1_Load(ByVal sender CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item End Sub

As System.Object, ByVal e As System.EventArgs) H 1", True) 2", True) 3", True) 4", False) 5", True) 6", True) 7", True) 8", False) 9", True) 10", True) 11", True)

Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Wind Select Case e.NewValue Case CheckState.Checked TextBox1.Text = "You checked Item " & e.Index Case CheckState.Unchecked TextBox1.Text = "You unchecked Item " & e.Index End Select End Sub

End Class

Lista 14.8.2.Checked Box eveniment selecie

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class CheckBoxListAddValueSelectionEvent public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Ca apel

Bool

"Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents CheckedListBox1 Ca System.Windows.Forms.CheckedListBox prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.CheckedListBox1 = New System.Windows.Forms.CheckedListBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Ch eckedListBox1 ' Me.CheckedListBox1.CheckOnClick = True Me.CheckedListBox1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , Me.CheckedListBox1.Location = New System.Drawing.Point ( 96 , 6 ) Me.CheckedListBox1.Name = "CheckedListBox1" Me.CheckedListBox1.Size = New System.Drawing.Size ( 120 , 150 ) Me.CheckedListBox1.TabIndex = 0

8.

" "Te xtBox1 ' Me.TextBox1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 8,25 !, S Me.TextBox1.Location = New System.Drawing.Point ( 16 , 184 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 296 , 20 ) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "TextBox1" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 15 , 37 ) Me.ClientSize = New System.Drawing.Size ( 336 , 229 ) Me.Controls.Add ( Me.TextBox1 ) Me.Controls.Add ( Me.CheckedListBox1 ) Me.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 24.0 !, System.Dra Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea ca

Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e CheckedListBox1.Items.Add ( "punctul 1" , Adevrat ) CheckedListBox1.Items.Add ( "punctul 2" , adevrat ) CheckedListBox1. Items.Add ( "punctul 3" , adevrat ) CheckedListBox1.Items.Add ( "punctul 4" , False ) CheckedListBox1.Items.Add ( "punctul 5" , adevrat ) CheckedListBox1.Items.Add ( "punctul 6" , adevrat ) CheckedListBox1.Items.Add ( "punctul 7" , adevrat ) CheckedListBox1.Items.Add ( "punctul 8" , False ) CheckedListBox1.Items.Add ( "punctul 9" , adevrat ) CheckedListBox1.Items.Add ( "punctul 10" , Adevraii ) CheckedListBox1.Items.Add ( "punctul 11" , adevrat )

System.Ev

End Sub Sub privat CheckedListBox1_ItemCheck ( expeditor ByVal Ca obiect, e ByVal Select Case e.NewValue caz CheckState.Checked TextBox1.Text = "Ai verificat articol" & e.Index Case CheckState.Unchecked TextBox1.Text = "Ai produs nenregistrat" & e.Index End Select End Sub End Class Ca

Sy

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class CheckBoxListAddValueSelectionEvent public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call

End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents CheckedListBox1 As System.Windows.Forms.CheckedListBox Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.CheckedListBox1 = New System.Windows.Forms.CheckedListBox

Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'CheckedListBox1 ' Me.CheckedListBox1.CheckOnClick = True Me.CheckedListBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, Me.CheckedListBox1.Location = New System.Drawing.Point(96, 6) Me.CheckedListBox1.Name = "CheckedListBox1" Me.CheckedListBox1.Size = New System.Drawing.Size(120, 150) Me.CheckedListBox1.TabIndex = 0

' 'TextBox1 ' Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System Me.TextBox1.Location = New System.Drawing.Point(16, 184) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(296, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "TextBox1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(15, 37) Me.ClientSize = New System.Drawing.Size(336, 229) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.CheckedListBox1) Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.Drawing. Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H

CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item CheckedListBox1.Items.Add("Item End Sub

1", True) 2", True) 3", True) 4", False) 5", True) 6", True) 7", True) 8", False) 9", True) 10", True) 11", True)

Private Sub CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Wind Select Case e.NewValue Case CheckState.Checked TextBox1.Text = "You checked Item " & e.Index Case CheckState.Unchecked TextBox1.Text = "You unchecked Item " & e.Index End Select End Sub End Class

CheckedListBox: Adugarea de elemente, pentru a primi obiectele

Importurile

System.Windows.Forms

public class CheckedListBoxAddItemGetSelected public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Motenete System.Windows.Forms.Form

# Region

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents btnAddItems Ca System.Windows.Forms.Button prieten WithEvents clb1 Ca System.Windows.Forms.CheckedListBox prieten WithEvents btnGetCheckedIndices Ca System.Windows.Forms.Button prieten WithEvents btnGetCheckedItems Ca System.Windows.Forms.Button prieten WithEvents ColorDialog1 Ca System.Windows.Forms.ColorDialog <System.Diagnostics.DebuggerStepThrough () > privat Sub InitializeComponent () Me.btnAddItems = New System.Windows.Forms.Button () Me.clb1 = New System.Windows.Forms.CheckedListBox () Me.btnGetCheckedItems = New System.Windows.Forms.Button () Me.btnGetCheckedIndices = nou System.Windows.Forms.Button () Me.ColorDialog1 = New System.Windows.Forms.ColorDialog () Me.SuspendLayout () " "bt nAddItems ' Me.btnAddItems.BackColor = System.Drawing.SystemColors.ControlLight Me.btnAddItems . Locaie = New System.Drawing.Point ( 176 , 8 ) Me.btnAddItems.Name = "btnAddItems" Me.btnAddItems.Size = New System.Drawing.Size ( 104 , 24 ) Me.btnAddItems.TabIndex = 3 Me.btnAddItems . Text = "Adaug produse" " "cl B1 ' Me.clb1.Location = New System.Drawing.Point ( 16 , 8 ) Me.clb1.Name = "clb1" Me.clb1.Size = New System.Drawing.Size ( 144 , 79 ) Me.clb1.TabIndex = 4 ' 'bt nGetCheckedItems ' Me.btnGetCheckedItems.BackColor = System.Drawing.SystemColors.ControlLight Me.btnGetCheckedItems.Location = New System.Drawing.Point ( 176 , 40 ) Ca apel

Bool

Me.btnGetCheckedItems . Nume = "btnGetCheckedItems" Me.btnGetCheckedItems.Size = New System.Drawing.Size ( 104 , 24 ) Me.btnGetCheckedItems.TabIndex = 5 Me.btnGetCheckedItems.Text = "Verificat de ctre postul" " "bt nGetCheckedIndices " Me.btnGetCheckedIndices. BackColor = System.Drawing.SystemColors.ControlLight Me.btnGetCheckedIndices.Location = New System.Drawing.Point ( 176 , 72 ) Me.btnGetCheckedIndices.Name = "btnGetCheckedIndices" Me.btnGetCheckedIndices.Size = New System.Drawing.Size ( 104 , 24 ) Me.btnGetCheckedIndices.TabIndex = 6 Me.btnGetCheckedIndices.Text = "Verificat de start a" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 296 , 277 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.btnGetCheckedInd Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub btnAddItems_Click ( ByVal expeditor clb1.Items.Add ( "A" , adevrat ) clb1.Items.Add ( "B" , adevrat ) clb1.Items. Adauga ( "C" , adevrat ) clb1.Items.Add ( "D" , Fals ) Sub End

Sy

Private Sub btnGetCheckedItems_Click ( ByVal expeditor Dim o ca obiect Pentru fiecare o n clb1.CheckedItems Console.WriteLine ( o.ToString ) nainte o End Sub Private Sub btnGetCheckedIndices_Click ( ByVal expeditor Dim o ca obiect Pentru fiecare o n clb1.CheckedIndices Console.WriteLine ( o ) nainte o End Sub End Class

Ca

System.Object, ByVal e

Ca

System.Object, ByVal

Originar

Imports System.Windows.Forms public class CheckedListBoxAddItemGetSelected public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents btnAddItems As System.Windows.Forms.Button Friend WithEvents clb1 As System.Windows.Forms.CheckedListBox

Friend WithEvents btnGetCheckedIndices As System.Windows.Forms.Button Friend WithEvents btnGetCheckedItems As System.Windows.Forms.Button Friend WithEvents ColorDialog1 As System.Windows.Forms.ColorDialog <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.btnAddItems = New System.Windows.Forms.Button() Me.clb1 = New System.Windows.Forms.CheckedListBox() Me.btnGetCheckedItems = New System.Windows.Forms.Button() Me.btnGetCheckedIndices = New System.Windows.Forms.Button() Me.ColorDialog1 = New System.Windows.Forms.ColorDialog() Me.SuspendLayout() ' 'btnAddItems ' Me.btnAddItems.BackColor = System.Drawing.SystemColors.ControlLight Me.btnAddItems.Location = New System.Drawing.Point(176, 8) Me.btnAddItems.Name = "btnAddItems" Me.btnAddItems.Size = New System.Drawing.Size(104, 24) Me.btnAddItems.TabIndex = 3 Me.btnAddItems.Text = "Add Items" ' 'clb1 ' Me.clb1.Location = New System.Drawing.Point(16, 8) Me.clb1.Name = "clb1" Me.clb1.Size = New System.Drawing.Size(144, 79) Me.clb1.TabIndex = 4 ' 'btnGetCheckedItems ' Me.btnGetCheckedItems.BackColor = System.Drawing.SystemColors.ControlLight Me.btnGetCheckedItems.Location = New System.Drawing.Point(176, 40) Me.btnGetCheckedItems.Name = "btnGetCheckedItems" Me.btnGetCheckedItems.Size = New System.Drawing.Size(104, 24) Me.btnGetCheckedItems.TabIndex = 5 Me.btnGetCheckedItems.Text = "Checked by Item" ' 'btnGetCheckedIndices ' Me.btnGetCheckedIndices.BackColor = System.Drawing.SystemColors.ControlLight Me.btnGetCheckedIndices.Location = New System.Drawing.Point(176, 72) Me.btnGetCheckedIndices.Name = "btnGetCheckedIndices" Me.btnGetCheckedIndices.Size = New System.Drawing.Size(104, 24) Me.btnGetCheckedIndices.TabIndex = 6 Me.btnGetCheckedIndices.Text = "Checked by Index" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(296, 277) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnGetCheckedIndices Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub btnAddItems_Click(ByVal sender As System.Object, ByVal e As System.Event clb1.Items.Add("A", True) clb1.Items.Add("B", True)

clb1.Items.Add("C", True) clb1.Items.Add("D", False) End Sub

Private Sub btnGetCheckedItems_Click(ByVal sender As System.Object, ByVal e As Syste Dim o As Object For Each o In clb1.CheckedItems Console.WriteLine(o.ToString) Next o End Sub

Private Sub btnGetCheckedIndices_Click(ByVal sender As System.Object, ByVal e As Sys Dim o As Object For Each o In clb1.CheckedIndices Console.WriteLine(o) Next o End Sub End Class

14.8.4.Using casetele list verificate pentru a aduga elemente la

Importurile

System.Windows.Forms

public class CheckedListBoxAddRemove public comun Sub principal Application.Run ( New FrmCheckedListBox ) End Sub End clasa Public class FrmCheckedListBox Motenete Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub apel

"Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "L ist din disponibila carte titluri prieten WithEvents chklstInput Ca CheckedListBox "U ser selecie lista prieten WithEvents lstDisplay Ca ListBox

Ca

Boole

"Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . chklstInput = New System.Windows.Forms.CheckedListBox () Me.lstDisplay = New System.Windows.Forms.ListBox () Me.SuspendLayout () " "ch klstInput " Me.chklstInput.HorizontalScrollbar = true Me.chklstInput.Items. AddRange ( Object Nou () { "A" , "B" , "C" , "D" , "E" , Me.chklstInput.Location = New System.Drawing . Punctul ( 16 , 16 ) Me.chklstInput.Name = "chklstInput" Me.chklstInput.Size = New System.Drawing.Size ( 152 , 124 ) Me.chklstInput.TabIndex = 1 ' 'ls tDisplay " Me.lstDisplay.Anchor = ( System.Windows.Forms.AnchorStyles.Top Sau System.Windows Me.lstDisplay.HorizontalScrollbar = True Me.lstDisplay.Location = New System.Drawing.Point ( 184 , 16 ) Me.lstDisplay. name = "lstDisplay" Me.lstDisplay.Size = New System.Drawing.Size ( 128 , 121 ) Me.lstDisplay.TabIndex = 2 ' "Parintele mCheckedListBox ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me . ClientSize = New System.Drawing.Size ( 328 , 157 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.lstDisplay, Me.chk Me.Name = "FrmCheckedListBox" Me.Text = "Lista de Box Test de verificat" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

Private Sub chklstInput_ItemCheck _ ( expeditor ByVal Ca System.Object, _

ByVal e ca System.Windows.Forms.ItemCheckEventArgs ) Manere chklstInput.ItemCheck Dim element Ca String = chklstInput.SelectedItem

Dac e.NewValue = CheckState.Checked Apoi lstDisplay.Items.Add ( element ) Else lstDisplay.Items.Remove ( element ) End If End Sub End Class

Original

Imports System.Windows.Forms public class CheckedListBoxAddRemove public Shared Sub Main Application.Run(New FrmCheckedListBox) End Sub End class Public Class FrmCheckedListBox Inherits Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then

components.Dispose() End If End If MyBase.Dispose(disposing) End Sub ' list of available book titles Friend WithEvents chklstInput As CheckedListBox ' user selection list Friend WithEvents lstDisplay As ListBox 'Required by the Windows Form Designer Private components As System.ComponentModel.Container

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.chklstInput = New System.Windows.Forms.CheckedListBox() Me.lstDisplay = New System.Windows.Forms.ListBox() Me.SuspendLayout() ' 'chklstInput ' Me.chklstInput.HorizontalScrollbar = True Me.chklstInput.Items.AddRange(New Object() {"A", "B", "C", "D", "E", "F", "G", "H" Me.chklstInput.Location = New System.Drawing.Point(16, 16) Me.chklstInput.Name = "chklstInput" Me.chklstInput.Size = New System.Drawing.Size(152, 124) Me.chklstInput.TabIndex = 1 ' 'lstDisplay ' Me.lstDisplay.Anchor = (System.Windows.Forms.AnchorStyles.Top Or System.Windows.Fo Me.lstDisplay.HorizontalScrollbar = True Me.lstDisplay.Location = New System.Drawing.Point(184, 16) Me.lstDisplay.Name = "lstDisplay" Me.lstDisplay.Size = New System.Drawing.Size(128, 121) Me.lstDisplay.TabIndex = 2 ' 'FrmCheckedListBox ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(328, 157) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lstDisplay, Me.chklstI Me.Name = "FrmCheckedListBox" Me.Text = "Checked List Box Test" Me.ResumeLayout(False) End Sub #End Region Private Sub chklstInput_ItemCheck _ (ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.ItemCheckEventArgs) _ Handles chklstInput.ItemCheck Dim item As String = chklstInput.SelectedItem

If e.NewValue = CheckState.Checked Then lstDisplay.Items.Add(item) Else lstDisplay.Items.Remove(item) End If End Sub End Class

ListView Demo

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ListViewIllustration public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Private Sub btnPopulate_Click ( ByVal expeditor Dim intWidth Ca Integer Dim objItem Ca ListViewItem "Se t implicit vizualizare. ListView1.View = View.Details

Ca

System.Object, ByVal e

ca

Sy

optDetails.Checked = True "Anuntul d anteturile de coloan. intWidth = ListView1.Width - 5 ListView1.Columns.Add ( "Name" , CInt ( intWidth / 4 )) ListView1.Columns.Add ( "Adresa" , CInt ( intWidth / 4 )) ListView1. Columns.Add ( "telefon" , CInt ( intWidth / 4 )) ListView1.Columns.Add ( "FAX" , CInt ( intWidth / 4 )) "Anuntul d unele vedere elementele de list. objItem = ListView1.Items.Add ( "AAAAA" ) Cu objItem . SubItems.Add ( "123 Main St" ) . SubItems.Add ( "555-555-5555" ) . sub articole. Adauga ( "555-555-5555" ) . ImageIndex = 0 End Cu objItem = ListView1.Items.Add ( "bbbbb" ) Cu objItem . SubItems.Add ( "456 Main St" ) . SubItems.Add ( "555-555-5555" ) . SubItems.Add ( "555-555-5555 " ) . ImageIndex = 0 End Cu End Sub Private Sub Dim Dim btnAdd_Click ( ByVal expeditor Ca String ListViewItem Ca System.Object, ByVal e ca

System.

strItemText objItem Ca

"Anuntul d unele elemente de vizualizare list. strItemText = "Nume:" objItem = ListView1.Items.Add ( strItemText ) Cu objItem . SubItems.Add ( "123 Unele Sf." ) . SubItems.Add ( "555-555-5555" ) . SubItems.Add ( "555-555-5555" ) . ImageIndex = 0 End Cu End Sub Private Sub btnClear_Click ( ByVal expeditor ListView1.Items.Clear () End Sub Private Sub Dim btnRemove_Click ( ByVal expeditor Ca ListViewItem Ca System.Object, ByVal e ca

Syste

Ca

System.Object, ByVal e

ca

Syst

objListItem

Pentru fiecare objListItem n ListView1.SelectedItems objListItem.Remove () objListItem urmtoare End Sub Private Sub btnDisplayItem_Click ( ByVal expeditor Ca System.Object, ByVal e ca

Dim Dim Dac

strMessage Ca String objListItem Ca ListViewItem

ListView1.SelectedItems.Count> 0 Apoi objListItem = ListView1.SelectedItems ( 0 ) Cu objListItem strMessage = "NUME:" & Text & vbCrLf & _. "Adresa:" . i sub articole ( 1 ) . Text & vbCrLf & _ "PHONE : " . i sub articole ( 2 ) Text & vbCrLf & _. "FAX:" . i sub articole ( 3 ) . Text End Cu MsgBox ( strMessage ) End If End Sub Private Sub optLargeIcon_CheckedChanged ( expeditor ByVal ListView1.View = View.LargeIcon End Sub Private Sub optSmallIcon_CheckedChanged ( expeditor ByVal ListView1.View = View.SmallIcon End Sub Sub Private optList_CheckedChanged ( expeditor ByVal ListView1.View = View.List End Sub Sub Private optTile_CheckedChanged ( expeditor ByVal ListView1.View = View.Tile End Sub Ca Ca

System.Object, ByVal

Ca

System.Object, ByVal

System.Object, ByVal e

Ca

System.Object, ByVal e

Private Sub optDetails_CheckedChanged ( expeditor ByVal ListView1.View = View.Details End Sub Clasa sfritul parial publice clasa Form1 Motenete System.Windows.Forms.Form <System.Diagnostics.DebuggerNonUserCode () > _ Public Sub New () MyBase.New ()

Ca

System.Object, ByVal e

"Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.components = New System.ComponentModel.Container Me.ListView1 = New System.Windows.Forms.ListView Me.btnPopulate = New System.Windows.Forms.Button Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.optDetails = New System.Windows.Forms.RadioButton Me.optTile = New System.Windows.Forms.RadioButton Me.optList = New System.Windows.Forms.RadioButton Me.optSmallIcon = New System.Windows.Forms.RadioButton Me.optLargeIcon = Sistem Windows.Forms.RadioButton. Me.btnAdd = New System.Windows.Forms.Button Me.btnRemove = New System.Windows.Forms.Button Me.btnClear = New System.Windows.Forms.Button Me.btnDisplayItem = Nou

= True Me.ListView1.Location = New System.Drawing.Point ( 17 , 18 ) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size ( 342 , 364 ) Me.ListView1.TabIndex = 0 Me.ListView1.UseCompatibleStateImageBehavior = False ' 'bt nPopulate ' Me.btnPopulate.Location = New System.Drawing.Point ( 366 , 239 ) Me.btnPopulate.Name = "btnPopulate" Me.btnPopulate.Size = New System.Drawing . Dimensiuni ( 161 , 23 ) Me.btnPopulate.TabIndex = 2 Me.btnPopulate.Text

= New System.Drawing.Point ( 370 , 13 ) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size ( 156 , 166 ) Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = false Me.GroupBox1.Text = "opinii" " "op tDetails ' Me.optDetails.AutoSize = True Me.optDetails.Location = New System.Drawing.Point ( 30 , 126 ) Me.optDetails.Name = "optDetails" Me optDetails.Size = New System.Drawing.Size. ( 57 , 17 ) Me.optDetails.TabIndex = 4 Me.optDetails.Text = "Detalii" "

"op tTile ' Me.optTile.AutoSize = True Me.optTile.Location = New System.Drawing.Point ( 30 , 102 ) Me.optTile.Name = "optTile" Me.optTile.Size = New System.Drawing.Size ( 42 , 17 ) Me.optTile.TabIndex = 3 Me.optTile.Text = "placi" " "op TList ' Me.optList.AutoSize = True Me.optList.Location = New System.Drawing.Point ( 30 , 78 ) Me.optList.Name = "optList" Me.optList.Size = Sistem. Drawing.Size ( 41 , 17 ) Me.optList.TabIndex = 2 Me.optList.Text = "Lista" " "op tSmallIcon ' Me.optSmallIcon.AutoSize = True Me.optSmallIcon.Location = New System.Drawing.Point ( 30 , 54 ) Me.optSmallIcon.Name = "optSmallIcon" Me.optSmallIcon.Size = New System.Drawing.Size ( 79 , 17 ) Me.optSmallIcon.TabIndex = 1 Me.optSmallIcon.Text = "Icoane mici" " "op tLargeIcon " Me.optLargeIcon.AutoSize = True Me.optLargeIcon.Location = New System.Drawing.Point ( 30 , 30 ) Me.optLargeIcon.Name = "optLargeIcon" Me.optLargeIcon.Size = New System.Drawing.Size ( 81 , 17 ) Me.optLargeIcon.TabIndex = 0 Me.optLargeIcon.Text = "Pictograme mari" " "bt Nadd ' Me.btnAdd.Location = New System.Drawing.Point ( 365 , 269 ) Me.btnAdd.Name = "btnAdd" Me . btnAdd.Size = New System.Drawing.Size ( 161 , 23 ) Me.btnAdd.TabIndex = 3 Me.btnAdd.Text = "Add" " "bt nRemove ' Me.btnRemove.Location = New System.Drawing.Point ( 366 , 299 ) Me.btnRemove.Name = "btnRemove" Me.btnRemove.Size = New System.Drawing.Size ( 161 , 23 ) Me.btnRemove.TabIndex = 4 Me.btnRemove.Text = "terge" " "bt nClear " Me.btnClear.Location = New System.Drawing.Point ( 365 , 329 ) Me.btnClear.Name = "btnClear" Me.btnClear.Size = New System.Drawing.Size ( 161 , 23 ) Me.btnClear.TabIndex = 5 Me.btnClear.Text = "Clear" " "bt nDisplayItem

' Me.btnDisplayItem.Location = New System.Drawing.Point ( 365 , Me.btnDisplayItem.Name = "btnDisplayItem" Me.btnDisplayItem.Size = Sistem. Drawing.Size ( 161 , 23 ) Me.btnDisplayItem.TabIndex = 6 Me.btnDisplayItem.Text = "afiat al elementului" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

359 )

= "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "ListView" Me.GroupBox1.ResumeLayout ( Fals ) Me.GroupBox1.PerformLayout () Me.ResumeLayout ( Fals ) End Sub prieten WithEvents ListView1 Ca System.Windows.Forms.ListView prieten WithEvents btnPopulate Ca System.Windows.Forms.Button prieten WithEvents GroupBox1 Ca System.Windows.Forms.GroupBox prieten WithEvents optDetails Ca System.Windows.Forms.RadioButton prieten WithEvents optTile Ca System.Windows.Forms.RadioButton prieten WithEvents optList Ca System.Windows.Forms.RadioButton prieten WithEvents optSmallIcon Ca System.Windows.Forms.RadioButton prieten WithEvents optLargeIcon Ca System.Windows.Forms.RadioButton prieten WithEvents btnAdd Ca System.Windows.Forms. Butonul prieten WithEvents btnRemove Ca System.Windows.Forms.Button prieten WithEvents btnClear Ca System.Windows.Forms.Button prieten WithEvents btnDisplayItem Ca System.Windows.Forms.Button prieten WithEvents ImageList1 Ca System.Windows.Forms.ImageList End Class

Originar

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms

public class ListViewIllustration public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub btnPopulate_Click(ByVal sender As System.Object, ByVal e As System.Event Dim intWidth As Integer Dim objItem As ListViewItem 'Set the default view. ListView1.View = View.Details optDetails.Checked = True 'Add the column headers. intWidth = ListView1.Width - 5 ListView1.Columns.Add("Name", CInt(intWidth / 4)) ListView1.Columns.Add("Address", CInt(intWidth / 4)) ListView1.Columns.Add("Phone", CInt(intWidth / 4)) ListView1.Columns.Add("FAX", CInt(intWidth / 4)) 'Add some list view items. objItem = ListView1.Items.Add("AAAAA") With objItem .SubItems.Add("123 Main St.") .SubItems.Add("555-555-5555") .SubItems.Add("555-555-5555") .ImageIndex = 0 End With

objItem = ListView1.Items.Add("BBBBB") With objItem .SubItems.Add("456 Main St.") .SubItems.Add("555-555-5555") .SubItems.Add("555-555-5555") .ImageIndex = 0 End With End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim strItemText As String Dim objItem As ListViewItem 'Add some list view items. strItemText = "name:" objItem = ListView1.Items.Add(strItemText) With objItem .SubItems.Add("123 Some St.") .SubItems.Add("555-555-5555") .SubItems.Add("555-555-5555") .ImageIndex = 0 End With End Sub

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArg ListView1.Items.Clear() End Sub

Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventAr Dim objListItem As ListViewItem For Each objListItem In ListView1.SelectedItems objListItem.Remove() Next objListItem End Sub

Private Sub btnDisplayItem_Click(ByVal sender As System.Object, ByVal e As System.Ev Dim strMessage As String Dim objListItem As ListViewItem If ListView1.SelectedItems.Count > 0 Then objListItem = ListView1.SelectedItems(0) With objListItem strMessage = "NAME: " & .Text & vbCrLf & _ "ADDRESS: " & .SubItems(1).Text & vbCrLf & _ "PHONE: " & .SubItems(2).Text & vbCrLf & _ "FAX: " & .SubItems(3).Text End With MsgBox(strMessage) End If End Sub

Private Sub optLargeIcon_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy

ListView1.View = View.LargeIcon End Sub

Private Sub optSmallIcon_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy ListView1.View = View.SmallIcon End Sub

Private Sub optList_CheckedChanged(ByVal sender As System.Object, ByVal e As System. ListView1.View = View.List End Sub

Private Sub optTile_CheckedChanged(ByVal sender As System.Object, ByVal e As System. ListView1.View = View.Tile End Sub

Private Sub optDetails_CheckedChanged(ByVal sender As System.Object, ByVal e As Syst ListView1.View = View.Details End Sub End Class Partial Public Class Form1 Inherits System.Windows.Forms.Form <System.Diagnostics.DebuggerNonUserCode()> _ Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() End Sub 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.ListView1 = New System.Windows.Forms.ListView Me.btnPopulate = New System.Windows.Forms.Button Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.optDetails = New System.Windows.Forms.RadioButton Me.optTile = New System.Windows.Forms.RadioButton Me.optList = New System.Windows.Forms.RadioButton Me.optSmallIcon = New System.Windows.Forms.RadioButton Me.optLargeIcon = New System.Windows.Forms.RadioButton Me.btnAdd = New System.Windows.Forms.Button Me.btnRemove = New System.Windows.Forms.Button Me.btnClear = New System.Windows.Forms.Button

Me.btnDisplayItem = New System.Windows.Forms.Button Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'ListView1 ' Me.ListView1.FullRowSelect = True Me.ListView1.Location = New System.Drawing.Point(17, 18) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(342, 364) Me.ListView1.TabIndex = 0 Me.ListView1.UseCompatibleStateImageBehavior = False ' 'btnPopulate ' Me.btnPopulate.Location = New System.Drawing.Point(366, 239) Me.btnPopulate.Name = "btnPopulate" Me.btnPopulate.Size = New System.Drawing.Size(161, 23) Me.btnPopulate.TabIndex = 2 Me.btnPopulate.Text = "Populate" ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.optDetails) Me.GroupBox1.Controls.Add(Me.optTile) Me.GroupBox1.Controls.Add(Me.optList) Me.GroupBox1.Controls.Add(Me.optSmallIcon) Me.GroupBox1.Controls.Add(Me.optLargeIcon) Me.GroupBox1.Location = New System.Drawing.Point(370, 13) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(156, 166) Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Views" ' 'optDetails ' Me.optDetails.AutoSize = True Me.optDetails.Location = New System.Drawing.Point(30, 126) Me.optDetails.Name = "optDetails" Me.optDetails.Size = New System.Drawing.Size(57, 17) Me.optDetails.TabIndex = 4 Me.optDetails.Text = "Details" ' 'optTile ' Me.optTile.AutoSize = True Me.optTile.Location = New System.Drawing.Point(30, 102) Me.optTile.Name = "optTile" Me.optTile.Size = New System.Drawing.Size(42, 17) Me.optTile.TabIndex = 3 Me.optTile.Text = "Tile" ' 'optList ' Me.optList.AutoSize = True Me.optList.Location = New System.Drawing.Point(30, 78) Me.optList.Name = "optList" Me.optList.Size = New System.Drawing.Size(41, 17) Me.optList.TabIndex = 2 Me.optList.Text = "List"

' 'optSmallIcon ' Me.optSmallIcon.AutoSize = True Me.optSmallIcon.Location = New System.Drawing.Point(30, 54) Me.optSmallIcon.Name = "optSmallIcon" Me.optSmallIcon.Size = New System.Drawing.Size(79, 17) Me.optSmallIcon.TabIndex = 1 Me.optSmallIcon.Text = "Small Icons" ' 'optLargeIcon ' Me.optLargeIcon.AutoSize = True Me.optLargeIcon.Location = New System.Drawing.Point(30, 30) Me.optLargeIcon.Name = "optLargeIcon" Me.optLargeIcon.Size = New System.Drawing.Size(81, 17) Me.optLargeIcon.TabIndex = 0 Me.optLargeIcon.Text = "Large Icons" ' 'btnAdd ' Me.btnAdd.Location = New System.Drawing.Point(365, 269) Me.btnAdd.Name = "btnAdd" Me.btnAdd.Size = New System.Drawing.Size(161, 23) Me.btnAdd.TabIndex = 3 Me.btnAdd.Text = "Add" ' 'btnRemove ' Me.btnRemove.Location = New System.Drawing.Point(366, 299) Me.btnRemove.Name = "btnRemove" Me.btnRemove.Size = New System.Drawing.Size(161, 23) Me.btnRemove.TabIndex = 4 Me.btnRemove.Text = "Remove" ' 'btnClear ' Me.btnClear.Location = New System.Drawing.Point(365, 329) Me.btnClear.Name = "btnClear" Me.btnClear.Size = New System.Drawing.Size(161, 23) Me.btnClear.TabIndex = 5 Me.btnClear.Text = "Clear" ' 'btnDisplayItem ' Me.btnDisplayItem.Location = New System.Drawing.Point(365, 359) Me.btnDisplayItem.Name = "btnDisplayItem" Me.btnDisplayItem.Size = New System.Drawing.Size(161, 23) Me.btnDisplayItem.TabIndex = 6 Me.btnDisplayItem.Text = "Display Item" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(539, 394) Me.Controls.Add(Me.btnDisplayItem) Me.Controls.Add(Me.btnClear) Me.Controls.Add(Me.btnRemove) Me.Controls.Add(Me.btnAdd) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.btnPopulate)

Me.Controls.Add(Me.ListView1) Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "ListView" Me.GroupBox1.ResumeLayout(False) Me.GroupBox1.PerformLayout() Me.ResumeLayout(False) End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class ListView1 As System.Windows.Forms.ListView btnPopulate As System.Windows.Forms.Button GroupBox1 As System.Windows.Forms.GroupBox optDetails As System.Windows.Forms.RadioButton optTile As System.Windows.Forms.RadioButton optList As System.Windows.Forms.RadioButton optSmallIcon As System.Windows.Forms.RadioButton optLargeIcon As System.Windows.Forms.RadioButton btnAdd As System.Windows.Forms.Button btnRemove As System.Windows.Forms.Button btnClear As System.Windows.Forms.Button btnDisplayItem As System.Windows.Forms.Button ImageList1 As System.Windows.Forms.ImageList

Creating Lista Vizite din Codul

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ListViewCreationInCode public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa

Publice clasa Form1 Motenete System.Windows.Forms.Form Dim ListView1 Ca ListView

Public Sub New () MyBase.New () Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.ResumeLayout ( Fals ) ListView1 = New ListView ListView1.Location = nou punct ( 75 , 90 ) ListView1.Size = noua dimensiune ( 150 , 150 ) Controls.Add ( ListView1 ) ListView1.Columns.Add ( ListView1.Columns.Add ( ListView1.Columns.Add ( ListView1 . Columns.Add

"Nume fiier" , 200 , HorizontalAlignment.Left ) "Size" , 100 , HorizontalAlignment.Left ) "Date" , 100 , HorizontalAlignment.Left ) ( "Caracteristica" , 100 , HorizontalAlignment.Center )

Dim ListItem1 Ca ListViewItem ListItem1 = ListView1.Items.Add ( "punctul 1" ) Dim ListItem2 Ca ListViewItem ListItem2 = ListView1.Items.Add ( "punctul 2" ) Dim ListItem3 Ca ListViewItem ListItem3 = ListView1.Items.Add ( "punctul 3" ) Dim ListItem4 Ca ListViewItem ListItem4 = ListView1.Items.Add ( "punctul 4" ) ListView1.View = View.SmallIcon End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ListViewCreationInCode public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Dim ListView1 As ListView Public Sub New() MyBase.New() Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.ResumeLayout(False) ListView1 = New ListView ListView1.Location = New Point(75, 90) ListView1.Size = New Size(150, 150) Controls.Add(ListView1) ListView1.Columns.Add("File Name", ListView1.Columns.Add("Size", 100, ListView1.Columns.Add("Date", 100, ListView1.Columns.Add("Attribute", 200, HorizontalAlignment.Left) HorizontalAlignment.Left) HorizontalAlignment.Left) 100, HorizontalAlignment.Center)

Dim ListItem1 As ListViewItem ListItem1 = ListView1.Items.Add("Item 1") Dim ListItem2 As ListViewItem ListItem2 = ListView1.Items.Add("Item 2") Dim ListItem3 As ListViewItem ListItem3 = ListView1.Items.Add("Item 3")

Dim ListItem4 As ListViewItem ListItem4 = ListView1.Items.Add("Item 4") ListView1.View = View.SmallIcon End Sub End Class

Add coloane i rnduri de un ListView

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class AddColumnToListView public comun Sub principal Application.Run ( New form2 ) End Sub End clasa public class form2 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New ()

"Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents ListView1 Ca System.Windows.Forms.ListView prieten WithEvents Button2 Ca System.Windows.Forms.Button prieten WithEvents ListView2 Ca System.Windows.Forms.ListView prieten WithEvents button3 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > privat Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button () Me.ListView1 = New System.Windows.Forms.ListView () Me.Button2 = New System.Windows.Forms.Button () Me.ListView2 = nou System.Windows.Forms.ListView () Me.Button3 = New System.Windows.Forms.Button () Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 32 , 8 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "obine fiiere" " "Li stView1 ' Me.ListView1.Location = New System.Drawing.Point ( 32 , 40 ) Me . ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size ( 480 , 56 ) Me.ListView1.TabIndex = 1 ' 'Bu tton2 ' Me.Button2.Location = New System.Drawing.Point ( 32 , 120 ) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size ( 80 , 24 ) Me.Button2.TabIndex = 2 Me.Button2.Text = "Adauga produs" " "Li stView2 ' Me.ListView2.Location = New System.Drawing.Point ( 32 , 160 ) Ca apel

Bool

Me.ListView2.Name = "ListView2" Me.ListView2.Size = New System.Drawing.Size ( 504 , 97 ) Me.ListView2.TabIndex = 3 Me.ListView2.View = System.Windows.Forms.View.Details ' 'Bu tton3 ' Me.Button3.Location = New System.Drawing.Point ( 120 , 120 ) Me.Button3.Name = "button3" Me. Button3.TabIndex = 4 Me.Button3.Text = "Adauga Coloana" " "Fo RM2 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 712 , 429 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Button3, Me.List Me.Name = "form2" Me.Text = " ListView Exemplu " Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub Button1_Click ( ByVal expeditor ListView1.Columns.Clear () ListView1.Items.Clear () ListView1.View = View.Details

System

ListView1.Columns.Add ( "Nume fiier" , 100 , HorizontalAlignment.Left ) ListView1.Columns.Add ( "extindere" , 50 , HorizontalAlignment.Left ) ListView1.Columns.Add ( "Bytes" , 50 , HorizontalAlignment.Right ) Dim DI Ca System.IO.DirectoryInfo = New System.IO.DirectoryInfo ( "C: \")

Fiiere Dim () ca System.IO.FileInfo = DI.GetFiles Fiier Dim Ca System.IO.FileInfo Dim li Ca ListViewItem pentru fiecare fiier din fiiere li = ListView1.Items.Add (file.Name) li.SubItems.Add (file.Extension) li.SubItems.Add (file.Length) Urmtorul End Sub

Private Sub Button2_Click (ByVal expeditorul ca System.Object, ByVal e ca System.Eve ListView2.Items.Add (" bau ") End Sub

Private Sub Button3_Click (ByVal expeditorul ca System.Object, ByVal e ca System.Eve ListView2.Columns.Add (" mycolumn ", 20, HorizontalAlignment.Center) End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class AddColumnToListView public Shared Sub Main Application.Run(New Form2) End Sub End class Public Class Form2 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then

If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents ListView1 As System.Windows.Forms.ListView Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents ListView2 As System.Windows.Forms.ListView Friend WithEvents Button3 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.ListView1 = New System.Windows.Forms.ListView() Me.Button2 = New System.Windows.Forms.Button() Me.ListView2 = New System.Windows.Forms.ListView() Me.Button3 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(32, 8) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Get Files" ' 'ListView1 ' Me.ListView1.Location = New System.Drawing.Point(32, 40) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(480, 56) Me.ListView1.TabIndex = 1 ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(32, 120) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(80, 24) Me.Button2.TabIndex = 2 Me.Button2.Text = "Add Item" ' 'ListView2 ' Me.ListView2.Location = New System.Drawing.Point(32, 160) Me.ListView2.Name = "ListView2" Me.ListView2.Size = New System.Drawing.Size(504, 97) Me.ListView2.TabIndex = 3 Me.ListView2.View = System.Windows.Forms.View.Details ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(120, 120) Me.Button3.Name = "Button3" Me.Button3.TabIndex = 4

Me.Button3.Text = "Add Column" ' 'Form2 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(712, 429) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button3, Me.ListView Me.Name = "Form2" Me.Text = "ListView Example" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ListView1.Columns.Clear() ListView1.Items.Clear() ListView1.View = View.Details ListView1.Columns.Add("Filename", 100, HorizontalAlignment.Left) ListView1.Columns.Add("Extension", 50, HorizontalAlignment.Left) ListView1.Columns.Add("Bytes", 50, HorizontalAlignment.Right) Dim DI As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("c:\") Dim files() As System.IO.FileInfo = DI.GetFiles Dim file As System.IO.FileInfo Dim li As ListViewItem For Each file In files li = ListView1.Items.Add(file.Name) li.SubItems.Add(file.Extension) li.SubItems.Add(file.Length) Next End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ListView2.Items.Add("boo") End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ListView2.Columns.Add("mycolumn", 20, HorizontalAlignment.Center) End Sub End Class

Change ListView de stat: LargeIcon, SmallIcon, lista i Detaliu

Importurile

System.Windows.Forms

public class ListViewState public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents MainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents MenuItem1 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem2 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem3 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem4 Ca sistem. Windows.Forms.MenuItem prieten WithEvents MenuItem5 Ca System.Windows.Forms.MenuItem prieten WithEvents ListView1 Ca System.Windows.Forms.ListView prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Label1 Ca System.Windows.Forms.Label

prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents TextBox2 Ca System.Windows.Forms.TextBox prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents button3 Ca System.Windows.Forms.Button prieten WithEvents ImageList1 Ca System.Windows . Forms.ImageList prieten WithEvents ImageList2 Ca System.Windows.Forms.ImageList prieten WithEvents ImageList3 Ca System.Windows.Forms.ImageList prieten WithEvents ColumnHeader1 Ca System.Windows.Forms.ColumnHeader prieten WithEvents ColumnHeader2 Ca System.Windows.Forms.ColumnHeader prieten WithEvents ColumnHeader3 Ca System.Windows.Forms.ColumnHeader <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.components = New System.ComponentModel.Container

Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem mine. MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.ListView1 = New System.Windows.Forms.ListView Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Button3 = Sistem . Windows.Forms.Button Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader3 = New System.Windows.Forms.ColumnHeader Me.SuspendLayout () " "Ma inMenu1 " Me.MainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.Menu " "Eu nuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange ( New System.Windows . Forms.MenuItem () { Me.Me Me.MenuItem1.Text = "View" " "Me nuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.Text = "Icoana mare" " "Me nuItem3 ' Me.MenuItem3.Index = 1 Me.MenuItem3.Text = "mic icon" " "Me nuItem4 ' Me.MenuItem4.Index = 2 Me.MenuItem4.Text = "Lista" " " ma nuItem5 ' Me.MenuItem5.Index = 3 Me.MenuItem5.Text = "detaliu" "

"Li stView1 " Me.ListView1.Columns.AddRange ( System.Windows.Forms.ColumnHeader Nou () { Me.Co Me.ListView1.Dock = System.Windows.Forms.DockStyle.Top Me.ListView1.Location = New System.Drawing.Point ( 0 , 0 ) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size ( 328 , 128 ) Me.ListView1.TabIndex = 0 " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 88 , 168 Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 80 , 20 ) Me. TextBox1.TabIndex = 1 Me.TextBox1.Text = "" " "La bel1 ' Me.Label1.Location = New System.Drawing.Point ( 48 , 168 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 40 , 24 ) Me.Label1.TabIndex = 2 Me.Label1.Text = "Proiectul" " "La bel2 ' Me.Label2.Location = New System.Drawing.Point ( 16 , 200 ) Me . Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 72 , 24 ) Me.Label2.TabIndex = 3 Me.Label2.Text = "Nu" " "Te xtBox2 " Me.TextBox2. Locaie = New System.Drawing.Point ( 88 , 200 Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size ( 80 , 20 ) Me.TextBox2.TabIndex = 4 Me.TextBox2. Text = "" " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 192 , 184 Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 72 , 24 ) Me.Button1.TabIndex = 5 Me.Button1.Text = "Add" " "Bu tton3 ' Me.Button3.Location = New System.Drawing.Point ( 120 , 240 Me.Button3.Name = "button3" Me . Button3.Size = New System.Drawing.Size ( 80 , 24 ) Me.Button3.TabIndex = 9 Me.Button3.Text = "Delete" " "Co lumnHeader1 ' Me.ColumnHeader1.Text = "File"

" "Co lumnHeader2 ' Me.ColumnHeader2.Text = "Dimensiune" " "Co lumnHeader3 ' Me.ColumnHeader3.Text = "Schimb data" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , Me.ClientSize = Nou

13 )

= Me.MainMenu1 Me.ResumeLayout ( Fals ) End Sub Private Sub MenuItem2_Click ( ByVal expeditor ListView1.View = View.LargeIcon End Sub Private Sub MenuItem3_Click ( ByVal expeditor ListView1.View = View.SmallIcon End Sub Private Sub MenuItem4_Click ( ByVal expeditor ListView1.View = View.List End Sub Private Sub MenuItem5_Click ( ByVal expeditor ListView1.View = View.Details End Sub Private Sub Button3_Click ( ByVal expeditor ListView1.FocusedItem.Remove () End Sub Private Sub Button1_Click ( ByVal expeditor 2 ) Ca Ca System.Object, ByVal e ca

Syst

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

System.Object, ByVal e

ca

System

Ca

System.Object, ByVal e

ca

System

ListView1.Items.Add ( "noi" , End Sub End Class

Original

Imports System.Windows.Forms public class ListViewState public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer Friend Friend Friend Friend Friend Friend Friend Friend Friend WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents MainMenu1 As System.Windows.Forms.MainMenu MenuItem1 As System.Windows.Forms.MenuItem MenuItem2 As System.Windows.Forms.MenuItem MenuItem3 As System.Windows.Forms.MenuItem MenuItem4 As System.Windows.Forms.MenuItem MenuItem5 As System.Windows.Forms.MenuItem ListView1 As System.Windows.Forms.ListView TextBox1 As System.Windows.Forms.TextBox Label1 As System.Windows.Forms.Label

Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents ImageList1 As System.Windows.Forms.ImageList Friend WithEvents ImageList2 As System.Windows.Forms.ImageList Friend WithEvents ImageList3 As System.Windows.Forms.ImageList Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container

Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.ListView1 = New System.Windows.Forms.ListView Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Button3 = New System.Windows.Forms.Button Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader3 = New System.Windows.Forms.ColumnHeader Me.SuspendLayout() ' 'MainMenu1 ' Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem ' 'MenuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem1.Text = "View" ' 'MenuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.Text = "Large Icon" ' 'MenuItem3 ' Me.MenuItem3.Index = 1 Me.MenuItem3.Text = "Small Icon" ' 'MenuItem4 ' Me.MenuItem4.Index = 2 Me.MenuItem4.Text = "List" ' 'MenuItem5 ' Me.MenuItem5.Index = 3 Me.MenuItem5.Text = "Detail" '

'ListView1 ' Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.Column Me.ListView1.Dock = System.Windows.Forms.DockStyle.Top Me.ListView1.Location = New System.Drawing.Point(0, 0) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(328, 128) Me.ListView1.TabIndex = 0 ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(88, 168) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(80, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(48, 168) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(40, 24) Me.Label1.TabIndex = 2 Me.Label1.Text = "Project" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(16, 200) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(72, 24) Me.Label2.TabIndex = 3 Me.Label2.Text = "No" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(88, 200) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(80, 20) Me.TextBox2.TabIndex = 4 Me.TextBox2.Text = "" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(192, 184) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(72, 24) Me.Button1.TabIndex = 5 Me.Button1.Text = "Add" ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(120, 240) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(80, 24) Me.Button3.TabIndex = 9 Me.Button3.Text = "Delete" ' 'ColumnHeader1 ' Me.ColumnHeader1.Text = "File"

' 'ColumnHeader2 ' Me.ColumnHeader2.Text = "Size" ' 'ColumnHeader3 ' Me.ColumnHeader3.Text = "Change Date" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(328, 297) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.ListView1) Me.Menu = Me.MainMenu1 Me.ResumeLayout(False) End Sub

Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventAr ListView1.View = View.LargeIcon End Sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventAr ListView1.View = View.SmallIcon End Sub

Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventAr ListView1.View = View.List End Sub

Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventAr ListView1.View = View.Details End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ListView1.FocusedItem.Remove() End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ListView1.Items.Add("new", 2) End Sub End Class

Add i terge ListView articol

Importurile

System.Windows.Forms

public class ListViewState public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents MainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents MenuItem1 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem2 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem3 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem4 Ca sistem. Windows.Forms.MenuItem prieten WithEvents MenuItem5 Ca System.Windows.Forms.MenuItem prieten WithEvents ListView1 Ca System.Windows.Forms.ListView prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Label1 Ca System.Windows.Forms.Label

prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents TextBox2 Ca System.Windows.Forms.TextBox prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents button3 Ca System.Windows.Forms.Button prieten WithEvents ImageList1 Ca System.Windows . Forms.ImageList prieten WithEvents ImageList2 Ca System.Windows.Forms.ImageList prieten WithEvents ImageList3 Ca System.Windows.Forms.ImageList prieten WithEvents ColumnHeader1 Ca System.Windows.Forms.ColumnHeader prieten WithEvents ColumnHeader2 Ca System.Windows.Forms.ColumnHeader prieten WithEvents ColumnHeader3 Ca System.Windows.Forms.ColumnHeader <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.components = New System.ComponentModel.Container

Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem mine. MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.ListView1 = New System.Windows.Forms.ListView Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Button3 = Sistem . Windows.Forms.Button Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader3 = New System.Windows.Forms.ColumnHeader Me.SuspendLayout () " "Ma inMenu1 " Me.MainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.Menu " "Eu nuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange ( New System.Windows . Forms.MenuItem () { Me.Me Me.MenuItem1.Text = "View" " "Me nuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.Text = "Icoana mare" " "Me nuItem3 ' Me.MenuItem3.Index = 1 Me.MenuItem3.Text = "mic icon" " "Me nuItem4 ' Me.MenuItem4.Index = 2 Me.MenuItem4.Text = "Lista" " " ma nuItem5 ' Me.MenuItem5.Index = 3 Me.MenuItem5.Text = "detaliu" "

"Li stView1 " Me.ListView1.Columns.AddRange ( System.Windows.Forms.ColumnHeader Nou () { Me.Co Me.ListView1.Dock = System.Windows.Forms.DockStyle.Top Me.ListView1.Location = New System.Drawing.Point ( 0 , 0 ) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size ( 328 , 128 ) Me.ListView1.TabIndex = 0 " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 88 , 168 Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 80 , 20 ) Me. TextBox1.TabIndex = 1 Me.TextBox1.Text = "" " "La bel1 ' Me.Label1.Location = New System.Drawing.Point ( 48 , 168 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 40 , 24 ) Me.Label1.TabIndex = 2 Me.Label1.Text = "Proiectul" " "La bel2 ' Me.Label2.Location = New System.Drawing.Point ( 16 , 200 ) Me . Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 72 , 24 ) Me.Label2.TabIndex = 3 Me.Label2.Text = "Nu" " "Te xtBox2 " Me.TextBox2. Locaie = New System.Drawing.Point ( 88 , 200 Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size ( 80 , 20 ) Me.TextBox2.TabIndex = 4 Me.TextBox2. Text = "" " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 192 , 184 Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 72 , 24 ) Me.Button1.TabIndex = 5 Me.Button1.Text = "Add" " "Bu tton3 ' Me.Button3.Location = New System.Drawing.Point ( 120 , 240 Me.Button3.Name = "button3" Me . Button3.Size = New System.Drawing.Size ( 80 , 24 ) Me.Button3.TabIndex = 9 Me.Button3.Text = "Delete" " "Co lumnHeader1 ' Me.ColumnHeader1.Text = "File"

" "Co lumnHeader2 ' Me.ColumnHeader2.Text = "Dimensiune" " "Co lumnHeader3 ' Me.ColumnHeader3.Text = "Schimb data" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , Me.ClientSize = Nou

13 )

= Me.MainMenu1 Me.ResumeLayout ( Fals ) End Sub Private Sub MenuItem2_Click ( ByVal expeditor ListView1.View = View.LargeIcon End Sub Private Sub MenuItem3_Click ( ByVal expeditor ListView1.View = View.SmallIcon End Sub Private Sub MenuItem4_Click ( ByVal expeditor ListView1.View = View.List End Sub Private Sub MenuItem5_Click ( ByVal expeditor ListView1.View = View.Details End Sub Private Sub Button3_Click ( ByVal expeditor ListView1.FocusedItem.Remove () End Sub Private Sub Button1_Click ( ByVal expeditor 2 ) Ca Ca System.Object, ByVal e ca

Syst

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

System.Object, ByVal e

ca

System

Ca

System.Object, ByVal e

ca

System

ListView1.Items.Add ( "noi" , End Sub End Class

Original

Imports System.Windows.Forms public class ListViewState public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer Friend Friend Friend Friend Friend Friend Friend Friend Friend WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents MainMenu1 As System.Windows.Forms.MainMenu MenuItem1 As System.Windows.Forms.MenuItem MenuItem2 As System.Windows.Forms.MenuItem MenuItem3 As System.Windows.Forms.MenuItem MenuItem4 As System.Windows.Forms.MenuItem MenuItem5 As System.Windows.Forms.MenuItem ListView1 As System.Windows.Forms.ListView TextBox1 As System.Windows.Forms.TextBox Label1 As System.Windows.Forms.Label

Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents ImageList1 As System.Windows.Forms.ImageList Friend WithEvents ImageList2 As System.Windows.Forms.ImageList Friend WithEvents ImageList3 As System.Windows.Forms.ImageList Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container

Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.ListView1 = New System.Windows.Forms.ListView Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Button3 = New System.Windows.Forms.Button Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader3 = New System.Windows.Forms.ColumnHeader Me.SuspendLayout() ' 'MainMenu1 ' Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem ' 'MenuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem1.Text = "View" ' 'MenuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.Text = "Large Icon" ' 'MenuItem3 ' Me.MenuItem3.Index = 1 Me.MenuItem3.Text = "Small Icon" ' 'MenuItem4 ' Me.MenuItem4.Index = 2 Me.MenuItem4.Text = "List" ' 'MenuItem5 ' Me.MenuItem5.Index = 3 Me.MenuItem5.Text = "Detail" '

'ListView1 ' Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.Column Me.ListView1.Dock = System.Windows.Forms.DockStyle.Top Me.ListView1.Location = New System.Drawing.Point(0, 0) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(328, 128) Me.ListView1.TabIndex = 0 ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(88, 168) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(80, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(48, 168) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(40, 24) Me.Label1.TabIndex = 2 Me.Label1.Text = "Project" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(16, 200) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(72, 24) Me.Label2.TabIndex = 3 Me.Label2.Text = "No" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(88, 200) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(80, 20) Me.TextBox2.TabIndex = 4 Me.TextBox2.Text = "" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(192, 184) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(72, 24) Me.Button1.TabIndex = 5 Me.Button1.Text = "Add" ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(120, 240) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(80, 24) Me.Button3.TabIndex = 9 Me.Button3.Text = "Delete" ' 'ColumnHeader1 ' Me.ColumnHeader1.Text = "File"

' 'ColumnHeader2 ' Me.ColumnHeader2.Text = "Size" ' 'ColumnHeader3 ' Me.ColumnHeader3.Text = "Change Date" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(328, 297) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.ListView1) Me.Menu = Me.MainMenu1 Me.ResumeLayout(False) End Sub

Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventAr ListView1.View = View.LargeIcon End Sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventAr ListView1.View = View.SmallIcon End Sub

Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventAr ListView1.View = View.List End Sub

Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventAr ListView1.View = View.Details End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ListView1.FocusedItem.Remove() End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ListView1.Items.Add("new", 2) End Sub End Class

ListView articol Verificai eveniment

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ListViewViewChange public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. Ca apel

Bool

prieten WithEvents ListView1 Ca System.Windows.Forms.ListView prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox prieten WithEvents ColumnHeader1 Ca System.Windows.Forms.ColumnHeader prieten WithEvents ColumnHeader2 Ca System.Windows.Forms.ColumnHeader prieten WithEvents ColumnHeader3 Ca System.Windows.Forms. ColumnHeader prieten WithEvents Button1 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.components = New System.ComponentModel.Container Dim ListViewItem1 Ca System.Windows.Forms.ListViewItem = Sistem. Windows.Form Dim ListViewItem2 Ca System.Windows.Forms.ListViewItem = New System.Windows.F Dim ListViewItem3 Ca System.Windows.Forms.ListViewItem = New System.Windows.F Dim ListViewItem4 Ca System.Windows.Forms.ListViewItem = New System.Windows.F Dim resurse Ca System.Resources . ResourceManager = New System.Resources.Reso Me.ListView1 = New System.Windows.Forms.ListView Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader2 = System.Windows.Forms noi. ColumnHeader Me.ColumnHeader3 = New System.Windows.Forms.ColumnHeader Me.TextBox1 = New System.Windows.Forms.TextBox Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.Button1 = New System.Windows.Forms.Button Me . SuspendLayout ()

" "Li stView1 ' Me.ListView1.AllowColumnReorder = True Me.ListView1.Columns.AddRange ( System.Windows.Forms.ColumnHeader Nou () { Me.Co Me.ListView1.Items. AddRange ( New System.Windows.Forms.ListViewItem () { ListVi Me.ListView1.Location = New System.Drawing.Point ( 32 , 104 ) Me.ListView1.Name = "ListView1" Me. ListView1.Size = New System.Drawing.Size ( 216 , 112 ) Me.ListView1.TabIndex = 1 ' 'Co lumnHeader1 ' Me.ColumnHeader1.Text = "Coloana antet 1" " "Co lumnHeader2 ' Me.ColumnHeader2.Text = " Antet coloana 2 " " "Co lumnHeader3 ' Me.ColumnHeader3.Text = "capul coloanei 3" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 64 , 232 ) Me.TextBox1.Name = "TextBox1 " Me.TextBox1.Size = New System.Drawing.Size ( 160 , 20 ) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "" " "Co mboBox1 " Me.ComboBox1.Items.AddRange ( Object nou () { "Icoana vizualizare mare" , "Rapo Me.ComboBox1.Location = New System.Drawing.Point ( 16 , 64 ) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size ( 121 , 21 ) Me.ComboBox1.TabIndex = 3

' 'Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 144 , 64 ) Me.Button1. name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 112 , 23 ) Me.Button1.TabIndex = 4 Me.Button1.Text = "Arat casute" " "Fo RM1 ' Me.AutoScaleBaseSize = Nou System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca

Private Sub ComboBox1_SelectedIndexChanged ( expeditor ByVal ListView1.View = ComboBox1.SelectedIndex End Sub

System.Object, By

Private Sub ListView1_SelectedIndexChanged ( expeditor ByVal Ca System.Object, By Dac ListView1.SelectedIndices.Count> 0 Apoi TextBox1.Text = "articol" & ListView1.SelectedIndices ( 0 ) & "a fost f Dac End End Sub Private Sub ListView1_ColumnClick ( expeditor ByVal TextBox1.Text = "Coloana" & ( e.Column + 1 ) End Sub Private Sub Button1_Click ( ByVal expeditor ListView1.CheckBoxes = True End Sub Ca Ca si

obiect, e ByVal Ca Syste "a fost fcut clic." ca

System.Object, ByVal e

System

Sub privat ListView1_ItemCheck ( expeditor ByVal Dac e.NewValue = CheckState.Checked Apoi TextBox1.Text = "articol" i e.Index () Altfel TextBox1.Text = "articol" i e.Index () Dac End End Sub End Class

Ca & &

obiect, ByVal e

ca

System.W

"este verificat . " "nu este verificat."

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ListViewViewChange public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.

Friend WithEvents ListView1 As System.Windows.Forms.ListView Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox Friend WithEvents ColumnHeader1 As System.Windows.Forms.ColumnHeader Friend WithEvents ColumnHeader2 As System.Windows.Forms.ColumnHeader Friend WithEvents ColumnHeader3 As System.Windows.Forms.ColumnHeader Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Dim ListViewItem1 As System.Windows.Forms.ListViewItem = New System.Windows.Form Dim ListViewItem2 As System.Windows.Forms.ListViewItem = New System.Windows.Form Dim ListViewItem3 As System.Windows.Forms.ListViewItem = New System.Windows.Form Dim ListViewItem4 As System.Windows.Forms.ListViewItem = New System.Windows.Form Dim resources As System.Resources.ResourceManager = New System.Resources.Resourc Me.ListView1 = New System.Windows.Forms.ListView Me.ColumnHeader1 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader2 = New System.Windows.Forms.ColumnHeader Me.ColumnHeader3 = New System.Windows.Forms.ColumnHeader Me.TextBox1 = New System.Windows.Forms.TextBox Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout()

' 'ListView1 ' Me.ListView1.AllowColumnReorder = True Me.ListView1.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.Column Me.ListView1.Items.AddRange(New System.Windows.Forms.ListViewItem() {ListViewIte Me.ListView1.Location = New System.Drawing.Point(32, 104) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(216, 112) Me.ListView1.TabIndex = 1 ' 'ColumnHeader1 ' Me.ColumnHeader1.Text = "Column Header 1" ' 'ColumnHeader2 ' Me.ColumnHeader2.Text = "Column Header 2" ' 'ColumnHeader3 ' Me.ColumnHeader3.Text = "Column Header 3" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(64, 232) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(160, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "" ' 'ComboBox1 ' Me.ComboBox1.Items.AddRange(New Object() {"Large Icon View", "Report View", "Sma Me.ComboBox1.Location = New System.Drawing.Point(16, 64) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(121, 21) Me.ComboBox1.TabIndex = 3

' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(144, 64) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(112, 23) Me.Button1.TabIndex = 4 Me.Button1.Text = "Show Check Boxes" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.ComboBox1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.ListView1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As ListView1.View = ComboBox1.SelectedIndex End Sub

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As If ListView1.SelectedIndices.Count > 0 Then TextBox1.Text = "Item " & ListView1.SelectedIndices(0) & " was clicked." End If End Sub

Private Sub ListView1_ColumnClick(ByVal sender As Object, ByVal e As System.Windows. TextBox1.Text = "Column " & (e.Column + 1) & " was clicked." End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ListView1.CheckBoxes = True End Sub

Private Sub ListView1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Fo If e.NewValue = CheckState.Checked Then TextBox1.Text = "Item " & e.Index() & " is checked." Else TextBox1.Text = "Item " & e.Index() & " is not checked." End If End Sub End Class

Directoare 14.15.7.Displaying i coninutul lor n ListView

Importurile Importurile public class

System.IO System.Windows.Forms LoadFileDirectoryInformationTreeView

public comun Sub principal Application.Run ( New FrmListView ) End Sub End clasa public class FrmListView Motenete Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "D etichete isplay pentru locaia curent n arborele de directoare prieten WithEvents lblCurrent Ca Label Ca apel

Boole

prieten WithEvents lblDisplay

Ca

Label

"D coninutul isplays din directorul curent prieten WithEvents lvwBrowser Ca ListView 'S pecifies imagini pentru icoane de fiiere i foldere icoane prieten WithEvents ilsFileFolder Ca ImageList "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . Componentele = New System.ComponentModel.Container () Me.ilsFileFolder = System.Windows.Forms.ImageList nou ( Me.components ) Me.lvwBrowser = New System.Windows.Forms.ListView () Me.lblCurrent = New System.Windows . Forms.Label () Me.lblDisplay = New System.Windows.Forms.Label () Me.SuspendLayout () " "O sFileFolder ' Me.ilsFileFolder.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.ilsFileFolder.ImageSize = New System.Drawing.Size ( 16 , 16 ) Me.ilsFileFolder.TransparentColor = System.Drawing.Color.Transparent ' "LV wBrowser ' Me.lvwBrowser.Location = New System.Drawing.Point ( 16 , 88 ) Me.lvwBrowser . Nume = "lvwBrowser" Me.lvwBrowser.RightToLeft = System.Windows.Forms.RightToLeft.No Me.lvwBrowser.Size = New System.Drawing.Size ( 448 , 232 ) Me.lvwBrowser.SmallImageList = Me.ilsFileFolder Me.lvwBrowser . tabindex = 2 Me.lvwBrowser.View = System.Windows.Forms.View.List ' 'lb lCurrent ' Me.lblCurrent.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, S Me.lblCurrent.ForeColor = System.Drawing.SystemColors.WindowText Me.lblCurrent.Location = New System.Drawing.Point ( 16 , 16 ) Me . lblCurrent.Name = "lblCurrent" Me.lblCurrent.Size = New System.Drawing.Size ( 112 , 23 ) Me.lblCurrent.TabIndex = 0 Me.lblCurrent.Text = "Acum, n Directory:" " 'lb lDisplay " Me . lblDisplay.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, Me.lblDisplay.ForeColor = System.Drawing.SystemColors.WindowText Me.lblDisplay.Location = New System.Drawing.Point ( 128 , 16 ) Me.lblDisplay.Name = "lblDisplay" Me.lblDisplay.Size = New System.Drawing.Size ( 344 , 56 ) Me.lblDisplay.TabIndex = 1 ' "Parintele mListView ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 )

Me.ClientSize = New System.Drawing.Size ( 488 , 341 ) Me.Controls.AddRange ( nou sistem de . Windows.Forms.Control () { Me.lvwBrowser, M Me.Name = "FrmListView" Me.Text = "ListViewTest" Me.ResumeLayout ( Fals ) End Sub # End Dim Regiunea currentDirectory Ca String = Directory.GetCurrentDirectory ()

Private Sub lvwBrowser_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere lvwBrowser.Click Dac lvwBrowser.SelectedItems.Count <> 0 Apoi Daca lvwBrowser.Items ( 0 ) . selectat, atunci Dim directoryObject Ca DirectoryInfo = _ New DirectoryInfo ( currentDirectory ) Dac nu ( directoryObject.Parent este nimic ) Apoi LoadFilesInDirectory ( directoryObject.Parent.FullName ) End Dac Altfel Dim ales Ca String = lvwBrowser.SelectedItems ( 0 ) . Text Dac Directory.Exists ( currentDirectory & "\" si ales), apoi Dac currentDirectory = " C: \ "Atunci LoadFilesInDirectory (currentDirectory & alese) Else LoadFilesInDirectory (currentDirectory & " \ "si ales) End If End If End If lblDisplay.Text = currentDirectory End Dac End Sub Public Sub LoadFilesInDirectory (ByVal currentDirectoryValue Ca String) lvwBrowser.Items.Clear () lvwBrowser.Items.Add (" Du-te sus cu un nivel ") currentDirectory = currentDirectoryValue newCurrentDirectory Dim Ca DirectoryInfo = New DirectoryInfo (currentDirectory) directoryArray Dim Ca DirectoryInfo () = newCurrentDirectory.GetDirectories () fileArray Dim Ca Fileinfo () = newCurrentDirectory.GetFiles () Dim dir Ca DirectoryInfo pentru fiecare dir n directoryArray Dim newDirectoryItem Ca ListViewItem = lvwBrowser.Items.Add (dir.Name) Urmtorul Fiier Dim Ca Fileinfo pentru fiecare fiier din fileArray Dim newFileItem Ca ListViewItem = lvwBrowser.Items.Add (file.Name) Urmtorul End Sub Private Sub FrmListView_Load (expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs) Manere MyBase.Load LoadFilesInDirectory (currentDirectory) lblDisplay.Text = currentDirectory

End Sub End Class

Original

14.15.7.Displaying directories and their contents in ListView

Imports System.IO Imports System.Windows.Forms public class LoadFileDirectoryInformationTreeView public Shared Sub Main Application.Run(New FrmListView) End Sub End class Public Class FrmListView Inherits Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub ' display labels for current location in directory tree Friend WithEvents lblCurrent As Label Friend WithEvents lblDisplay As Label ' displays contents of current directory Friend WithEvents lvwBrowser As ListView ' specifies images for file icons and folder icons Friend WithEvents ilsFileFolder As ImageList 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Me.ilsFileFolder = New System.Windows.Forms.ImageList(Me.components) Me.lvwBrowser = New System.Windows.Forms.ListView() Me.lblCurrent = New System.Windows.Forms.Label() Me.lblDisplay = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'ilsFileFolder ' Me.ilsFileFolder.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.ilsFileFolder.ImageSize = New System.Drawing.Size(16, 16) Me.ilsFileFolder.TransparentColor = System.Drawing.Color.Transparent ' 'lvwBrowser ' Me.lvwBrowser.Location = New System.Drawing.Point(16, 88) Me.lvwBrowser.Name = "lvwBrowser" Me.lvwBrowser.RightToLeft = System.Windows.Forms.RightToLeft.No Me.lvwBrowser.Size = New System.Drawing.Size(448, 232) Me.lvwBrowser.SmallImageList = Me.ilsFileFolder Me.lvwBrowser.TabIndex = 2 Me.lvwBrowser.View = System.Windows.Forms.View.List ' 'lblCurrent ' Me.lblCurrent.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System Me.lblCurrent.ForeColor = System.Drawing.SystemColors.WindowText Me.lblCurrent.Location = New System.Drawing.Point(16, 16) Me.lblCurrent.Name = "lblCurrent" Me.lblCurrent.Size = New System.Drawing.Size(112, 23) Me.lblCurrent.TabIndex = 0 Me.lblCurrent.Text = "Now in Directory:"

' 'lblDisplay ' Me.lblDisplay.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System Me.lblDisplay.ForeColor = System.Drawing.SystemColors.WindowText Me.lblDisplay.Location = New System.Drawing.Point(128, 16) Me.lblDisplay.Name = "lblDisplay" Me.lblDisplay.Size = New System.Drawing.Size(344, 56) Me.lblDisplay.TabIndex = 1 ' 'FrmListView ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(488, 341) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lvwBrowser, Me.lblDisp Me.Name = "FrmListView" Me.Text = "ListViewTest" Me.ResumeLayout(False) End Sub #End Region Dim currentDirectory As String = Directory.GetCurrentDirectory() Private Sub lvwBrowser_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles lvwBrowser.Click If lvwBrowser.SelectedItems.Count <> 0 Then If lvwBrowser.Items(0).Selected Then Dim directoryObject As DirectoryInfo = _ New DirectoryInfo(currentDirectory) If Not (directoryObject.Parent Is Nothing) Then LoadFilesInDirectory(directoryObject.Parent.FullName) End If Else Dim chosen As String = lvwBrowser.SelectedItems(0).Text If Directory.Exists(currentDirectory & "\" & chosen) Then If currentDirectory = "C:\" Then LoadFilesInDirectory(currentDirectory & chosen) Else LoadFilesInDirectory(currentDirectory & "\" & chosen) End If End If End If lblDisplay.Text = currentDirectory End If End Sub Public Sub LoadFilesInDirectory(ByVal currentDirectoryValue As String) lvwBrowser.Items.Clear() lvwBrowser.Items.Add("Go Up One Level") currentDirectory = currentDirectoryValue Dim newCurrentDirectory As DirectoryInfo = New DirectoryInfo(currentDirectory) Dim directoryArray As DirectoryInfo() = newCurrentDirectory.GetDirectories() Dim fileArray As FileInfo() = newCurrentDirectory.GetFiles() Dim dir As DirectoryInfo For Each dir In directoryArray

Dim newDirectoryItem As ListViewItem = lvwBrowser.Items.Add(dir.Name) Next Dim file As FileInfo For Each file In fileArray Dim newFileItem As ListViewItem =lvwBrowser.Items.Add(file.Name) Next End Sub Private Sub FrmListView_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load LoadFilesInDirectory(currentDirectory) lblDisplay.Text = currentDirectory End Sub End Class

ListView ItemActivate eveniment

Importurile

System.Windows.Forms

public class TreeViewListView public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New ()

"Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents TreeView1 Ca System.Windows.Forms.TreeView prieten WithEvents Splitter1 Ca System.Windows.Forms.Splitter prieten WithEvents ListView1 Ca System.Windows.Forms.ListView <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.components = New System.ComponentModel.Container () Me.TreeView1 = Sistem . Windows.Forms.TreeView () Me.Splitter1 = New System.Windows.Forms.Splitter () Me.ListView1 = New System.Windows.Forms.ListView () Me.SuspendLayout () " "Tr eeView1 " Me.TreeView1. doc = System.Windows.Forms.DockStyle.Left Me.TreeView1.Name = "TreeView1" Me.TreeView1.Nodes.AddRange ( New System.Windows.Forms.TreeNode () { New System.Windows. System.Windows.Forms.TreeNode ( "Z" ) , New System.Windows.Forms.TreeNode ( "b" )}) , Ne Me.TreeView1.Size = New System.Drawing.Size ( 121 , 273 ) Me.TreeView1.TabIndex = 0 ' ' Sp litter1 ' Me.Splitter1.Location = New System.Drawing.Point ( 121 , 0 ) Me.Splitter1.Name = "Splitter1" Me.Splitter1.Size = New System.Drawing.Size ( 3 , 273 ) Me.Splitter1. tabindex = 1 Me.Splitter1.TabStop = false ' "Li stView1 ' Me.ListView1.Dock = System.Windows.Forms.DockStyle.Fill Me.ListView1.Location = New System.Drawing.Point ( 124 , 0 ) Me.ListView1 . Nume = "ListView1" Me.ListView1.Size = New System.Drawing.Size ( 168 , 273 ) Me.ListView1.TabIndex = 2 Me.ListView1.View = System.Windows.Forms.View.List ' 'Fo RM1 "

Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.ListView1 , Me.Splitter1 Me.Name = "Form1" Me.Text = "Vehicul Ierarhia" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub TreeView1_AfterSelect ( expeditor ByVal selectai

selectai End Sub Sub Private ListView1_ItemActivate ( expeditor ByVal Ca strItem dim ca String = listView1.FocusedItem.Text Console.WriteLine ( strItem ) End Sub End Class obiect, e ByVal Ca

System

Original

Imports System.Windows.Forms

public class TreeViewListView public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TreeView1 As System.Windows.Forms.TreeView Friend WithEvents Splitter1 As System.Windows.Forms.Splitter Friend WithEvents ListView1 As System.Windows.Forms.ListView <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Me.TreeView1 = New System.Windows.Forms.TreeView() Me.Splitter1 = New System.Windows.Forms.Splitter() Me.ListView1 = New System.Windows.Forms.ListView() Me.SuspendLayout() ' 'TreeView1 ' Me.TreeView1.Dock = System.Windows.Forms.DockStyle.Left Me.TreeView1.Name = "TreeView1" Me.TreeView1.Nodes.AddRange(New System.Windows.Forms.TreeNode() {New System.Windows.Form New System.Windows.Forms.TreeNode("b")}), New System.Windows.Forms.TreeNode("c", New Sys Me.TreeView1.Size = New System.Drawing.Size(121, 273) Me.TreeView1.TabIndex = 0 ' 'Splitter1 ' Me.Splitter1.Location = New System.Drawing.Point(121, 0)

Me.Splitter1.Name = "Splitter1" Me.Splitter1.Size = New System.Drawing.Size(3, 273) Me.Splitter1.TabIndex = 1 Me.Splitter1.TabStop = False ' 'ListView1 ' Me.ListView1.Dock = System.Windows.Forms.DockStyle.Fill Me.ListView1.Location = New System.Drawing.Point(124, 0) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(168, 273) Me.ListView1.TabIndex = 2 Me.ListView1.View = System.Windows.Forms.View.List ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListView1, Me.Splitter1, Me. Me.Name = "Form1" Me.Text = "Vehicle Hierarchy" Me.ResumeLayout(False) End Sub #End Region

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Win select case e.Node.Text case "a" listView1.Clear() listView1.Items.Add("a",3) listView1.Items.Add("b", 4) listView1.Items.Add("c", 6) case "b" listView1.Clear() listView1.Items.Add("a", 1) listView1.Items.Add("b", 2) listView1.Items.Add("c", 5) end select End Sub

Private Sub ListView1_ItemActivate(ByVal sender As Object, ByVal e As System.EventArgs dim strItem as String = listView1.FocusedItem.Text Console.WriteLine(strItem) End Sub End Class

.ListView cu celule CheckBox

"Vi "Au "Pu "IS

SUAL Basic.Net JingCai Programarea Thor: Yong Zhang blisher: Apa Editura China BN: 750841156 System.Drawing System.Drawing.Drawing2D System.Windows.Forms

100

Exemple

Importurile Importurile Importurile Importurile Importurile

System.Runtime.InteropServices System.IO

public class FileListView public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Dim nIndex Ca Integer = 0 Private Sub CreateMyListView ( ByVal dirpath Ca String ) Dim hImgSmall Ca IntPtr Dim hImgLarge Ca IntPtr Dim shinfo Ca FileInfoClass.SHFILEINFO = Nou

= 0 ListView1.Columns.Add ListView1.Columns.Add ListView1.Columns.Add ListView1.Columns.Add

( ( ( (

"Nume fiier" , 200 , HorizontalAlignment.Left ) "Size" , 100 , HorizontalAlignment.Left ) "Date" , 100 , HorizontalAlignment.Left ) "Caracteristica" , 100 , HorizontalAlignment.Center )

ListView1.LargeImageList = imageListLarge ListView1.SmallImageList = imageListSmall ListView1.View = View.Details ListView1.LabelEdit = True ListView1.AllowColumnReorder = true ListView1.CheckBoxes = True

ListView1.FullRowSelect = true ListView1.GridLines = True ListView1.Sorting = SortOrder.Ascending Dim FilesInDir Ca String () = Directory.GetFiles ( dirpath, Dim SFile Ca String Dim item1 Ca noi

"*. *" )

Fiecare SFile n FilesInDir ctdate = IO.File.GetCreationTime ( SFile ) fAttr = IO.File.GetAttributes ( SFile ) shinfo.szDisplayName = new String ( Chr ( 0 ) , 260 ) shinfo.szTypeName = new String ( Chr ( 0 ) , 80 ) hImgSmall = FileInfoClass.SHGetFileInfo ( SFile, 0 , shinfo, _ Marshal.SizeOf ( shinfo ) , _ FileInfoClass.SHGFI_ICON sau pictograma de smallimageList. hImgLarge = FileInfoClass.SHGetFileInfo ( SFile, 0 , shinfo, _ Marshal.SizeOf ( shinfo ) , _ FileInfoClass.SHGFI_ICON sau pictograma de LargeimageList. ListView1.Items.Add ( New ListViewItem ( New String () { SFile, CStr ( FileL nIndex = nIndex + 1 Urmtor End Sub Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e Dim discuri Ca String () = Directory.GetLogicalDrives Dim Sdisk Ca String ComboBox1.Items.Clear () pentru fiecare Sdisk In discuri ComboBox1. Items.Add ( Sdisk ) Urmtorul End Sub Private Sub ComboBox1_SelectedIndexChanged ( expeditor ByVal CreateMyListView ( ComboBox1.Text ) End Sub End Class public class FileInfoClass Publice Structura Ca ca

System.Ev

System.Object, By

SizeConst: = 260 ) > _ Public szDisplayName Ca String <MarshalAs ( UnmanagedType.ByValTStr, SizeConst: = 80 ) > _ Public szTypeName Ca String Sfrit Structura Public declara funcia Auto SHGetFileInfo Lib "Shell32.dll" _ ( ByVal pszPath Ca String, _ dwFileAttributes ByVal Ca Integer, _ ByRef IFPS Ca SHFILEINFO, _ ByVal cbFileInfo Ca Integer, _ ByVal uFlags Ca Integer ) Ca IntPtr Public Const SHGFI_ICON = & H100 Public Const SHGFI_SMALLICON = & H1 Public Const SHGFI_LARGEICON = & H0 'L ARGE pictograma

End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.components = New System.ComponentModel.Container Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.ListView1 = New System.Windows.Forms.ListView Me.ImageListSmall = New System.Windows.Forms.ImageList ( Me.components ) Me.ImageListLarge = Nou

Boolean )

= True Me.ComboBox1.Location = New System.Drawing.Point ( 12 , 3 ) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size ( 413 , 20 ) Me.ComboBox1.TabIndex = 0 ' 'Li stView1 ' Me.ListView1.Location = New System.Drawing.Point ( 12 , 29 ) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size ( 413 , 207 ) Me.ListView1.TabIndex = 1 Me.ListView1.UseCompatibleStateImageBehavior = false ' "Im ageListSmall ' Me.ImageListSmall.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.ImageListSmall.ImageSize = New System.Drawing.Size ( 16 , 16 ) Me.ImageListSmall.TransparentColor = System.Drawing.Color.Transparent ' 'Im ageListLarge ' Me.ImageListLarge.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.ImageListLarge.ImageSize = New System.Drawing.Size ( 16 , 16 ) Me.ImageListLarge.TransparentColor = System.Drawing.Color.Transparent ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 12.0 ! )

Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me . ClientSize = Nou

End Sub prieten WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox prieten WithEvents ListView1 Ca System.Windows.Forms.ListView prieten WithEvents ImageListSmall Ca System.Windows.Forms.ImageList prieten WithEvents ImageListLarge Ca System.Windows.Forms.ImageList End Class

Original

'Visual Basic.Net JingCai Programming 100 Examples 'Author: Yong Zhang 'Publisher: Water Publisher China 'ISBN: 750841156 Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms Imports System.Runtime.InteropServices Imports System.IO public class FileListView public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Dim nIndex As Integer = 0 Private Sub CreateMyListView(ByVal dirpath As String) Dim hImgSmall As IntPtr Dim hImgLarge As IntPtr Dim shinfo As FileInfoClass.SHFILEINFO = New FileInfoClass.SHFILEINFO() ListView1.Clear() ImageListSmall.Images.Clear() ImageListLarge.Images.Clear() nIndex = 0 ListView1.Columns.Add("File Name", 200, HorizontalAlignment.Left) ListView1.Columns.Add("Size", 100, HorizontalAlignment.Left) ListView1.Columns.Add("Date", 100, HorizontalAlignment.Left) ListView1.Columns.Add("Attribute", 100, HorizontalAlignment.Center)

ListView1.LargeImageList = imageListLarge ListView1.SmallImageList = imageListSmall ListView1.View = View.Details ListView1.LabelEdit = True ListView1.AllowColumnReorder = True ListView1.CheckBoxes = True ListView1.FullRowSelect = True ListView1.GridLines = True ListView1.Sorting = SortOrder.Ascending Dim FilesInDir As String() = Directory.GetFiles(dirpath, "*.*") Dim SFile As String Dim item1 As New ListViewItem("", 0) item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim ctdate As Date Dim fAttr As FileAttribute For Each SFile In FilesInDir ctdate = IO.File.GetCreationTime(SFile) fAttr = IO.File.GetAttributes(SFile) shinfo.szDisplayName = New String(Chr(0), 260) shinfo.szTypeName = New String(Chr(0), 80) hImgSmall = FileInfoClass.SHGetFileInfo(SFile, 0, shinfo, _ Marshal.SizeOf(shinfo), _ FileInfoClass.SHGFI_ICON Or FileInfoClass.SHGFI_SMAL ImageListSmall.Images.Add(System.Drawing.Icon.FromHandle(shinfo.hIcon)) hImgLarge = FileInfoClass.SHGetFileInfo(SFile, 0, shinfo, _ Marshal.SizeOf(shinfo), _ FileInfoClass.SHGFI_ICON Or FileInfoClass.SH ImageListLarge.Images.Add(System.Drawing.Icon.FromHandle(shinfo.hIcon)) ListView1.Items.Add(New ListViewItem(New String() {SFile, CStr(FileLen(SFile nIndex = nIndex + 1 Next End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H Dim disks As String() = Directory.GetLogicalDrives Dim Sdisk As String ComboBox1.Items.Clear() For Each Sdisk In disks ComboBox1.Items.Add(Sdisk) Next End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As CreateMyListView(ComboBox1.Text)

End Sub End Class Public Class FileInfoClass Public Structure SHFILEINFO Public hIcon As IntPtr Public iIcon As Integer Public dwAttributes As Integer <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _ Public szDisplayName As String <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> _ Public szTypeName As String End Structure Public Declare Auto Function SHGetFileInfo Lib "shell32.dll" _ (ByVal pszPath As String, _ ByVal dwFileAttributes As Integer, _ ByRef psfi As SHFILEINFO, _ ByVal cbFileInfo As Integer, _ ByVal uFlags As Integer) As IntPtr Public Const SHGFI_ICON = &H100 Public Const SHGFI_SMALLICON = &H1 Public Const SHGFI_LARGEICON = &H0 ' Large icon End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.ListView1 = New System.Windows.Forms.ListView Me.ImageListSmall = New System.Windows.Forms.ImageList(Me.components) Me.ImageListLarge = New System.Windows.Forms.ImageList(Me.components) Me.SuspendLayout() ' 'ComboBox1 ' Me.ComboBox1.FormattingEnabled = True Me.ComboBox1.Location = New System.Drawing.Point(12, 3) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(413, 20) Me.ComboBox1.TabIndex = 0 ' 'ListView1 '

Me.ListView1.Location = New System.Drawing.Point(12, 29) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(413, 207) Me.ListView1.TabIndex = 1 Me.ListView1.UseCompatibleStateImageBehavior = False ' 'ImageListSmall ' Me.ImageListSmall.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.ImageListSmall.ImageSize = New System.Drawing.Size(16, 16) Me.ImageListSmall.TransparentColor = System.Drawing.Color.Transparent ' 'ImageListLarge ' Me.ImageListLarge.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.ImageListLarge.ImageSize = New System.Drawing.Size(16, 16) Me.ImageListLarge.TransparentColor = System.Drawing.Color.Transparent ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(437, 246) Me.Controls.Add(Me.ListView1) Me.Controls.Add(Me.ComboBox1) Me.ResumeLayout(False) End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class ComboBox1 As System.Windows.Forms.ComboBox ListView1 As System.Windows.Forms.ListView ImageListSmall As System.Windows.Forms.ImageList ImageListLarge As System.Windows.Forms.ImageList

Original

'Visual Basic.Net JingCai Programming 100 Examples 'Author: Yong Zhang 'Publisher: Water Publisher China 'ISBN: 750841156 Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms Imports System.Runtime.InteropServices Imports System.IO public class FileListView public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Dim nIndex As Integer = 0 Private Sub CreateMyListView(ByVal dirpath As String) Dim hImgSmall As IntPtr Dim hImgLarge As IntPtr Dim shinfo As FileInfoClass.SHFILEINFO = New FileInfoClass.SHFILEINFO() ListView1.Clear() ImageListSmall.Images.Clear() ImageListLarge.Images.Clear() nIndex = 0 ListView1.Columns.Add("File Name", 200, HorizontalAlignment.Left) ListView1.Columns.Add("Size", 100, HorizontalAlignment.Left) ListView1.Columns.Add("Date", 100, HorizontalAlignment.Left) ListView1.Columns.Add("Attribute", 100, HorizontalAlignment.Center) ListView1.LargeImageList = imageListLarge ListView1.SmallImageList = imageListSmall ListView1.View = View.Details ListView1.LabelEdit = True ListView1.AllowColumnReorder = True ListView1.CheckBoxes = True

ListView1.FullRowSelect = True ListView1.GridLines = True ListView1.Sorting = SortOrder.Ascending Dim FilesInDir As String() = Directory.GetFiles(dirpath, "*.*") Dim SFile As String Dim item1 As New ListViewItem("", 0) item1.SubItems.Add("1") item1.SubItems.Add("2") item1.SubItems.Add("3") Dim ctdate As Date Dim fAttr As FileAttribute For Each SFile In FilesInDir ctdate = IO.File.GetCreationTime(SFile) fAttr = IO.File.GetAttributes(SFile) shinfo.szDisplayName = New String(Chr(0), 260) shinfo.szTypeName = New String(Chr(0), 80) hImgSmall = FileInfoClass.SHGetFileInfo(SFile, 0, shinfo, _ Marshal.SizeOf(shinfo), _ FileInfoClass.SHGFI_ICON Or FileInfoClass.SHGFI_SMAL ImageListSmall.Images.Add(System.Drawing.Icon.FromHandle(shinfo.hIcon)) hImgLarge = FileInfoClass.SHGetFileInfo(SFile, 0, shinfo, _ Marshal.SizeOf(shinfo), _ FileInfoClass.SHGFI_ICON Or FileInfoClass.SH ImageListLarge.Images.Add(System.Drawing.Icon.FromHandle(shinfo.hIcon)) ListView1.Items.Add(New ListViewItem(New String() {SFile, CStr(FileLen(SFile nIndex = nIndex + 1 Next End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H Dim disks As String() = Directory.GetLogicalDrives Dim Sdisk As String ComboBox1.Items.Clear() For Each Sdisk In disks ComboBox1.Items.Add(Sdisk) Next End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As CreateMyListView(ComboBox1.Text) End Sub End Class Public Class FileInfoClass Public Structure SHFILEINFO Public hIcon As IntPtr Public iIcon As Integer Public dwAttributes As Integer <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _ Public szDisplayName As String <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)> _ Public szTypeName As String End Structure Public Declare Auto Function SHGetFileInfo Lib "shell32.dll" _ (ByVal pszPath As String, _ ByVal dwFileAttributes As Integer, _ ByRef psfi As SHFILEINFO, _ ByVal cbFileInfo As Integer, _ ByVal uFlags As Integer) As IntPtr Public Const SHGFI_ICON = &H100 Public Const SHGFI_SMALLICON = &H1 Public Const SHGFI_LARGEICON = &H0 ' Large icon

End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.ListView1 = New System.Windows.Forms.ListView Me.ImageListSmall = New System.Windows.Forms.ImageList(Me.components) Me.ImageListLarge = New System.Windows.Forms.ImageList(Me.components) Me.SuspendLayout() ' 'ComboBox1 ' Me.ComboBox1.FormattingEnabled = True Me.ComboBox1.Location = New System.Drawing.Point(12, 3) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(413, 20) Me.ComboBox1.TabIndex = 0 ' 'ListView1 ' Me.ListView1.Location = New System.Drawing.Point(12, 29) Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(413, 207) Me.ListView1.TabIndex = 1 Me.ListView1.UseCompatibleStateImageBehavior = False ' 'ImageListSmall ' Me.ImageListSmall.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.ImageListSmall.ImageSize = New System.Drawing.Size(16, 16) Me.ImageListSmall.TransparentColor = System.Drawing.Color.Transparent ' 'ImageListLarge ' Me.ImageListLarge.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.ImageListLarge.ImageSize = New System.Drawing.Size(16, 16) Me.ImageListLarge.TransparentColor = System.Drawing.Color.Transparent ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)

Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(437, 246) Me.Controls.Add(Me.ListView1) Me.Controls.Add(Me.ComboBox1) Me.ResumeLayout(False) End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class ComboBox1 As System.Windows.Forms.ComboBox ListView1 As System.Windows.Forms.ListView ImageListSmall As System.Windows.Forms.ImageList ImageListLarge As System.Windows.Forms.ImageList

Numele de fiier 14.15.10.Add la lista

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class AddImageFileToListView public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents ListView1 Ca System.Windows.Forms.ListView prieten WithEvents PictureBox1 Ca System.Windows.Forms.PictureBox prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.ListView1 = Sistem. Windows.Forms.ListView () Me.PictureBox1 = New System.Windows.Forms.PictureBox () Me.Button1 = New System.Windows.Forms.Button () Me.TextBox1 = New System.Windows.Forms.TextBox () Me . SuspendLayout () " "Li stView1 ' Me.ListView1.Location = New System.Drawing.Point ( 8 , 16 ) Me.ListView1.MultiSelect = false Me.ListView1.Name = "ListView1" Me.ListView1.Size = Sistem . Drawing.Size ( 304 , 232 ) Me.ListView1.TabIndex = 0 Me.ListView1.View = System.Windows.Forms.View.Details ' 'Pi ctureBox1 Ca apel

Boolea

' Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle. Fixed3D Me.PictureBox1.Location = New System.Drawing.Point ( 320 , 16 ) Me.PictureBox1.Name = "PictureBox1" Me.PictureBox1.Size = New System.Drawing.Size ( 600 , 568 ) Me.PictureBox1.TabIndex = 1 Me.PictureBox1.TabStop = False ' 'Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 8 , 256 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing. Dimensiune ( 64 , 24 ) Me.Button1.TabIndex = 2 Me.Button1.Text = "Drum nou:" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 8 , 288 ) Me.TextBox1. name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 256 , 20 ) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "c: \ winnt" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 804 , 585 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.TextBox1, Me.But Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub

# End Regiunea Private Sub ListView1_SelectedIndexChanged ( expeditor ByVal Ca System.Object, ByVa PictureBox1.Image = Image.FromFile ( ListView1.FocusedItem.Text ) End Sub

Private Sub Button1_Click ( ByVal expeditor Ca System.Object, ByVal e ca System.E ListView1.Columns.Clear () ListView1.View = View.Details ListView1.Columns.Add ( "Nume fiier" , 100 , HorizontalAlignment. stnga ) ListView1.Columns.Add ( "extindere" , 50 , HorizontalAlignment.Left ) ListView1.Columns.Add ( "Bytes" , 50 , HorizontalAlignment.Right ) Dim DI Ca System.IO.DirectoryInfo = New System.IO.DirectoryInfo ( "C: \") fiiere Dim () ca System.IO.FileInfo = DI.GetFiles fiier Dim Ca System.IO.FileInfo pentru fiecare fiier din fiiere Selectai Cazul file.Extension "caz . jpeg "," . gif "," . bmp "," . jpg "," . tif "," . tiff "," . Avi " Dim li Ca noi

Selectai Urmtorul End Sub

End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class AddImageFileToListView public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents ListView1 As System.Windows.Forms.ListView Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.ListView1 = New System.Windows.Forms.ListView() Me.PictureBox1 = New System.Windows.Forms.PictureBox() Me.Button1 = New System.Windows.Forms.Button() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.SuspendLayout() ' 'ListView1 ' Me.ListView1.Location = New System.Drawing.Point(8, 16) Me.ListView1.MultiSelect = False Me.ListView1.Name = "ListView1" Me.ListView1.Size = New System.Drawing.Size(304, 232) Me.ListView1.TabIndex = 0 Me.ListView1.View = System.Windows.Forms.View.Details ' 'PictureBox1 ' Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.PictureBox1.Location = New System.Drawing.Point(320, 16) Me.PictureBox1.Name = "PictureBox1" Me.PictureBox1.Size = New System.Drawing.Size(600, 568) Me.PictureBox1.TabIndex = 1 Me.PictureBox1.TabStop = False ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(8, 256)

Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(64, 24) Me.Button1.TabIndex = 2 Me.Button1.Text = "New Path:" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(8, 288) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(256, 20) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "c:\winnt" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(804, 585) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox1, Me.Button1 Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub

#End Region Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As S PictureBox1.Image = Image.FromFile(ListView1.FocusedItem.Text) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) ListView1.Columns.Clear() ListView1.View = View.Details ListView1.Columns.Add("Filename", 100, HorizontalAlignment.Left) ListView1.Columns.Add("Extension", 50, HorizontalAlignment.Left) ListView1.Columns.Add("Bytes", 50, HorizontalAlignment.Right) Dim DI As System.IO.DirectoryInfo = New System.IO.DirectoryInfo("c:\") Dim files() As System.IO.FileInfo = DI.GetFiles Dim file As System.IO.FileInfo For Each file In files Select Case file.Extension Case ".jpeg", ".gif", ".bmp", ".jpg", ".tif", ".tiff", ".avi" Dim li As New ListViewItem(file.FullName) li.SubItems.Add(file.Extension) li.SubItems.Add(file.Length) ListView1.Items.Add(li) End Select Next End Sub End Class

Runtime ListView

"Vi SUAL de baz 2005 Programator 's ", cu Rod Stephens ( Autor ) "# "# "# "# Publisher: Wrox ( octombrie Limba: englez ISBN- 10 : 0764571982 ISBN- 13 : 978 - 0764571985 System.Windows.Forms 21 ,

de referin 2005 )

Importurile

public class ListViewRunTime public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e "M ake anteturile de coloan ListView . ListViewMakeColumnHeaders ( lvwBooks, _ "Titlu" , HorizontalAlignment.Left, 120 , _ "URL-ul" , HorizontalAlignment.Left, 120 , _ "ISBN" , HorizontalAlignment.Left, 90 , _ "Picture" , HorizontalAlignment.Left, 120 , _ "Pagini" , HorizontalAlignment.Right, 50 , _ "An" , HorizontalAlignment.Right, 40 ) ListViewMakeRow ( lvwBooks, 0 , _ ", Visual Basic i XML" , _ "http://www.vb-helper.com/xml.htm" , _ "0-471-12060-X" , _ "http:// www.vb-helper.com/xml.jpg " , _ "503" , _ "2002" ) ListViewMakeRow ( lvwBooks, 0 , _ "Visual Basic Graphics programare, 2e" , _ "http://www.vb-helper .com / vbgp.htm " , _ "0-471-35599-2" , _ "http://www.vb-helper.com/vbgp.jpg" , _ "712" , _

ca

System.Ev

"2000" ) ListViewMakeRow ( lvwBooks, 0 , _ "Algoritmi Ready-to-Run Visual Basic" , _ "http://www.vb-helper.com/vba.htm" , _ "0-471-24268-3" , _ "http: / / www.vb-helper.com/vba.jpg " , _ "395" , _ "1998" ) ListViewSizeColumns ( lvwBooks, Adevrat ) Text = "RunTimeListView (" & lvwBooks.View.ToString & lvwBooks.View = View.Details CheckMenus () End Sub ")"

"M ake ListView s anteturile de coloan. " T el intrri ParamArray ar trebui s fie triple dein "C olumn titlu, valoare HorizontalAlignment, i limea. Private Sub ListViewMakeColumnHeaders ( ByVal LVW Ca ListView, ByVal ParamArray h "R liminai orice antete existente. lvw.Columns.Clear ()

"M ake anteturile de coloan. Pentru i Ca Integer = header_info.GetLowerBound ( 0 ) Pentru a header_info.Ge Dim col_header Ca ColumnHeader = lvw.Columns.Add ( _ DirectCast ( header_info ( i ) , String ) , _ - 1 , _ DirectCast ( header_info ( i + 1 ) , HorizontalAlignment )) col_header.Width = DirectCast ( header_info ( i + 2 ) , Integer ) Urmtorul i End Sub "M ake-un rnd ListView. Private Sub ListViewMakeRow ( ByVal LVW Ca ListView, ByVal image_index "M ake elementul. Dim new_item Ca ListViewItem = lvw.Items.Add ( item_title ) new_item.ImageIndex = image_index "M ake sub-produs. Pentru i ca Integer = subitem_titles.GetLowerBound ( 0 ) new_item.SubItems.Add ( subitem_titles ( i )) Apoi am End Sub Ca

Integ

Pentru a subitem_tit

"S et limi de coloan pentru a - 1 pentru a se potrivi de date, "- 2 . pentru a se potrivi de date i antet Private Sub ListViewSizeColumns ( ByVal LVW Ca ListView, ByVal allow_room_for_hea Dim new_wid Ca Integer = - 1 Dac allow_room_for_header Apoi new_wid = - 2 "S et limea pentru fiecare coloan. Pentru i ca Integer = 0 Pentru a lvw.Columns.Count lvw.Columns ( i ) . Lime = new_wid Urmtor i End Sub 1

Private Sub mnuViewDetails_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.Details Text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub

ca

Private Sub mnuViewLargeIcons_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.LargeIcon text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub Private Sub mnuViewList_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.List text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub ca

Sy

Private Sub mnuViewSmallIcons_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.SmallIcon text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub Private Sub mnuViewTile_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.Tile text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub Private Sub CheckMenus () mnuViewDetails.Checked = ( lvwBooks.View = View.Details ) mnuViewLargeIcons.Checked = ( lvwBooks.View = View.LargeIcon ) mnuViewList.Checked = ( lvwBooks.View = View.List ) mnuViewSmallIcons.Checked = ( lvwBooks . Vezi = View.SmallIcon ) mnuViewTile.Checked = ( lvwBooks.View = View.Tile ) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.components = New System.ComponentModel.Container Me.MenuStrip1 = New System.Windows.Forms.MenuStrip Me.ViewToolStripMenuItem = noi System.Windows.Forms.ToolStripMenuItem Me.mnuViewDetails = New System.Windows.Forms.ToolStripMenuItem Me.mnuViewLargeIcons = New System.Windows.Forms.ToolStripMenuItem Me.mnuViewList = New System.Windows.Forms.ToolStripMenuItem Me.mnuViewSmallIcons = New System.Windows.Forms.ToolStripMenuItem ca

Sy

Ca

Bool

Me.mnuViewTile = New System.Windows.Forms.ToolStripMenuItem Me.lvwBooks = Nou

System.Windows.Forms.ToolStripItem () { Me.ViewToolStripMenuItem }) Me.MenuStrip1.Location = New System.Drawing.Point ( 0 , 0 ) Me.MenuStrip1.Name = "MenuStrip1" Me.MenuStrip1.Size = Sistem. Drawing.Size ( 592 , 24 ) Me.MenuStrip1.TabIndex = 2 Me.MenuStrip1.Text = "MenuStrip1" " "Vi ewToolStripMenuItem " Me.ViewToolStripMenuItem.DropDownItems.AddRange ( New System.Windows.Forms.ToolS Me.ViewToolStripMenuItem.Name = "ViewToolStripMenuItem" Me.ViewToolStripMenuItem.Text = "& View" " "milioane uViewDetails ' Me.mnuViewDetails.Name = "mnuViewDetails " Me.mnuViewDetails.Text = "& detalii" " "milioane uViewLargeIcons ' Me.mnuViewLargeIcons.Name = "mnuViewLargeIcons" Me.mnuViewLargeIcons.Text = "Pictograme mari" " "milioane uViewList ' Me.mnuViewList.Name = "mnuViewList" Me. mnuViewList.Text = "& List" " "milioane uViewSmallIcons ' Me.mnuViewSmallIcons.Name = "mnuViewSmallIcons" Me.mnuViewSmallIcons.Text = "& Small Icons" " "milioane uViewTile ' Me.mnuViewTile.Name = "mnuViewTile" Me.mnuViewTile.Text = "placi" " "LV wBooks ' Me.lvwBooks.Dock = System.Windows.Forms.DockStyle.Fill Me.lvwBooks.Location = New System.Drawing.Point ( 0 , 24 ) Me.lvwBooks.Name = "lvwBooks" Me.lvwBooks.Size = New System.Drawing.Size ( 592 , 249 ) Me.lvwBooks.TabIndex = 1 Me.lvwBooks.View = System.Windows.Forms.View.Details ' 'Fo RM1 ' Me.AutoScaleDimensions = Sistem . Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 592 , 273 ) Me.Controls.Add ( Me.lvwBooks ) Me . Controls.Add ( Me.MenuStrip1 )

Me.Name = "Form1" Me.Text = "RunTimeListView" Me.MenuStrip1.ResumeLayout ( Fals ) Me.ResumeLayout ( False ) Me.PerformLayout ()

Sub End prieten WithEvents MenuStrip1 Ca System.Windows.Forms.MenuStrip prieten WithEvents ViewToolStripMenuItem Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents mnuViewDetails Ca System.Windows.Forms.ToolStripMenuItem prieten mnuViewLargeIcons WithEvents Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents mnuViewList Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents mnuViewSmallIcons Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents mnuViewTile Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents lvwBooks Ca System.Windows.Forms.ListView End Class

Original

"Vi SUAL de baz 2005 Programator 's ", cu Rod Stephens ( Autor ) "# "# "# "# Publisher: Wrox ( octombrie Limba: englez ISBN- 10 : 0764571982 ISBN- 13 : 978 - 0764571985 System.Windows.Forms 21 ,

de referin 2005 )

Importurile

public class ListViewRunTime public comun Sub principal Application.Run ( New Form1 )

End Sub End clasa public class Form1 Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e "M ake anteturile de coloan ListView . ListViewMakeColumnHeaders ( lvwBooks, _ "Titlu" , HorizontalAlignment.Left, 120 , _ "URL-ul" , HorizontalAlignment.Left, 120 , _ "ISBN" , HorizontalAlignment.Left, 90 , _ "Picture" , HorizontalAlignment.Left, 120 , _ "Pagini" , HorizontalAlignment.Right, 50 , _ "An" , HorizontalAlignment.Right, 40 ) ListViewMakeRow ( lvwBooks, 0 , _ ", Visual Basic i XML" , _ "http://www.vb-helper.com/xml.htm" , _ "0-471-12060-X" , _ "http:// www.vb-helper.com/xml.jpg " , _ "503" , _ "2002" ) ListViewMakeRow ( lvwBooks, 0 , _ "Visual Basic Graphics programare, 2e" , _ "http://www.vb-helper .com / vbgp.htm " , _ "0-471-35599-2" , _ "http://www.vb-helper.com/vbgp.jpg" , _ "712" , _ "2000" ) ListViewMakeRow ( lvwBooks, 0 , _ "Algoritmi Ready-to-Run Visual Basic" , _ "http://www.vb-helper.com/vba.htm" , _ "0-471-24268-3" , _ "http: / / www.vb-helper.com/vba.jpg " , _ "395" , _ "1998" ) ListViewSizeColumns ( lvwBooks, Adevrat ) Text = "RunTimeListView (" & lvwBooks.View.ToString & lvwBooks.View = View.Details CheckMenus () End Sub ")"

ca

System.Ev

"M ake ListView s anteturile de coloan. " T el intrri ParamArray ar trebui s fie triple dein "C olumn titlu, valoare HorizontalAlignment, i limea. Private Sub ListViewMakeColumnHeaders ( ByVal LVW Ca ListView, ByVal ParamArray h "R liminai orice antete existente. lvw.Columns.Clear ()

"M ake anteturile de coloan. Pentru i Ca Integer = header_info.GetLowerBound ( 0 ) Pentru a header_info.Ge Dim col_header Ca ColumnHeader = lvw.Columns.Add ( _ DirectCast ( header_info ( i ) , String ) , _ - 1 , _ DirectCast ( header_info ( i + 1 ) , HorizontalAlignment )) col_header.Width = DirectCast ( header_info ( i + 2 ) , Integer ) Urmtorul i End Sub "M ake-un rnd ListView. Private Sub ListViewMakeRow ( ByVal LVW "M ake elementul. Ca ListView, ByVal image_index Ca

Integ

Dim new_item Ca ListViewItem = lvw.Items.Add ( item_title ) new_item.ImageIndex = image_index "M ake sub-produs. Pentru i ca Integer = subitem_titles.GetLowerBound ( 0 ) new_item.SubItems.Add ( subitem_titles ( i )) Apoi am End Sub

Pentru a subitem_tit

"S et limi de coloan pentru a - 1 pentru a se potrivi de date, "- 2 . pentru a se potrivi de date i antet Private Sub ListViewSizeColumns ( ByVal LVW Ca ListView, ByVal allow_room_for_hea Dim new_wid Ca Integer = - 1 Dac allow_room_for_header Apoi new_wid = - 2 "S et limea pentru fiecare coloan. Pentru i ca Integer = 0 Pentru a lvw.Columns.Count lvw.Columns ( i ) . Lime = new_wid Urmtor i End Sub 1

Private Sub mnuViewDetails_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.Details Text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub

ca

Private Sub mnuViewLargeIcons_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.LargeIcon text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub Private Sub mnuViewList_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.List text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub ca

Sy

Private Sub mnuViewSmallIcons_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.SmallIcon text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub Private Sub mnuViewTile_Click ( ByVal expeditor Ca System.Object, ByVal e lvwBooks.View = View.Tile text = "RunTimeListView (" & lvwBooks.View.ToString & ")" CheckMenus () End Sub Private Sub CheckMenus () mnuViewDetails.Checked = ( lvwBooks.View = View.Details ) mnuViewLargeIcons.Checked = ( lvwBooks.View = View.LargeIcon ) mnuViewList.Checked = ( lvwBooks.View = View.List ) mnuViewSmallIcons.Checked = ( lvwBooks . Vezi = View.SmallIcon ) mnuViewTile.Checked = ( lvwBooks.View = View.Tile ) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 ca

Sy

Motenete

System.Windows.Forms.Form

"Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.components = New System.ComponentModel.Container Me.MenuStrip1 = New System.Windows.Forms.MenuStrip Me.ViewToolStripMenuItem = noi System.Windows.Forms.ToolStripMenuItem Me.mnuViewDetails = New System.Windows.Forms.ToolStripMenuItem Me.mnuViewLargeIcons = New System.Windows.Forms.ToolStripMenuItem Me.mnuViewList = New System.Windows.Forms.ToolStripMenuItem Me.mnuViewSmallIcons = New System.Windows.Forms.ToolStripMenuItem Me.mnuViewTile = New System.Windows.Forms.ToolStripMenuItem Me.lvwBooks = Nou

System.Windows.Forms.ToolStripItem () { Me.ViewToolStripMenuItem }) Me.MenuStrip1.Location = New System.Drawing.Point ( 0 , 0 ) Me.MenuStrip1.Name = "MenuStrip1" Me.MenuStrip1.Size = Sistem. Drawing.Size ( 592 , 24 ) Me.MenuStrip1.TabIndex = 2 Me.MenuStrip1.Text = "MenuStrip1" " "Vi ewToolStripMenuItem " Me.ViewToolStripMenuItem.DropDownItems.AddRange ( New System.Windows.Forms.ToolS Me.ViewToolStripMenuItem.Name = "ViewToolStripMenuItem" Me.ViewToolStripMenuItem.Text = "& View" " "milioane uViewDetails ' Me.mnuViewDetails.Name = "mnuViewDetails " Me.mnuViewDetails.Text = "& detalii" " "milioane uViewLargeIcons ' Me.mnuViewLargeIcons.Name = "mnuViewLargeIcons" Me.mnuViewLargeIcons.Text = "Pictograme mari" " "milioane uViewList ' Me.mnuViewList.Name = "mnuViewList" Me. mnuViewList.Text = "& List" "

"milioane uViewSmallIcons ' Me.mnuViewSmallIcons.Name = "mnuViewSmallIcons" Me.mnuViewSmallIcons.Text = "& Small Icons" " "milioane uViewTile ' Me.mnuViewTile.Name = "mnuViewTile" Me.mnuViewTile.Text = "placi" " "LV wBooks ' Me.lvwBooks.Dock = System.Windows.Forms.DockStyle.Fill Me.lvwBooks.Location = New System.Drawing.Point ( 0 , 24 ) Me.lvwBooks.Name = "lvwBooks" Me.lvwBooks.Size = New System.Drawing.Size ( 592 , 249 ) Me.lvwBooks.TabIndex = 1 Me.lvwBooks.View = System.Windows.Forms.View.Details ' 'Fo RM1 ' Me.AutoScaleDimensions = Sistem . Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 592 , 273 ) Me.Controls.Add ( Me.lvwBooks ) Me . Controls.Add ( Me.MenuStrip1 ) Me.Name = "Form1" Me.Text = "RunTimeListView" Me.MenuStrip1.ResumeLayout ( Fals ) Me.ResumeLayout ( False ) Me.PerformLayout ()

Sub End prieten WithEvents MenuStrip1 Ca System.Windows.Forms.MenuStrip prieten WithEvents ViewToolStripMenuItem Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents mnuViewDetails Ca System.Windows.Forms.ToolStripMenuItem prieten mnuViewLargeIcons WithEvents Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents mnuViewList Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents mnuViewSmallIcons Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents mnuViewTile Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents lvwBooks Ca System.Windows.Forms.ListView End Class

Create Meniu n codul dvs.

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class MenuCreationInCode public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Dim Dim Dim Dim Dim mainMenu1 WithEvents WithEvents WithEvents WithEvents Ca New MainMenu Ca Ca Ca Ca New New New New MenuItem MenuItem MenuItem MenuItem

menuItem1 menuItem2 menuItem3 menuItem4

Public Sub New () MyBase.New () Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) menuItem1.Text = "File" menuItem2.Text = "Punctul 1" menuItem3.Text = "Punctul 2" menuItem3.Checked = True menuItem4.Text = "Exit" menuItem4.Shortcut =

menuItem4.Click, AddressOf MenuItem4_Click mainMenu1.MenuItems.Add ( menuItem1 ) Meniu = mainMenu1

End Sub Private Sub ByVal e ca MenuItem4_Click ( ByVal expeditor System.EventArgs ) Ca System.Object, _

Console.WriteLine ( "aciune" ) End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class MenuCreationInCode public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Dim mainMenu1 As New MainMenu Dim Dim Dim Dim WithEvents WithEvents WithEvents WithEvents menuItem1 menuItem2 menuItem3 menuItem4 As As As As New New New New MenuItem MenuItem MenuItem MenuItem

Public Sub New()

MyBase.New() Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) menuItem1.Text = "File" menuItem2.Text = "Item 1" menuItem3.Text = "Item 2" menuItem3.Checked = True menuItem4.Text = "Exit" menuItem4.Shortcut = Shortcut.CtrlX menuItem2.MenuItems.Add(menuItem3) menuItem1.MenuItems.Add(menuItem2) menuItem1.MenuItems.Add(menuItem4) AddHandler menuItem4.Click, AddressOf MenuItem4_Click mainMenu1.MenuItems.Add(menuItem1) Menu = mainMenu1 End Sub Private Sub MenuItem4_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Console.WriteLine("action") End Sub End Class

Meniu 14.17.2.Add a Forma fereastr i ataai aciuni

Importurile

System.Windows.Forms

public class CreateMenuAndAttachAction public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form

Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents MainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents MenuItem1 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem2 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem3 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem4 Ca sistem. Windows.Forms.MenuItem prieten WithEvents MenuItem5 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem6 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem7 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem8 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem9 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem10 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem11 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem12 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem13 Ca System.Windows . Forms.MenuItem prieten WithEvents MenuItem14 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem15 Ca System.Windows.Forms.MenuItem prieten WithEvents OpenFileDialog1 Ca System.Windows.Forms.OpenFileDialog prieten WithEvents Sub InitializeComponent () Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem8 = New System.Windows.Forms.MenuItem Me.MenuItem9 = New System.Windows.Forms . MenuItem Me.MenuItem10 = New System.Windows.Forms.MenuItem Me.MenuItem11 = New System.Windows.Forms.MenuItem Me.MenuItem12 = New System.Windows.Forms.MenuItem Me.MenuItem13 = New System.Windows.Forms.MenuItem Me.MenuItem14 = New System.Windows.Forms.MenuItem Me.MenuItem15 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem mine. MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.MenuItem6 = New System.Windows.Forms.MenuItem Me.MenuItem7 = New System.Windows.Forms.MenuItem Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog ' "Ma inMenu1 " Me.MainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.Menu " "Eu nuItem1

' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange ( noi System.Windows.Forms. MenuItem () { Me.Men Me.MenuItem1.Text = "File" " "Me nuItem8 ' Me.MenuItem8.Index = 0 Me.MenuItem8.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.Menu Me.MenuItem8.Text = "Nou" " "Me nuItem9 ' Me.MenuItem9.Index = 0 Me MenuItem9.Text =. "File" " "Me nuItem10 ' Me.MenuItem10.Index = 1 Me.MenuItem10.Text = "Proiectul" " "Me nuItem11 ' Me.MenuItem11.Index = 1 Me.MenuItem11.Text = "Open" " "Eu nuItem12 ' Me.MenuItem12.Index = 2 Me.MenuItem12.Text = "Salvare" " "Me nuItem13 ' Me.MenuItem13.Index = 3 Me.MenuItem13.Text = "-" " "Me nuItem14 " Me.MenuItem14 . index = 4 Me.MenuItem14.Text = "Noua" " "Me nuItem15 ' Me.MenuItem15.Index = 5 Me.MenuItem15.Text = "Add" " "Me nuItem2 ' Me.MenuItem2.Index = 1 Me.MenuItem2. Text = "Edit" " "Me nuItem3 ' Me.MenuItem3.Index = 2 Me.MenuItem3.Text = "View" " "Me nuItem4 ' Me.MenuItem4.Index = 3 Me.MenuItem4.Text = "Proiectul" "

"Me nuItem5 ' Me.MenuItem5.Index = 4 Me.MenuItem5.Text = "Creaza" " "Me nuItem6 ' Me.MenuItem6.Index = 5 Me.MenuItem6.Text = "instrument" " "Me nuItem7 ' Me.MenuItem7.Index = 6 Me.MenuItem7.Text = "Debug" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 368 , 198 ) Me.Menu = Me . MainMenu1 End Sub Private Sub MenuItem11_Click ( ByVal expeditor OpenFileDialog1.ShowDialog () End Sub Private Sub MenuItem12_Click ( ByVal expeditor SaveFileDialog1.ShowDialog () End Sub End Class Ca System.Object, ByVal e ca

Sys

Ca

System.Object, ByVal e

ca

Sys

Original

Imports System.Windows.Forms public class CreateMenuAndAttachAction public Shared Sub Main

Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem8 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem9 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem10 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem11 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem12 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem13 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem14 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem15 As System.Windows.Forms.MenuItem Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem8 = New System.Windows.Forms.MenuItem Me.MenuItem9 = New System.Windows.Forms.MenuItem Me.MenuItem10 = New System.Windows.Forms.MenuItem Me.MenuItem11 = New System.Windows.Forms.MenuItem Me.MenuItem12 = New System.Windows.Forms.MenuItem Me.MenuItem13 = New System.Windows.Forms.MenuItem Me.MenuItem14 = New System.Windows.Forms.MenuItem Me.MenuItem15 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.MenuItem6 = New System.Windows.Forms.MenuItem Me.MenuItem7 = New System.Windows.Forms.MenuItem Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog

Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog ' 'MainMenu1 ' Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem ' 'MenuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem1.Text = "File" ' 'MenuItem8 ' Me.MenuItem8.Index = 0 Me.MenuItem8.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem8.Text = "New" ' 'MenuItem9 ' Me.MenuItem9.Index = 0 Me.MenuItem9.Text = "File" ' 'MenuItem10 ' Me.MenuItem10.Index = 1 Me.MenuItem10.Text = "Project" ' 'MenuItem11 ' Me.MenuItem11.Index = 1 Me.MenuItem11.Text = "Open" ' 'MenuItem12 ' Me.MenuItem12.Index = 2 Me.MenuItem12.Text = "Save" ' 'MenuItem13 ' Me.MenuItem13.Index = 3 Me.MenuItem13.Text = "-" ' 'MenuItem14 ' Me.MenuItem14.Index = 4 Me.MenuItem14.Text = "New" ' 'MenuItem15 ' Me.MenuItem15.Index = 5 Me.MenuItem15.Text = "Add" ' 'MenuItem2 ' Me.MenuItem2.Index = 1 Me.MenuItem2.Text = "Edit" ' 'MenuItem3 ' Me.MenuItem3.Index = 2

Me.MenuItem3.Text = "View" ' 'MenuItem4 ' Me.MenuItem4.Index = 3 Me.MenuItem4.Text = "Project" ' 'MenuItem5 ' Me.MenuItem5.Index = 4 Me.MenuItem5.Text = "Create" ' 'MenuItem6 ' Me.MenuItem6.Index = 5 Me.MenuItem6.Text = "Tool" ' 'MenuItem7 ' Me.MenuItem7.Index = 6 Me.MenuItem7.Text = "Debug" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(368, 198) Me.Menu = Me.MainMenu1 End Sub

Private Sub MenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventA OpenFileDialog1.ShowDialog() End Sub

Private Sub MenuItem12_Click(ByVal sender As System.Object, ByVal e As System.EventA SaveFileDialog1.ShowDialog() End Sub End Class

Meniul 14.17.3.Build n timpul rulrii

"Vi Sual de baz 2005 Soluii Carte de bucate pentru VB 2005 "de Tim Patrick ( Autor ) , John Craig ( autor ) "# Editura: O 'Re illy Media, Inc ( septembrie 21 , 2006 ) "# Limba: englez

Programatorii

"# "#

ISBN - 10 : 0596101775 ISBN- 13 : 978 - 0596101770 MVB = Microsoft.VisualBasic System.Windows.Forms

Importurile Importurile

public class BuildYourOwnMenu public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 private declara funcia Auto GetPrivateProfileString Lib "kernel32" ( APPNAME ByVal Ca String, _ KeyName ByVal Ca String, _ ByVal implicit Ca String, _ ByVal ReturnedString Ca System.Text.StringBuilder, _ ByVal BufferSize Ca Integer, _ ByVal FileName Ca String ) Ca Integer Private Sub MenuExitProgram_Click ( ByVal expeditor Me.Close () End Sub Private Sub Form1_Load ( expeditor ByVal Dim favoritesPath Ca String Ca Ca

System.Object, ByVal e

ca

obiect, ByVal e

ca

System.EventArgs

favoritesPath = Environment.GetFolderPath ( Environment.SpecialFolder.Favorites Dac ( favoritesPath = "" ) apoi s se ntoarc cazul n care ( My.Computer.FileSystem.DirectoryExists ( favoritesPath ) = fal BuildFavorites ( MenuFavorites, favoritesPath ) Dac End Sub Private Sub BuildFavorites ( whichMenu ByVal Ca ToolStripMenuItem, ByVal ( MenuFavorites.DropDownItems.Count> MenuNoFavorites.Visible = false 1 ) Apoi _

Pentru fiecare oneEntry n My.Computer.FileSystem.GetDirectories ( fromPath ) menuEntry = New ToolStripMenuItem ( _ My.Computer.FileSystem.GetName ( oneEntry )) BuildFavorites ( menuEntry, oneEntry ) n cazul n care ( menuEntry.DropDownItems.Count> whichMenu.DropDownItems.Add ( menuEntry ) oneEntry urmtoare 0 ) Apoi _

Pentru fiecare oneEntry n My.Computer.FileSystem.GetFiles ( fromPath, _ FileIO.SearchOption.SearchTopLevelOnly, "*. url" ) linkPath = GetINIEntry ( "InternetShortcut" , "URL-ul" , oneEntry ) Dac ( linkPath <> "" ) Apoi, displayName = My.Computer.FileSystem.GetName ( oneEntry )

displayName = MVB.Left ( displayName, displayName.Length menuEntry = New ToolStripMenuItem ( displayName ) menuEntry.Tag = linkPath whichMenu.DropDownItems.Add ( menuEntry ) AddHandler menuEntry.Click, AddressOf RunFavoritesLink Sfrit dac Urmtor oneEntry End Sub Private Sub RunFavoritesLink ( ByVal expeditor "- ---- Run link-ul. Dim whichMenu Ca ToolStripMenuItem Ca

4 )

System.Object, ByVal e

ca

Sys

whichMenu = Ctype ( expeditor, ToolStripMenuItem ) Console.WriteLine ( whichMenu.Tag ) "Pr ocess.Start ( whichMenu.Tag ) End Sub Privat GetINIEntry Funcia ( numesectiune ByVal Ca String, _ KeyName ByVal Ca String, ByVal whichFile Ca String ) Ca "- ---- Extras o valoare de la un fiier INI-stil. Dim resultLength Ca Integer Dim targetBuffer Ca New System.Text. StringBuilder ( 500 ) String

resultLength = GetPrivateProfileString ( numesectiune, KeyName, targetBuffer, targetBuffer.Capacity, whichFile ) targetBuffer.ToString retur () End Function End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

"" , _

Boolean )

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.MainMenu = New System.Windows.Forms.MenuStrip Me.MenuFile = New System.Windows.Forms.ToolStripMenuItem Me.MenuExitProgram = New System.Windows.Forms.ToolStripMenuItem Me.MenuFavorites = New System.Windows.Forms.ToolStripMenuItem mine. MenuNoFavorites = Nou

System.Windows.Forms.ToolStripItem () { Me.MenuFile, Me.MenuFavorites }) Me.MainMenu.Location = New System.Drawing.Point ( 0 , 0 ) Me.MainMenu.Name = "MainMenu" Me.MainMenu.Size = New System.Drawing.Size ( 292 , 24 ) Me.MainMenu.TabIndex = 0 Me.MainMenu.Text = "MenuStrip1" " "Me nuFile " Me.MenuFile.DropDownItems.AddRange ( New System.Windows.Forms.ToolStripItem ( ) Me.MenuFile.Name = "MenuFile" Me.MenuFile.Size = New System.Drawing.Size ( 35 , 20 ) Me.MenuFile.Text = "& Fiier" " "Me nuExitProgram " Me.MenuExitProgram . Nume = "MenuExitProgram" Me.MenuExitProgram.ShortcutKeys = Ctype (( System.Windows.Forms.Keys.Alt sau Sys Me.MenuExitProgram.Size = New System.Drawing.Size ( 132 , 22 ) Me.MenuExitProgram.Text = "& Ieire" " "Me nuFavorites " Me.MenuFavorites.DropDownItems.AddRange ( New System.Windows.Forms.ToolStripItem Me . MenuFavorites.Name = "MenuFavorites" Me.MenuFavorites.Size = New System.Drawing.Size ( 64 , 20 ) Me.MenuFavorites.Text = "Fa & vorites" " "Me nuNoFavorites " Me.MenuNoFavorites.Enabled = false Me.MenuNoFavorites. name = "MenuNoFavorites" Me.MenuNoFavorites.Size = New System.Drawing.Size ( 112 , 22 ) Me.MenuNoFavorites.Text = "(gol)" " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 292 , 121 ) Me.Controls.Add ( Me.MainMenu ) Me.FormBorderStyle = System.Windows . Forms.FormBorderStyle.FixedSingle Me.MainMenuStrip = Me.MainMenu Me.MaximizeBox = false Me.Name = "Form1" Me.Text = "execuie

End Sub prieten WithEvents MainMenu Ca System.Windows.Forms.MenuStrip prieten WithEvents MenuFile Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents MenuExitProgram Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents MenuFavorites Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents MenuNoFavorites Ca System.Windows.Forms.ToolStripMenuItem

End Class

Original

'Visual Basic 2005 Cookbook Solutions for VB 2005 Programmers 'by Tim Patrick (Author), John Craig (Author) '# Publisher: O'Reilly Media, Inc. (September 21, 2006) '# Language: English '# ISBN-10: 0596101775 '# ISBN-13: 978-0596101770 Imports MVB = Microsoft.VisualBasic Imports System.Windows.Forms public class BuildYourOwnMenu public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Declare Auto Function GetPrivateProfileString Lib "kernel32" _ (ByVal AppName As String, _ ByVal KeyName As String, _ ByVal DefaultValue As String, _ ByVal ReturnedString As System.Text.StringBuilder, _ ByVal BufferSize As Integer, _ ByVal FileName As String) As Integer

Private Sub MenuExitProgram_Click(ByVal sender As System.Object, ByVal e As System.E Me.Close() End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dim favoritesPath As String favoritesPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites) If (favoritesPath = "") Then Return If (My.Computer.FileSystem.DirectoryExists(favoritesPath) = False) Then Return BuildFavorites(MenuFavorites, favoritesPath) If (MenuFavorites.DropDownItems.Count > 1) Then _

MenuNoFavorites.Visible = False End Sub Private Dim Dim Dim Dim

Sub BuildFavorites(ByVal whichMenu As ToolStripMenuItem, ByVal fromPath As S oneEntry As String menuEntry As ToolStripMenuItem linkPath As String displayName As String

For Each oneEntry In My.Computer.FileSystem.GetDirectories(fromPath) menuEntry = New ToolStripMenuItem( _ My.Computer.FileSystem.GetName(oneEntry)) BuildFavorites(menuEntry, oneEntry) If (menuEntry.DropDownItems.Count > 0) Then _ whichMenu.DropDownItems.Add(menuEntry) Next oneEntry For Each oneEntry In My.Computer.FileSystem.GetFiles(fromPath, _ FileIO.SearchOption.SearchTopLevelOnly, "*.url") linkPath = GetINIEntry("InternetShortcut", "URL", oneEntry) If (linkPath <> "") Then displayName = My.Computer.FileSystem.GetName(oneEntry) displayName = MVB.Left(displayName, displayName.Length - 4) menuEntry = New ToolStripMenuItem(displayName) menuEntry.Tag = linkPath whichMenu.DropDownItems.Add(menuEntry) AddHandler menuEntry.Click, AddressOf RunFavoritesLink End If Next oneEntry End Sub

Private Sub RunFavoritesLink(ByVal sender As System.Object, ByVal e As System.EventA ' ----- Run the link. Dim whichMenu As ToolStripMenuItem whichMenu = CType(sender, ToolStripMenuItem) Console.WriteLine(whichMenu.Tag) 'Process.Start(whichMenu.Tag) End Sub Private Function GetINIEntry(ByVal sectionName As String, _ ByVal keyName As String, ByVal whichFile As String) As String ' ----- Extract a value from an INI-style file. Dim resultLength As Integer Dim targetBuffer As New System.Text.StringBuilder(500) resultLength = GetPrivateProfileString(sectionName, keyName, "", _ targetBuffer, targetBuffer.Capacity, whichFile) Return targetBuffer.ToString() End Function End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list.

<System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.MainMenu = New System.Windows.Forms.MenuStrip Me.MenuFile = New System.Windows.Forms.ToolStripMenuItem Me.MenuExitProgram = New System.Windows.Forms.ToolStripMenuItem Me.MenuFavorites = New System.Windows.Forms.ToolStripMenuItem Me.MenuNoFavorites = New System.Windows.Forms.ToolStripMenuItem Me.MainMenu.SuspendLayout() Me.SuspendLayout() ' 'MainMenu ' Me.MainMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.MenuFile Me.MainMenu.Location = New System.Drawing.Point(0, 0) Me.MainMenu.Name = "MainMenu" Me.MainMenu.Size = New System.Drawing.Size(292, 24) Me.MainMenu.TabIndex = 0 Me.MainMenu.Text = "MenuStrip1" ' 'MenuFile ' Me.MenuFile.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me. Me.MenuFile.Name = "MenuFile" Me.MenuFile.Size = New System.Drawing.Size(35, 20) Me.MenuFile.Text = "&File" ' 'MenuExitProgram ' Me.MenuExitProgram.Name = "MenuExitProgram" Me.MenuExitProgram.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System Me.MenuExitProgram.Size = New System.Drawing.Size(132, 22) Me.MenuExitProgram.Text = "E&xit" ' 'MenuFavorites ' Me.MenuFavorites.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() Me.MenuFavorites.Name = "MenuFavorites" Me.MenuFavorites.Size = New System.Drawing.Size(64, 20) Me.MenuFavorites.Text = "Fa&vorites" ' 'MenuNoFavorites ' Me.MenuNoFavorites.Enabled = False Me.MenuNoFavorites.Name = "MenuNoFavorites" Me.MenuNoFavorites.Size = New System.Drawing.Size(112, 22) Me.MenuNoFavorites.Text = "(empty)" '

'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 121) Me.Controls.Add(Me.MainMenu) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MainMenuStrip = Me.MainMenu Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "Runtime Menus" Me.MainMenu.ResumeLayout(False) Me.MainMenu.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class MainMenu As System.Windows.Forms.MenuStrip MenuFile As System.Windows.Forms.ToolStripMenuItem MenuExitProgram As System.Windows.Forms.ToolStripMenuItem MenuFavorites As System.Windows.Forms.ToolStripMenuItem MenuNoFavorites As System.Windows.Forms.ToolStripMenuItem

Meniuri 14.17.4.Using pentru a schimba culorile de font i stiluri

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class FormMenuAction public comun Sub principal Application.Run ( New FrmMenu ) End Sub End clasa Public class FrmMenu Motenete Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New ()

"Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "D isplay eticheta prieten WithEvents lblDisplay Ca Label Ca apel

Boole

"M meniul Ain ( conine meniuri de fiiere i format ) prieten WithEvents mnuMainMenu Ca MainMenu "F ile meniu prieten WithEvents mnuFile Ca MenuItem prieten WithEvents mnuitmAbout Ca MenuItem prieten WithEvents mnuitmExit Ca MenuItem "F meniul ormat ( conine formatul i fontul submeniurile ) prieten WithEvents mnuFormat Ca MenuItem "C olor prieten prieten prieten prieten prieten submeniu WithEvents WithEvents WithEvents WithEvents WithEvents mnuitmColor Ca MenuItem mnuitmBlack Ca MenuItem mnuitmBlue Ca MenuItem mnuitmRed Ca MenuItem mnuitmGreen Ca MenuItem mnuitmFont Ca MenuItem mnuitmTimes Ca MenuItem mnuitmCourier Ca MenuItem mnuitmComic Ca MenuItem mnuitmDash Ca MenuItem mnuitmBold Ca MenuItem mnuitmItalic Ca MenuItem

"F ONT submeniu prieten WithEvents prieten WithEvents prieten WithEvents prieten WithEvents prieten WithEvents prieten WithEvents prieten WithEvents

"Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . mnuitmItalic = New System.Windows.Forms.MenuItem () Me.mnuitmExit = New System.Windows.Forms.MenuItem () Me.mnuitmCourier = New System.Windows.Forms.MenuItem () Me.mnuitmBlue = New System.Windows. Forms.MenuItem () Me.mnuitmGreen = New System.Windows.Forms.MenuItem () Me.mnuMainMenu = New System.Windows.Forms.MainMenu ()

Me.mnuFile = New System.Windows.Forms.MenuItem () Me.mnuitmAbout = New System.Windows.Forms.MenuItem () Me.mnuFormat = New System.Windows.Forms.MenuItem () Me.mnuitmColor = New System.Windows.Forms.MenuItem () Me.mnuitmBlack = New System.Windows.Forms. MenuItem () Me.mnuitmRed = New System.Windows.Forms.MenuItem () Me.mnuitmFont = New System.Windows.Forms.MenuItem () Me.mnuitmTimes = New System.Windows.Forms.MenuItem () Me.mnuitmComic = Nou System.Windows.Forms.MenuItem () Me.mnuitmDash = New System.Windows.Forms.MenuItem () Me.mnuitmBold = New System.Windows.Forms.MenuItem () Me.lblDisplay = New System.Windows.Forms.Label ( ) Me.SuspendLayout () " "mil lei uitmItalic ' Me.mnuitmItalic.Index = 5 Me.mnuitmItalic.Text = "Italic" ' 'mil. uitmExit ' Me.mnuitmExit.Index = 1 Me.mnuitmExit.Text = "Exit" " " mil. uitmCourier ' Me.mnuitmCourier.Index = 1 Me.mnuitmCourier.Text = "Curier" " "milioane uitmBlue ' Me.mnuitmBlue.Index = 1 Me.mnuitmBlue.RadioCheck = True Me.mnuitmBlue.Text = "Blue" " "mil lei uitmGreen ' Me.mnuitmGreen.Index = 3 Me.mnuitmGreen.RadioCheck = True Me.mnuitmGreen.Text = "verde" ' 'mil. uMainMenu " Me.mnuMainMenu.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me . mn " "mil lei uFile ' Me.mnuFile.Index = 0 Me.mnuFile.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuitmAb Me. mnuFile.Text = "File" " "milioane uitmAbout ' Me.mnuitmAbout.Index = 0 Me.mnuitmAbout.Text = "About" " "milioane uFormat ' Me.mnuFormat.Index = 1 Me.mnuFormat.MenuItems.AddRange ( nou sistem de . Windows.Forms.MenuItem () { Me.m Me.mnuFormat.Text = "Format"

' 'mil. uitmColor ' Me.mnuitmColor.Index = 0 Me.mnuitmColor.MenuItems.AddRange ( nou sistem. Windows.Forms.MenuItem () { Me.mnu Me.mnuitmColor.Text = "color" " "milioane uitmBlack ' Me.mnuitmBlack.Index = 0 Me.mnuitmBlack. RadioCheck = True Me.mnuitmBlack.Text = "Black" " "milioane uitmRed ' Me.mnuitmRed.Index = 2 Me.mnuitmRed.RadioCheck = True Me.mnuitmRed.Text = "Red" " "milioane uitmFont " Me.mnuitmFont.Index = 1 Me.mnuitmFont.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuit Me.mnuitmFont. Text = "Font" " "milioane uitmTimes ' Me.mnuitmTimes.Index = 0 Me.mnuitmTimes.Text = "Times New Roman" ' 'mil. uitmComic ' Me.mnuitmComic.Index = 2 Me.mnuitmComic.Text = "Comic Sans" " 'mil. uitmDash ' Me.mnuitmDash.Index = 3 Me.mnuitmDash.Text = "-" ' 'mil. uitmBold ' Me.mnuitmBold.Index = 4 Me.mnuitmBold.Text = "Bold" " "lb lDisplay " Me.lblDisplay . Font = New System.Drawing.Font ( "Times New Roman" , 26.25 !, Sys Me.lblDisplay.Location = Sistem . Drawing.Point ( 8 , 8 ) Me.lblDisplay.Name = "lblDisplay" Me.lblDisplay.Size = New System.Drawing.Size ( 240 , 48 ) Me.lblDisplay.TabIndex = 0 Me.lblDisplay.Text = "www . Java2s.com " ' "Parintele mMenu ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 256 , 121 ) Me.Controls.AddRange ( New System.Windows . Forms.Control () { Me.lblDisplay }) Me.Menu = Me.mnuMainMenu Me.Name = "FrmMenu"

Me.Text = "MenuTest" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

Private Sub mnuitmAbout_Click _ ( expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmAbout.Click MessageBox.Show ( "Acesta este un exemplu" & vbCrLf & _ "de utilizare a meniurilor." , "Despre" , MessageBoxButtons.OK, _ MessageBoxIcon.Information ) End Sub Private Sub mnuitmExit_Click _ ( expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmExit.Click Application.Exit () End Sub Private Sub ClearColor () mnuitmBlack.Checked = false mnuitmBlue.Checked = false mnuitmRed.Checked = false mnuitmGreen.Checked = False End Sub Private Sub mnuitmBlack_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System . EventArgs ) Manere mnuitmBlack.Click ClearColor () lblDisplay.ForeColor = Color.Black mnuitmBlack.Checked = True End Sub Private Sub mnuitmBlue_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmBlue.Click ClearColor () lblDisplay.ForeColor = Color.Blue mnuitmBlue.Checked = True End Sub Private Sub mnuitmRed_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmRed.Click ClearColor () lblDisplay.ForeColor = Color.Red mnuitmRed.Checked = True End Sub Private Sub mnuitmGreen_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmGreen.Click ClearColor () lblDisplay.ForeColor = Color.Green mnuitmGreen.Checked = True End Sub

Private Sub ClearFont () mnuitmTimes.Checked = false mnuitmCourier.Checked = false mnuitmComic.Checked = False End Sub Private Sub mnuitmTimes_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmTimes.Click ClearFont () mnuitmTimes.Checked = True lblDisplay.Font = New Font ( "Times New Roman" , lblDisplay.Font.Style ) End Sub 30 , _

Private Sub mnuitmCourier_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmCourier . Apsai ClearFont () mnuitmCourier.Checked = True lblDisplay.Font = New Font ( "Courier New" , 30 , _ lblDisplay.Font.Style ) End Sub Private Sub mnuitmComic_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmComic. clic ClearFont () mnuitmComic.Checked = True lblDisplay.Font = New Font ( "Comic Sans MS" , lblDisplay.Font.Style ) End Sub 30 , _

Private Sub mnuitmBold_Click _ ( expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmBold.Click mnuitmBold.Checked = Nu mnuitmBold.Checked lblDisplay.Font = New Font ( "Times New Roman" , End Sub

30 , lblDisplay.Font.Style XOR F

Private Sub mnuitmItalic_Click _ ( expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) Manere mnuitmItalic.Click mnuitmItalic.Checked = Nu mnuitmItalic.Checked lblDisplay.Font = New Font ( "Times New Roman" , End Sub End Class

30 , lblDisplay.Font.Style XOR F

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class FormMenuAction public Shared Sub Main Application.Run(New FrmMenu) End Sub End class Public Class FrmMenu Inherits Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub ' display label Friend WithEvents lblDisplay As Label ' main menu (contains file and format menus) Friend WithEvents mnuMainMenu As MainMenu ' file Friend Friend Friend menu WithEvents mnuFile As MenuItem WithEvents mnuitmAbout As MenuItem WithEvents mnuitmExit As MenuItem

' format menu (contains format and font submenus) Friend WithEvents mnuFormat As MenuItem ' color submenu Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents ' font Friend Friend Friend Friend Friend Friend Friend submenu WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents mnuitmColor As MenuItem mnuitmBlack As MenuItem mnuitmBlue As MenuItem mnuitmRed As MenuItem mnuitmGreen As MenuItem mnuitmFont As MenuItem mnuitmTimes As MenuItem mnuitmCourier As MenuItem mnuitmComic As MenuItem mnuitmDash As MenuItem mnuitmBold As MenuItem mnuitmItalic As MenuItem

'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.mnuitmItalic = New System.Windows.Forms.MenuItem() Me.mnuitmExit = New System.Windows.Forms.MenuItem() Me.mnuitmCourier = New System.Windows.Forms.MenuItem() Me.mnuitmBlue = New System.Windows.Forms.MenuItem() Me.mnuitmGreen = New System.Windows.Forms.MenuItem() Me.mnuMainMenu = New System.Windows.Forms.MainMenu() Me.mnuFile = New System.Windows.Forms.MenuItem() Me.mnuitmAbout = New System.Windows.Forms.MenuItem() Me.mnuFormat = New System.Windows.Forms.MenuItem() Me.mnuitmColor = New System.Windows.Forms.MenuItem() Me.mnuitmBlack = New System.Windows.Forms.MenuItem() Me.mnuitmRed = New System.Windows.Forms.MenuItem() Me.mnuitmFont = New System.Windows.Forms.MenuItem() Me.mnuitmTimes = New System.Windows.Forms.MenuItem() Me.mnuitmComic = New System.Windows.Forms.MenuItem() Me.mnuitmDash = New System.Windows.Forms.MenuItem() Me.mnuitmBold = New System.Windows.Forms.MenuItem() Me.lblDisplay = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'mnuitmItalic ' Me.mnuitmItalic.Index = 5 Me.mnuitmItalic.Text = "Italic" ' 'mnuitmExit ' Me.mnuitmExit.Index = 1 Me.mnuitmExit.Text = "Exit" ' 'mnuitmCourier ' Me.mnuitmCourier.Index = 1 Me.mnuitmCourier.Text = "Courier" '

'mnuitmBlue ' Me.mnuitmBlue.Index = 1 Me.mnuitmBlue.RadioCheck = True Me.mnuitmBlue.Text = "Blue" ' 'mnuitmGreen ' Me.mnuitmGreen.Index = 3 Me.mnuitmGreen.RadioCheck = True Me.mnuitmGreen.Text = "Green" ' 'mnuMainMenu ' Me.mnuMainMenu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, ' 'mnuFile ' Me.mnuFile.Index = 0 Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuitmAbout, Me.mnuFile.Text = "File " ' 'mnuitmAbout ' Me.mnuitmAbout.Index = 0 Me.mnuitmAbout.Text = "About" ' 'mnuFormat ' Me.mnuFormat.Index = 1 Me.mnuFormat.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuitmColo Me.mnuFormat.Text = "Format" ' 'mnuitmColor ' Me.mnuitmColor.Index = 0 Me.mnuitmColor.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuitmBl Me.mnuitmColor.Text = "Color" ' 'mnuitmBlack ' Me.mnuitmBlack.Index = 0 Me.mnuitmBlack.RadioCheck = True Me.mnuitmBlack.Text = "Black" ' 'mnuitmRed ' Me.mnuitmRed.Index = 2 Me.mnuitmRed.RadioCheck = True Me.mnuitmRed.Text = "Red" ' 'mnuitmFont ' Me.mnuitmFont.Index = 1 Me.mnuitmFont.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuitmTim Me.mnuitmFont.Text = "Font" ' 'mnuitmTimes ' Me.mnuitmTimes.Index = 0 Me.mnuitmTimes.Text = "Times New Roman"

' 'mnuitmComic ' Me.mnuitmComic.Index = 2 Me.mnuitmComic.Text = "Comic Sans" ' 'mnuitmDash ' Me.mnuitmDash.Index = 3 Me.mnuitmDash.Text = "-" ' 'mnuitmBold ' Me.mnuitmBold.Index = 4 Me.mnuitmBold.Text = "Bold" ' 'lblDisplay ' Me.lblDisplay.Font = New System.Drawing.Font("Times New Roman", 26.25!, System.Dra Me.lblDisplay.Location = New System.Drawing.Point(8, 8) Me.lblDisplay.Name = "lblDisplay" Me.lblDisplay.Size = New System.Drawing.Size(240, 48) Me.lblDisplay.TabIndex = 0 Me.lblDisplay.Text = "www.Java2s.com" ' 'FrmMenu ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(256, 121) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblDisplay}) Me.Menu = Me.mnuMainMenu Me.Name = "FrmMenu" Me.Text = "MenuTest" Me.ResumeLayout(False) End Sub #End Region Private Sub mnuitmAbout_Click _ (ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmAbout.Click MessageBox.Show("This is an example" & vbCrLf & _ "of using menus.", "About", MessageBoxButtons.OK, _ MessageBoxIcon.Information) End Sub Private Sub mnuitmExit_Click _ (ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmExit.Click Application.Exit() End Sub Private Sub ClearColor() mnuitmBlack.Checked = False mnuitmBlue.Checked = False mnuitmRed.Checked = False mnuitmGreen.Checked = False End Sub Private Sub mnuitmBlack_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles mnuitmBlack.Click ClearColor() lblDisplay.ForeColor = Color.Black mnuitmBlack.Checked = True End Sub Private Sub mnuitmBlue_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmBlue.Click ClearColor() lblDisplay.ForeColor = Color.Blue mnuitmBlue.Checked = True End Sub Private Sub mnuitmRed_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmRed.Click ClearColor() lblDisplay.ForeColor = Color.Red mnuitmRed.Checked = True End Sub Private Sub mnuitmGreen_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmGreen.Click ClearColor() lblDisplay.ForeColor = Color.Green mnuitmGreen.Checked = True End Sub Private Sub ClearFont() mnuitmTimes.Checked = False mnuitmCourier.Checked = False mnuitmComic.Checked = False End Sub Private Sub mnuitmTimes_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmTimes.Click ClearFont() mnuitmTimes.Checked = True lblDisplay.Font = New Font("Times New Roman", 30, _ lblDisplay.Font.Style) End Sub Private Sub mnuitmCourier_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmCourier.Click ClearFont() mnuitmCourier.Checked = True lblDisplay.Font = New Font("Courier New", 30, _ lblDisplay.Font.Style) End Sub Private Sub mnuitmComic_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmComic.Click ClearFont()

mnuitmComic.Checked = True lblDisplay.Font = New Font("Comic Sans MS", 30, _ lblDisplay.Font.Style) End Sub Private Sub mnuitmBold_Click _ (ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmBold.Click mnuitmBold.Checked = Not mnuitmBold.Checked

lblDisplay.Font = New Font("Times New Roman", 30, lblDisplay.Font.Style Xor FontSt End Sub Private Sub mnuitmItalic_Click _ (ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuitmItalic.Click mnuitmItalic.Checked = Not mnuitmItalic.Checked

lblDisplay.Font = New Font("Times New Roman", 30, lblDisplay.Font.Style Xor FontSt End Sub End Class

Meniul 14.17.5.Owner remiz

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class OwnerDrawMenuAndSubmenu public comun Sub principal Application.Run ( New Form1 )

End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents MainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents MenuItem1 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem2 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem3 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem4 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem5 Ca System.Windows.Forms. MenuItem prieten WithEvents MenuItem6 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem7 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem8 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem9 Ca System.Windows.Forms.MenuItem <System.Diagnostics. DebuggerStepThrough () > Private Sub InitializeComponent () Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem7 = Nou System.Windows.Forms.MenuItem Me.MenuItem8 = New System.Windows.Forms.MenuItem Me.MenuItem9 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.MenuItem4 = Sistem. Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.MenuItem6 = New System.Windows.Forms.MenuItem Me.SuspendLayout () " "Ma inMenu1 " Me.MainMenu1.MenuItems.AddRange ( nou sistem. Windows.Forms.MenuItem () { Me.Men "

"Eu nuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.Menu Me.MenuItem1.Text = "& Fiier" " "Me nuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.MenuItems.AddRange ( New System.Windows.Forms . MenuItem () { Me.Me Me.MenuItem2.Text = "Punctul 1" " "Me nuItem7 ' Me.MenuItem7.Index = 0 Me.MenuItem7.OwnerDraw = True Me.MenuItem7 . Text = "Punctul 5" " "Me nuItem8 ' Me.MenuItem8.Checked = True Me.MenuItem8.Index = 1 Me.MenuItem8.Text = "Punctul 6" " "Me nuItem9 ' Me.MenuItem9.Index = 2 Me. MenuItem9.Text = "punctul 7" " "Me nuItem3 ' Me.MenuItem3.Index = 1 Me.MenuItem3.Text = "Punctul 2" ' 'Me nuItem4 ' Me.MenuItem4.Index = 2 Me.MenuItem4.Text = "Postul 3 " " "Me nuItem5 ' Me.MenuItem5.Index = 3 Me.MenuItem5.Text = "-" " "Me nuItem6 ' Me.MenuItem6.Index = 4 Me.MenuItem6.Shortcut = System.Windows.Forms.Shortcut.CtrlX Me.MenuItem6.Text = "& Ieire" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Menu = Me. MainMenu1 Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub

# End

Regiunea MenuItem6_Click ( ByVal expeditor Ca System.Object, ByVal e ca

Private Sub End End Sub

Syst

Private Sub MenuItem9_Click ( ByVal expeditor MsgBox ( "Ai fcut clic Punctul 7." ) End Sub Private Sub MenuItem8_Click ( ByVal expeditor MenuItem8.Checked = Nu MenuItem8.Checked End Sub Private Sub MenuItem4_Click ( ByVal expeditor MenuItem4.Visible = false End Sub Private Sub MenuItem3_Click ( ByVal expeditor MenuItem3.Enabled = false End Sub

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

Private Sub MenuItem7_MeasureItem ( expeditor ByVal e.ItemHeight = 15 e.ItemWidth = 60 End Sub Private Sub MenuItem7_DrawItem ( expeditor ByVal Dim penRed Ca New Pen ( Color.Red ) e.Graphics.DrawEllipse ( penRed, e.Bounds ) End Sub End Class Ca

Ca

obiect, ByVal e

ca

Syste

obiect, e ByVal

Ca

System.W

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class OwnerDrawMenuAndSubmenu public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem8 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem9 As System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem7 = New System.Windows.Forms.MenuItem Me.MenuItem8 = New System.Windows.Forms.MenuItem Me.MenuItem9 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.MenuItem6 = New System.Windows.Forms.MenuItem Me.SuspendLayout() ' 'MainMenu1 ' Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem ' 'MenuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem1.Text = "&File" ' 'MenuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem2.Text = "Item 1" ' 'MenuItem7 ' Me.MenuItem7.Index = 0 Me.MenuItem7.OwnerDraw = True Me.MenuItem7.Text = "Item 5" ' 'MenuItem8 ' Me.MenuItem8.Checked = True Me.MenuItem8.Index = 1 Me.MenuItem8.Text = "Item 6" ' 'MenuItem9 ' Me.MenuItem9.Index = 2 Me.MenuItem9.Text = "Item 7" ' 'MenuItem3 ' Me.MenuItem3.Index = 1

Me.MenuItem3.Text = "Item 2" ' 'MenuItem4 ' Me.MenuItem4.Index = 2 Me.MenuItem4.Text = "Item 3" ' 'MenuItem5 ' Me.MenuItem5.Index = 3 Me.MenuItem5.Text = "-" ' 'MenuItem6 ' Me.MenuItem6.Index = 4 Me.MenuItem6.Shortcut = System.Windows.Forms.Shortcut.CtrlX Me.MenuItem6.Text = "E&xit" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Menu = Me.MainMenu1 Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventAr End End Sub

Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventAr MsgBox("You clicked Item 7.") End Sub

Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventAr MenuItem8.Checked = Not MenuItem8.Checked End Sub

Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventAr MenuItem4.Visible = False End Sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventAr MenuItem3.Enabled = False End Sub

Private Sub MenuItem7_MeasureItem(ByVal sender As Object, ByVal e As System.Windows. e.ItemHeight = 15 e.ItemWidth = 60 End Sub

Private Sub MenuItem7_DrawItem(ByVal sender As Object, ByVal e As System.Windows.For Dim penRed As New Pen(Color.Red) e.Graphics.DrawEllipse(penRed, e.Bounds) End Sub

End Class

Submeniul 14.18.1.Add la meniu

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class OwnerDrawMenuAndSubmenu public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () Ca apel

Bool

End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

"NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents MainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents MenuItem1 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem2 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem3 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem4 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem5 Ca System.Windows.Forms. MenuItem prieten WithEvents MenuItem6 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem7 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem8 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem9 Ca System.Windows.Forms.MenuItem <System.Diagnostics. DebuggerStepThrough () > Private Sub InitializeComponent () Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem7 = Nou System.Windows.Forms.MenuItem Me.MenuItem8 = New System.Windows.Forms.MenuItem Me.MenuItem9 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.MenuItem4 = Sistem. Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.MenuItem6 = New System.Windows.Forms.MenuItem Me.SuspendLayout () " "Ma inMenu1 " Me.MainMenu1.MenuItems.AddRange ( nou sistem. Windows.Forms.MenuItem () { Me.Men " "Eu nuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.Menu Me.MenuItem1.Text = "& Fiier" " "Me nuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.MenuItems.AddRange ( New System.Windows.Forms . MenuItem () { Me.Me Me.MenuItem2.Text = "Punctul 1" " "Me nuItem7 ' Me.MenuItem7.Index = 0 Me.MenuItem7.OwnerDraw = True Me.MenuItem7 . Text = "Punctul 5" " "Me nuItem8 ' Me.MenuItem8.Checked = True Me.MenuItem8.Index = 1 Me.MenuItem8.Text = "Punctul 6"

" "Me nuItem9 ' Me.MenuItem9.Index = 2 Me. MenuItem9.Text = "punctul 7" " "Me nuItem3 ' Me.MenuItem3.Index = 1 Me.MenuItem3.Text = "Punctul 2" ' 'Me nuItem4 ' Me.MenuItem4.Index = 2 Me.MenuItem4.Text = "Postul 3 " " "Me nuItem5 ' Me.MenuItem5.Index = 3 Me.MenuItem5.Text = "-" " "Me nuItem6 ' Me.MenuItem6.Index = 4 Me.MenuItem6.Shortcut = System.Windows.Forms.Shortcut.CtrlX Me.MenuItem6.Text = "& Ieire" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Menu = Me. MainMenu1 Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea MenuItem6_Click ( ByVal expeditor Ca System.Object, ByVal e ca

Private Sub End End Sub

Syst

Private Sub MenuItem9_Click ( ByVal expeditor MsgBox ( "Ai fcut clic Punctul 7." ) End Sub Private Sub MenuItem8_Click ( ByVal expeditor MenuItem8.Checked = Nu MenuItem8.Checked End Sub Private Sub MenuItem4_Click ( ByVal expeditor MenuItem4.Visible = false End Sub Private Sub MenuItem3_Click ( ByVal expeditor MenuItem3.Enabled = false End Sub Private Sub

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

Ca

System.Object, ByVal e

ca

Syst

MenuItem7_MeasureItem ( expeditor ByVal

Ca

obiect, ByVal e

ca

Syste

e.ItemHeight = 15 e.ItemWidth = 60 End Sub Private Sub MenuItem7_DrawItem ( expeditor ByVal Dim penRed Ca New Pen ( Color.Red ) e.Graphics.DrawEllipse ( penRed, e.Bounds ) End Sub End Class Ca obiect, e ByVal Ca

System.W

Original

14.18.1.Add submenu to menu

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class OwnerDrawMenuAndSubmenu public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent()

'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem8 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem9 As System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem7 = New System.Windows.Forms.MenuItem Me.MenuItem8 = New System.Windows.Forms.MenuItem Me.MenuItem9 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.MenuItem6 = New System.Windows.Forms.MenuItem Me.SuspendLayout() ' 'MainMenu1 ' Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem ' 'MenuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem1.Text = "&File" ' 'MenuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem2.Text = "Item 1" ' 'MenuItem7

' Me.MenuItem7.Index = 0 Me.MenuItem7.OwnerDraw = True Me.MenuItem7.Text = "Item 5" ' 'MenuItem8 ' Me.MenuItem8.Checked = True Me.MenuItem8.Index = 1 Me.MenuItem8.Text = "Item 6" ' 'MenuItem9 ' Me.MenuItem9.Index = 2 Me.MenuItem9.Text = "Item 7" ' 'MenuItem3 ' Me.MenuItem3.Index = 1 Me.MenuItem3.Text = "Item 2" ' 'MenuItem4 ' Me.MenuItem4.Index = 2 Me.MenuItem4.Text = "Item 3" ' 'MenuItem5 ' Me.MenuItem5.Index = 3 Me.MenuItem5.Text = "-" ' 'MenuItem6 ' Me.MenuItem6.Index = 4 Me.MenuItem6.Shortcut = System.Windows.Forms.Shortcut.CtrlX Me.MenuItem6.Text = "E&xit" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Menu = Me.MainMenu1 Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventAr End End Sub

Private Sub MenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventAr MsgBox("You clicked Item 7.") End Sub

Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventAr MenuItem8.Checked = Not MenuItem8.Checked End Sub

Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventAr MenuItem4.Visible = False End Sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventAr MenuItem3.Enabled = False End Sub

Private Sub MenuItem7_MeasureItem(ByVal sender As Object, ByVal e As System.Windows. e.ItemHeight = 15 e.ItemWidth = 60 End Sub

Private Sub MenuItem7_DrawItem(ByVal sender As Object, ByVal e As System.Windows.For Dim penRed As New Pen(Color.Red) e.Graphics.DrawEllipse(penRed, e.Bounds) End Sub End Class

Set MenuItem vizibil i invizibil

Importurile

System.Windows.Forms

public class DynamicMenu public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub

Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca

Distrugerea ( ByVal eliminare Apoi

Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents MainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents MenuItem1 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem2 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem3 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem4 Ca sistem. Windows.Forms.MenuItem prieten WithEvents MenuItem5 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem6 Ca System.Windows.Forms.MenuItem prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Button2 Ca System.Windows.Forms.Button prieten WithEvents button3 Ca System.Windows.Forms.Button prieten WithEvents Button4 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = Nou System.Windows.Forms.MenuItem Me.MenuItem6 = New System.Windows.Forms.MenuItem Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Button3 = Sistem. Windows.Forms.Button Me.Button4 = New System.Windows.Forms.Button Me.SuspendLayout () " "Ma inMenu1 " Me.MainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.Menu " "Eu nuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.Menu Me.MenuItem1.Text = "File" " "Eu nuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.Text = "Open" " "Me nuItem3 ' Me.MenuItem3.Index = 1 Me.MenuItem3.MenuItems.AddRange ( New System.Windows.Forms.MenuItem ( ) { Me.Men Me.MenuItem3.Text = "Edit" " "Me nuItem4 ' Me.MenuItem4.Index = 0

Me.MenuItem4.Text = "Cut" " "Me nuItem5 " Me.MenuItem5.Index = 1 Me.MenuItem5.Text = "Copy" " "Me nuItem6 ' Me.MenuItem6.Index = 2 Me.MenuItem6.Text = "Paste" " "Bu tton1 ' Me.Button1.Location = Sistem . Drawing.Point ( 200 , 8 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 72 , 24 ) Me.Button1.TabIndex = 3 Me.Button1.Text = "Selectai " " "Bu tton2 ' Me.Button2.Location = New System.Drawing.Point ( 200 , 48 ) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size ( 72 , 24 ) Me Button2.TabIndex =. 4 Me.Button2.Text = "Disable" " "Bu tton3 ' Me.Button3.Location = New System.Drawing.Point ( 200 , 88 ) Me.Button3.Name = "button3" Me.Button3. size = New System.Drawing.Size ( 72 , 24 ) Me.Button3.TabIndex = 5 Me.Button3.Text = "RadioButon" " "Bu tton4 ' Me.Button4.Location = New System.Drawing.Point ( 200 , 136 ) Me.Button4.Name = "Button4" Me.Button4.Size = New System.Drawing.Size ( 72 , 24 ) Me.Button4.TabIndex = 6 Me.Button4.Text = "Ascunde" " "Fo RM1 " Me. AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= Me.MainMenu1 Me.ResumeLayout ( Fals ) End Sub Private Sub Button1_Click_1 ( expeditor ByVal MenuItem4.RadioCheck = Fals MenuItem5.RadioCheck = false MenuItem6.RadioCheck = false Ca System.Object, ByVal e ca

Syst

MenuItem6.Checked MenuItem4.Checked MenuItem5.Checked MenuItem6.Checked End Sub

= = = =

MenuItem4.Checked Nu MenuItem4 Verificat. Nu MenuItem5.Checked Nu MenuItem6.Checked System.Object, ByVal e ca

Private Sub Button2_Click ( ByVal expeditor Ca MenuItem4.RadioCheck = Fals MenuItem5.RadioCheck = false MenuItem6.RadioCheck = false MenuItem6.Checked = MenuItem4.Checked MenuItem4.Enabled = Nu MenuItem4 . Enabled MenuItem5.Enabled = Nu MenuItem5.Enabled MenuItem6.Enabled = Nu MenuItem6.Enabled End Sub Private Sub Button3_Click ( ByVal expeditor MenuItem4.Checked = Fals MenuItem5.Checked = Fals MenuItem6.Checked = True MenuItem6.RadioCheck = True End Sub Private Sub Button4_Click ( ByVal expeditor MenuItem6.Visible = Nu MenuItem6.Visible End Sub End Class Ca Ca

System

System.Object, ByVal e

ca

System

System.Object, ByVal e

ca

System

Original

Imports System.Windows.Forms public class DynamicMenu public Shared Sub Main Application.Run(New Form1) End Sub

End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer

Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Button4 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.MainMenu1 = New System.Windows.Forms.MainMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.MenuItem4 = New System.Windows.Forms.MenuItem Me.MenuItem5 = New System.Windows.Forms.MenuItem Me.MenuItem6 = New System.Windows.Forms.MenuItem Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Button3 = New System.Windows.Forms.Button Me.Button4 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'MainMenu1 ' Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem ' 'MenuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem1.Text = "File" ' 'MenuItem2 ' Me.MenuItem2.Index = 0 Me.MenuItem2.Text = "Open"

' 'MenuItem3 ' Me.MenuItem3.Index = 1 Me.MenuItem3.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem Me.MenuItem3.Text = "Edit" ' 'MenuItem4 ' Me.MenuItem4.Index = 0 Me.MenuItem4.Text = "Cut" ' 'MenuItem5 ' Me.MenuItem5.Index = 1 Me.MenuItem5.Text = "Copy" ' 'MenuItem6 ' Me.MenuItem6.Index = 2 Me.MenuItem6.Text = "Paste" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(200, 8) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(72, 24) Me.Button1.TabIndex = 3 Me.Button1.Text = "Select" ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(200, 48) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(72, 24) Me.Button2.TabIndex = 4 Me.Button2.Text = "Disable" ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(200, 88) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(72, 24) Me.Button3.TabIndex = 5 Me.Button3.Text = "RadioButton" ' 'Button4 ' Me.Button4.Location = New System.Drawing.Point(200, 136) Me.Button4.Name = "Button4" Me.Button4.Size = New System.Drawing.Size(72, 24) Me.Button4.TabIndex = 6 Me.Button4.Text = "Hide" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(328, 225) Me.Controls.Add(Me.Button4) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button2)

Me.Controls.Add(Me.Button1) Me.Menu = Me.MainMenu1 Me.ResumeLayout(False) End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventAr MenuItem4.RadioCheck = False MenuItem5.RadioCheck = False MenuItem6.RadioCheck = False MenuItem6.Checked = MenuItem4.Checked MenuItem4.Checked = Not MenuItem4.Checked MenuItem5.Checked = Not MenuItem5.Checked MenuItem6.Checked = Not MenuItem6.Checked End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs MenuItem4.RadioCheck = False MenuItem5.RadioCheck = False MenuItem6.RadioCheck = False MenuItem6.Checked = MenuItem4.Checked MenuItem4.Enabled = Not MenuItem4.Enabled MenuItem5.Enabled = Not MenuItem5.Enabled MenuItem6.Enabled = Not MenuItem6.Enabled End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs MenuItem4.Checked = False MenuItem5.Checked = False MenuItem6.Checked = True MenuItem6.RadioCheck = True End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs MenuItem6.Visible = Not MenuItem6.Visible End Sub End Class

Meniu 14.18.4.Add i MenuItem n codul

Importurile Importurile

System.IO System.Windows.Forms

public class MenuAddDynamically public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Public

ourItem

Ca

MenuItem

Private Sub menuClick ( expeditor ByVal Ca obiect, ByVal e ca MessageBox.Show ( "Ai fcut clic" si sender.text & "." , _ "Creatorul meniu interactiv!" ) End Sub

System.EventArgs )

# Region

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub prieten WithEvents btnMainMenu Ca System.Windows.Forms.Button prieten WithEvents GroupBox1 Ca System.Windows.Forms.GroupBox Prietenul WithEvents btnTopMnu Ca System.Windows.Forms.Button prieten WithEvents GroupBox2 Ca System.Windows.Forms.GroupBox prieten WithEvents btnAddItem Ca System.Windows.Forms.Button prieten WithEvents lstTopLevel Ca System.Windows.Forms.ListBox prieten WithEvents Label5 Ca sistem. Windows.Forms.Label prieten WithEvents txtItemText Ca System.Windows.Forms.TextBox prieten WithEvents txtTopLevel Ca System.Windows.Forms.TextBox "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . btnMainMenu = New System.Windows.Forms.Button () Me.GroupBox1 = New System.Windows.Forms.GroupBox () Me.txtTopLevel = New System.Windows.Forms.TextBox () Me.btnTopMnu = New System.Windows. Forms.Button () Me.GroupBox2 = New System.Windows.Forms.GroupBox () Me.Label5 = New System.Windows.Forms.Label () Me.lstTopLevel = New System.Windows.Forms.ListBox () Me.btnAddItem = New System.Windows.Forms.Button () Me.txtItemText = Nou Ca apel

Boole

= New System.Drawing.Point ( 40 , 16 ) Me.btnMainMenu.Name = "btnMainMenu" Me.btnMainMenu.Size = New System.Drawing.Size ( 128 , Me.btnMainMenu.TabIndex = 0 Me.btnMainMenu.Text = "Crearea MainMenu" " "Gr. oupBox1 "

40 )

Me.GroupBox1.Controls.AddRange ( New System.Windows.Forms.Control () { Me.txtTopLe Me.GroupBox1.Location = New System.Drawing. punctul ( 40 , 80 ) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size ( 344 , 104 ) Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = false Me.GroupBox1. Text = "Adauga textul meniului de nivel superior:" " "TX tTopLevel ' Me.txtTopLevel.Location = New System.Drawing.Point ( 24 , 24 ) Me.txtTopLevel.Name = "txtTopLevel" Me.txtTopLevel.Size = Sistem . Drawing.Size ( 272 , 20 ) Me.txtTopLevel.TabIndex = 5 Me.txtTopLevel.Text = "" " "bt nTopMnu ' Me.btnTopMnu.Location = New System.Drawing.Point ( 200 , 64 ) Me.btnTopMnu. name = "btnTopMnu" Me.btnTopMnu.Size = New System.Drawing.Size ( 88 , 24 ) Me.btnTopMnu.TabIndex = 4 Me.btnTopMnu.Text = "F-o aa!" " "Gr. oupBox2 " Me.GroupBox2. Controls.AddRange ( New System.Windows.Forms.Control () { Me.Label5, Me.GroupBox2.Location = New System.Drawing.Point ( 40 , 216 ) Me . GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size ( 344 , 248 ) Me.GroupBox2.TabIndex = 2 Me.GroupBox2.TabStop = false Me.GroupBox2.Text = "Add meniu articol de text : " " "La bel5 ' Me.Label5.Location = New System.Drawing.Point ( 32 , 64 ) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size ( 256 , 16 ) Me.Label5.TabIndex = 6 Me.Label5.Text = "selectai Meniu elementul continu:" " "ls tTopLevel ' Me.lstTopLevel.Location = New System.Drawing.Point ( 16 , 88 ) Me.lstTopLevel.Name = "lstTopLevel" Me.lstTopLevel.Size = New System.Drawing.Size ( 288 , 108 ) Me.lstTopLevel.TabIndex = 5 ' 'bt nAddItem ' Me.btnAddItem.Location = New System.Drawing.Point ( 216 , 208 ) Me . btnAddItem.Name = "btnAddItem" Me.btnAddItem.Size = New System.Drawing.Size ( 88 , 24 ) Me.btnAddItem.TabIndex = 4 Me.btnAddItem.Text = "Adauga articol!" " "TX tItemText " Me. txtItemText.Location = New System.Drawing.Point ( 56 , 32 ) Me.txtItemText.Name = "txtItemText"

Me.txtItemText.Size = New System.Drawing.Size ( 200 , 20 ) Me.txtItemText.TabIndex = 3 Mine. txtItemText.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 440 , 510 ) Me.Controls.AddRange ( nou sistem. Windows.Forms.Control () { Me.GroupBox2, Me.Gro Me.Name = "Form1" Me.Text = "Interactive creator meniu" Me.GroupBox1.ResumeLayout ( Fals ) Me.GroupBox2.ResumeLayout ( False ) Me.ResumeLayout ( Fals ) End Sub # End Regiunea btnMainMenu_Click ( ByVal expeditor Ca System.Object, _ ca System.EventArgs ) Manere btnMainMenu.Click New MainMenu () ourMenu

Private Sub ByVal e ourMenu = Me.Menu = End Sub

Private Sub btnTopMnu_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere btnTopMnu.Click Dim itemString Ca String = txtTopLevel.Text ourTop = New MenuItem ( itemString ) ourMenu.MenuItems.Add ( ourTop ) lstTopLevel.Items. Adauga ( itemString ) End Sub Private Sub btnAddItem_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere btnAddItem.Click Dim i Ca Integer i = 0 ourItem = New MenuItem ( txtItemText.Text, New System.EventHandler ourMenu.MenuItems ( i ) . MenuItems.Add ( ourItem ) End Sub End Class

( AddressOf Me

Original

Imports System.IO Imports System.Windows.Forms public class MenuAddDynamically public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Private ourMenu As MainMenu Private ourTop As MenuItem Private WithEvents ourItem As MenuItem Private Sub menuClick(ByVal sender As Object, ByVal e As System.EventArgs) MessageBox.Show("You clicked " & sender.text & ".", _ "Interactive Menu Creator!") End Sub

#Region " Windows Form Designer generated code "

Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents btnMainMenu As System.Windows.Forms.Button Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend Friend Friend Friend Friend Friend Friend WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents btnTopMnu As System.Windows.Forms.Button GroupBox2 As System.Windows.Forms.GroupBox btnAddItem As System.Windows.Forms.Button lstTopLevel As System.Windows.Forms.ListBox Label5 As System.Windows.Forms.Label txtItemText As System.Windows.Forms.TextBox txtTopLevel As System.Windows.Forms.TextBox

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.btnMainMenu = New System.Windows.Forms.Button() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.txtTopLevel = New System.Windows.Forms.TextBox() Me.btnTopMnu = New System.Windows.Forms.Button() Me.GroupBox2 = New System.Windows.Forms.GroupBox() Me.Label5 = New System.Windows.Forms.Label() Me.lstTopLevel = New System.Windows.Forms.ListBox() Me.btnAddItem = New System.Windows.Forms.Button() Me.txtItemText = New System.Windows.Forms.TextBox() Me.GroupBox1.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.SuspendLayout() ' 'btnMainMenu ' Me.btnMainMenu.Location = New System.Drawing.Point(40, 16) Me.btnMainMenu.Name = "btnMainMenu" Me.btnMainMenu.Size = New System.Drawing.Size(128, 40) Me.btnMainMenu.TabIndex = 0 Me.btnMainMenu.Text = "Create the MainMenu" ' 'GroupBox1 '

Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtTopLevel, Me.GroupBox1.Location = New System.Drawing.Point(40, 80) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(344, 104) Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Add top-level Menu text:" ' 'txtTopLevel ' Me.txtTopLevel.Location = New System.Drawing.Point(24, 24) Me.txtTopLevel.Name = "txtTopLevel" Me.txtTopLevel.Size = New System.Drawing.Size(272, 20) Me.txtTopLevel.TabIndex = 5 Me.txtTopLevel.Text = "" ' 'btnTopMnu ' Me.btnTopMnu.Location = New System.Drawing.Point(200, 64) Me.btnTopMnu.Name = "btnTopMnu" Me.btnTopMnu.Size = New System.Drawing.Size(88, 24) Me.btnTopMnu.TabIndex = 4 Me.btnTopMnu.Text = "Make it so!" ' 'GroupBox2 ' Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label5, Me.l Me.GroupBox2.Location = New System.Drawing.Point(40, 216) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(344, 248) Me.GroupBox2.TabIndex = 2 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Add menu item text:" ' 'Label5 ' Me.Label5.Location = New System.Drawing.Point(32, 64) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(256, 16) Me.Label5.TabIndex = 6 Me.Label5.Text = "Select menu the item goes on:" ' 'lstTopLevel ' Me.lstTopLevel.Location = New System.Drawing.Point(16, 88) Me.lstTopLevel.Name = "lstTopLevel" Me.lstTopLevel.Size = New System.Drawing.Size(288, 108) Me.lstTopLevel.TabIndex = 5 ' 'btnAddItem ' Me.btnAddItem.Location = New System.Drawing.Point(216, 208) Me.btnAddItem.Name = "btnAddItem" Me.btnAddItem.Size = New System.Drawing.Size(88, 24) Me.btnAddItem.TabIndex = 4 Me.btnAddItem.Text = "Add Item!" ' 'txtItemText ' Me.txtItemText.Location = New System.Drawing.Point(56, 32) Me.txtItemText.Name = "txtItemText"

Me.txtItemText.Size = New System.Drawing.Size(200, 20) Me.txtItemText.TabIndex = 3 Me.txtItemText.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(440, 510) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox2, Me.GroupBox Me.Name = "Form1" Me.Text = "Interactive menu creator" Me.GroupBox1.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub btnMainMenu_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnMainMenu.Click ourMenu = New MainMenu() Me.Menu = ourMenu End Sub Private Sub btnTopMnu_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnTopMnu.Click Dim itemString As String = txtTopLevel.Text ourTop = New MenuItem(itemString) ourMenu.MenuItems.Add(ourTop) lstTopLevel.Items.Add(itemString) End Sub

Private Sub btnAddItem_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnAddItem.Click Dim i As Integer i = 0 ourItem = New MenuItem(txtItemText.Text, New System.EventHandler (AddressOf Me.men ourMenu.MenuItems(i).MenuItems.Add(ourItem) End Sub End Class

Owner Egal MenuItem

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class OwnerDrawMenu public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Private de # Region fiiere () Ca String = { "yourfile.jpg" , "yourfile.jpg" }

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac Ca apel

Bool

MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod WithEvents prieten mainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents mnuFile Ca System.Windows.Forms.MenuItem prieten WithEvents mnuNew Ca System.Windows.Forms.MenuItem prieten WithEvents mnuFileOpen Ca System.Windows.Forms.MenuItem prieten WithEvents mnuFileClose Ca System.Windows.Forms.MenuItem prieten WithEvents mnuFileSave Ca System.Windows.Forms. MenuItem prieten WithEvents mnuFileSaveAs Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEdit Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEditCopy Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEditPaste Ca System.Windows.Forms.MenuItem prieten mnuOptions WithEvents Ca sistem . Windows.Forms.MenuItem prieten WithEvents mnuOption1 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuOption2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuOption3 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOptions Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOption1 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOption2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOption3 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuWindow Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu1 Ca sistem. Windows.Forms.MenuItem prieten WithEvents mnuMenu11 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu12 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu13 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu14 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMerge Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu21 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu22 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu23 Ca System.Windows . Forms.MenuItem prieten WithEvents mnuMenu24 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuSpecial Ca System.Windows.Forms.MenuItem prieten WithEvents mnuODVote Ca System.Windows.Forms.MenuItem prieten WithEvents mnuODShazam Ca System.Windows.Forms.MenuItem <System . Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.mainMenu1 = New System.Windows.Forms.MainMenu () Me.mnuFile = New System.Windows.Forms.MenuItem () Me.mnuNew = New System.Windows.Forms . MenuItem () Me.mnuFileOpen = New System.Windows.Forms.MenuItem () Me.mnuFileClose = New System.Windows.Forms.MenuItem () Me.mnuFileSave = New System.Windows.Forms.MenuItem () Me.mnuFileSaveAs = nou System.Windows.Forms.MenuItem () Me.mnuEdit = New System.Windows.Forms.MenuItem () Me.mnuEditCopy = New System.Windows.Forms.MenuItem () Me.mnuEditPaste = New System.Windows.Forms.MenuItem () Me.mnuOptions = New System.Windows.Forms.MenuItem () Me.mnuOption1 = New System.Windows.Forms.MenuItem () Me.mnuOption2 = New System.Windows.Forms.MenuItem () Me.mnuOption3 = Sistem . Windows.Forms.MenuItem () Me.mnuRadioOptions = New System.Windows.Forms.MenuItem () Me.mnuRadioOption1 = New System.Windows.Forms.MenuItem () Me.mnuRadioOption2 = New System.Windows.Forms.MenuItem () Me.mnuRadioOption3 = New System.Windows.Forms.MenuItem ()

Me.mnuWindow = New System.Windows.Forms.MenuItem () Me.mnuMenu1 = New System.Windows.Forms.MenuItem () Me.mnuMenu11 = New System.Windows . Forms.MenuItem () Me.mnuMenu12 = New System.Windows.Forms.MenuItem () Me.mnuMenu13 = New System.Windows.Forms.MenuItem () Me.mnuMenu14 = New System.Windows.Forms.MenuItem () Me. mnuMerge = New System.Windows.Forms.MenuItem () Me.mnuMenu2 = New System.Windows.Forms.MenuItem () Me.mnuMenu21 = New System.Windows.Forms.MenuItem () Me.mnuMenu22 = New System.Windows.Forms . MenuItem () Me.mnuMenu23 = New System.Windows.Forms.MenuItem () Me.mnuMenu24 = New System.Windows.Forms.MenuItem () Me.mnuSpecial = New System.Windows.Forms.MenuItem () Me.mnuODVote = nou System.Windows.Forms.MenuItem () Me.mnuODShazam = New System.Windows.Forms.MenuItem () " "ma inMenu1 " Me.mainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me. mnu " "mil lei uFile ' Me.mnuFile.Index = 0 Me.mnuFile.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuNew Me.mnuFile.Text = "File" " "milioane uNew " Me.mnuNew . index = 0 Me.mnuNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN Me.mnuNew.Text = "& New" " "milioane uFileOpen ' Me.mnuFileOpen.Index = 1 Me.mnuFileOpen.Text = "Open" " "mil. uFileClose ' Me.mnuFileClose.Index = 2 Me.mnuFileClose.Text = "Close" " "milioane uFileSave ' Me.mnuFileSave.Index = 3 Me.mnuFileSave.Text = "Salvare" " "milioane uFileSaveAs " Me.mnuFileSaveAs. index = 4 Me.mnuFileSaveAs.Text = "Save & A", " 'mil. uEdit ' Me.mnuEdit.Index = 1 Me.mnuEdit.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuEdi Me.mnuEdit.Text = "Edit" " "milioane uEditCopy ' Me.mnuEditCopy.Index = 0

Me.mnuEditCopy.Text = "& Copy", " 'mil. uEditPaste ' Me.mnuEditPaste.Index = 1 Me.mnuEditPaste.Text = "Paste" " "milioane uOptions ' Me.mnuOptions.Index = 2 Me.mnuOptions.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnu Me.mnuOptions . Text = "Opiuni" " "milioane uOption1 ' Me.mnuOption1.Index = 0 Me.mnuOption1.Text = "Opiunea 1" " "milioane uOption2 ' Me.mnuOption2.Index = 1 Me.mnuOption2.Text = "Opiunea 2" " " mil. uOption3 ' Me.mnuOption3.Index = 2 Me.mnuOption3.Text = "Option3" " "mil uRadioOptions " Me.mnuRadioOptions.Index = 3 Me.mnuRadioOptions.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { M Me.mnuRadioOptions.Text = "Opiuni de radio" " "milioane uRadioOption1 ' Me.mnuRadioOption1.Index = 0 Me.mnuRadioOption1.RadioCheck = True Me.mnuRadioOption1.Text = "Radio Opiunea 1 " ' 'mil. uRadioOption2 ' Me.mnuRadioOption2.Index = 1 Me.mnuRadioOption2.RadioCheck = True Me.mnuRadioOption2.Text = "Opiunea Radio 2" ' 'mil. uRadioOption3 ' Me.mnuRadioOption3.Index = 2 Me.mnuRadioOption3.RadioCheck = True Me.mnuRadioOption3.Text = "Opiunea Radio 3", " 'mil. uWindow ' Me.mnuWindow.Index = 4 Me.mnuWindow.MdiList = True Me.mnuWindow.MergeOrder = 99 Me.mnuWindow.Text = "& Window" " " mil. uMenu1 '

Me.mnuMenu1.Index = 5 Me.mnuMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuMe Me.mnuMenu1.Text = "Meniul 1" ' 'mil. uMenu11 ' Me.mnuMenu11.Index = 0 Me.mnuMenu11.MergeOrder = 1 Me.mnuMenu11.Text = "Meniu 1.1" " "milioane uMenu12 ' Me.mnuMenu12.Index = 1 Me.mnuMenu12.MergeOrder = 2 Me.mnuMenu12.Text = "Meniu 1.2" " "milioane uMenu13 ' Me.mnuMenu13.Index = 2 Me.mnuMenu13.MergeOrder = 3 Me.mnuMenu13.Text = "Meniu 1.3" " "mil lei uMenu14 ' Me.mnuMenu14.Index = 3 Me.mnuMenu14.MergeOrder = 4 Me.mnuMenu14.Text = "Meniu 1.4" " "milioane uMerge ' Me.mnuMerge.Index = 4 Me.mnuMerge.MergeOrder = 99 Me.mnuMerge.Text = "Merge!" " "milioane uMenu2 ' Me.mnuMenu2.Index = 6 Me.mnuMenu2.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuMe Me.mnuMenu2.Text = "Meniul 2" ' 'mil. uMenu21 ' Me.mnuMenu21.Index = 0 Me.mnuMenu21.MergeOrder = 1 Me.mnuMenu21.Text = "Meniu 2.1" " "milioane uMenu22 " Me.mnuMenu22 . index = 1 Me.mnuMenu22.MergeOrder = 2 Me.mnuMenu22.MergeType = System.Windows.Forms.MenuMerge.Replace Me.mnuMenu22.Text = "Meniu 2.2" " "milioane uMenu23 ' Me.mnuMenu23.Index = 2 Me. mnuMenu23.MergeOrder = 3 Me.mnuMenu23.MergeType = System.Windows.Forms.MenuMerge.Remove Me.mnuMenu23.Text = "Meniu 2.3" " "milioane uMenu24

' Me.mnuMenu24.Index = 3 Me.mnuMenu24.MergeOrder = 5 Me . mnuMenu24.Text = "Meniu 2.4" " "milioane uSpecial ' Me.mnuSpecial.Index = 7 Me.mnuSpecial.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnu Me . mnuSpecial.Text = "Special" " "milioane uODVote ' Me.mnuODVote.Index = 0 Me.mnuODVote.OwnerDraw = True Me.mnuODVote.Text = "Vot" " "milioane uODShazam ' Me.mnuODShazam.Index = 1 Me. mnuODShazam.OwnerDraw = True Me.mnuODShazam.Text = "Shazam" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 456 , 106 ) Me . IsMdiContainer = True Me.Menu = Me.mainMenu1 Me.Name = "Form1" Me.Text = "Form1" End Sub # End Regiunea obiect, ByVal e ca

Private Sub mnuODVote_DrawItem ( expeditor ByVal Ca Manere mnuODVote.DrawItem, mnuODShazam.DrawItem Dim img Ca imagine img = Image.FromFile ( fiiere ( e.Index )) Dim r Ca dreptunghi r = e.Bounds Dim p Ca Pen = New Pen ( e.BackColor, 2 ) r.Inflate ( - 6 , - 6 ) e.Graphics.DrawRectangle ( P, R ) e.Graphics.DrawImage ( img, R ) End Sub

System.W

Private Sub mnuODVote_MeasureItem ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MeasureItemEventArgs ) _ Manere mnuODVote.MeasureItem, mnuODShazam.MeasureItem Dim img Ca imagine img = Image.FromFile ( fiiere ( e.Index )) e.ItemHeight = img.Height e.ItemWidth = img.Width End Sub Private Sub mnuODDraw_Click ( ByVal expeditor Ca System.Object, ByVal e ca

Syst

Manere mnuODVote.Click, mnuODShazam.Click Dim punctul Ca MenuItem = Ctype ( expeditor, MenuItem ) Dim alegerea Ca String = item.Text MessageBox.Show ( "Ai fcut clic" i alegere, "Meniu Tester Event" , MessageBo MessageBoxIcon.Asterisk ) End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class OwnerDrawMenu public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Private files() As String = {"yourfile.jpg", "yourfile.jpg"} #Region " Windows Form Designer generated code " Public Sub New()

MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents mainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents mnuFile As System.Windows.Forms.MenuItem Friend WithEvents mnuNew As System.Windows.Forms.MenuItem Friend WithEvents mnuFileOpen As System.Windows.Forms.MenuItem Friend WithEvents mnuFileClose As System.Windows.Forms.MenuItem Friend WithEvents mnuFileSave As System.Windows.Forms.MenuItem Friend WithEvents mnuFileSaveAs As System.Windows.Forms.MenuItem Friend WithEvents mnuEdit As System.Windows.Forms.MenuItem Friend WithEvents mnuEditCopy As System.Windows.Forms.MenuItem Friend WithEvents mnuEditPaste As System.Windows.Forms.MenuItem Friend WithEvents mnuOptions As System.Windows.Forms.MenuItem Friend WithEvents mnuOption1 As System.Windows.Forms.MenuItem Friend WithEvents mnuOption2 As System.Windows.Forms.MenuItem Friend WithEvents mnuOption3 As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOptions As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOption1 As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOption2 As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOption3 As System.Windows.Forms.MenuItem Friend WithEvents mnuWindow As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu1 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu11 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu12 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu13 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu14 As System.Windows.Forms.MenuItem Friend WithEvents mnuMerge As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu2 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu21 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu22 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu23 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu24 As System.Windows.Forms.MenuItem Friend WithEvents mnuSpecial As System.Windows.Forms.MenuItem Friend WithEvents mnuODVote As System.Windows.Forms.MenuItem Friend WithEvents mnuODShazam As System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.mainMenu1 = New System.Windows.Forms.MainMenu() Me.mnuFile = New System.Windows.Forms.MenuItem()

Me.mnuNew = New System.Windows.Forms.MenuItem() Me.mnuFileOpen = New System.Windows.Forms.MenuItem() Me.mnuFileClose = New System.Windows.Forms.MenuItem() Me.mnuFileSave = New System.Windows.Forms.MenuItem() Me.mnuFileSaveAs = New System.Windows.Forms.MenuItem() Me.mnuEdit = New System.Windows.Forms.MenuItem() Me.mnuEditCopy = New System.Windows.Forms.MenuItem() Me.mnuEditPaste = New System.Windows.Forms.MenuItem() Me.mnuOptions = New System.Windows.Forms.MenuItem() Me.mnuOption1 = New System.Windows.Forms.MenuItem() Me.mnuOption2 = New System.Windows.Forms.MenuItem() Me.mnuOption3 = New System.Windows.Forms.MenuItem() Me.mnuRadioOptions = New System.Windows.Forms.MenuItem() Me.mnuRadioOption1 = New System.Windows.Forms.MenuItem() Me.mnuRadioOption2 = New System.Windows.Forms.MenuItem() Me.mnuRadioOption3 = New System.Windows.Forms.MenuItem() Me.mnuWindow = New System.Windows.Forms.MenuItem() Me.mnuMenu1 = New System.Windows.Forms.MenuItem() Me.mnuMenu11 = New System.Windows.Forms.MenuItem() Me.mnuMenu12 = New System.Windows.Forms.MenuItem() Me.mnuMenu13 = New System.Windows.Forms.MenuItem() Me.mnuMenu14 = New System.Windows.Forms.MenuItem() Me.mnuMerge = New System.Windows.Forms.MenuItem() Me.mnuMenu2 = New System.Windows.Forms.MenuItem() Me.mnuMenu21 = New System.Windows.Forms.MenuItem() Me.mnuMenu22 = New System.Windows.Forms.MenuItem() Me.mnuMenu23 = New System.Windows.Forms.MenuItem() Me.mnuMenu24 = New System.Windows.Forms.MenuItem() Me.mnuSpecial = New System.Windows.Forms.MenuItem() Me.mnuODVote = New System.Windows.Forms.MenuItem() Me.mnuODShazam = New System.Windows.Forms.MenuItem() ' 'mainMenu1 ' Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, ' 'mnuFile ' Me.mnuFile.Index = 0 Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNew, Me Me.mnuFile.Text = "File" ' 'mnuNew ' Me.mnuNew.Index = 0 Me.mnuNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN Me.mnuNew.Text = "&New" ' 'mnuFileOpen ' Me.mnuFileOpen.Index = 1 Me.mnuFileOpen.Text = "Open" ' 'mnuFileClose ' Me.mnuFileClose.Index = 2 Me.mnuFileClose.Text = "Close" ' 'mnuFileSave ' Me.mnuFileSave.Index = 3

Me.mnuFileSave.Text = "Save" ' 'mnuFileSaveAs ' Me.mnuFileSaveAs.Index = 4 Me.mnuFileSaveAs.Text = "Save&As" ' 'mnuEdit ' Me.mnuEdit.Index = 1 Me.mnuEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEditCop Me.mnuEdit.Text = "Edit" ' 'mnuEditCopy ' Me.mnuEditCopy.Index = 0 Me.mnuEditCopy.Text = "&Copy" ' 'mnuEditPaste ' Me.mnuEditPaste.Index = 1 Me.mnuEditPaste.Text = "Paste" ' 'mnuOptions ' Me.mnuOptions.Index = 2 Me.mnuOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpti Me.mnuOptions.Text = "Options" ' 'mnuOption1 ' Me.mnuOption1.Index = 0 Me.mnuOption1.Text = "Option1" ' 'mnuOption2 ' Me.mnuOption2.Index = 1 Me.mnuOption2.Text = "Option2" ' 'mnuOption3 ' Me.mnuOption3.Index = 2 Me.mnuOption3.Text = "Option3" ' 'mnuRadioOptions ' Me.mnuRadioOptions.Index = 3 Me.mnuRadioOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mn Me.mnuRadioOptions.Text = "Radio Options" ' 'mnuRadioOption1 ' Me.mnuRadioOption1.Index = 0 Me.mnuRadioOption1.RadioCheck = True Me.mnuRadioOption1.Text = "Radio Option 1" ' 'mnuRadioOption2 ' Me.mnuRadioOption2.Index = 1 Me.mnuRadioOption2.RadioCheck = True Me.mnuRadioOption2.Text = "Radio Option 2"

' 'mnuRadioOption3 ' Me.mnuRadioOption3.Index = 2 Me.mnuRadioOption3.RadioCheck = True Me.mnuRadioOption3.Text = "Radio Option 3" ' 'mnuWindow ' Me.mnuWindow.Index = 4 Me.mnuWindow.MdiList = True Me.mnuWindow.MergeOrder = 99 Me.mnuWindow.Text = "&Window" ' 'mnuMenu1 ' Me.mnuMenu1.Index = 5 Me.mnuMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMenu11 Me.mnuMenu1.Text = "Menu 1" ' 'mnuMenu11 ' Me.mnuMenu11.Index = 0 Me.mnuMenu11.MergeOrder = 1 Me.mnuMenu11.Text = "Menu 1.1" ' 'mnuMenu12 ' Me.mnuMenu12.Index = 1 Me.mnuMenu12.MergeOrder = 2 Me.mnuMenu12.Text = "Menu 1.2" ' 'mnuMenu13 ' Me.mnuMenu13.Index = 2 Me.mnuMenu13.MergeOrder = 3 Me.mnuMenu13.Text = "Menu 1.3" ' 'mnuMenu14 ' Me.mnuMenu14.Index = 3 Me.mnuMenu14.MergeOrder = 4 Me.mnuMenu14.Text = "Menu 1.4" ' 'mnuMerge ' Me.mnuMerge.Index = 4 Me.mnuMerge.MergeOrder = 99 Me.mnuMerge.Text = "Merge!" ' 'mnuMenu2 ' Me.mnuMenu2.Index = 6 Me.mnuMenu2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMenu21 Me.mnuMenu2.Text = "Menu 2" ' 'mnuMenu21 ' Me.mnuMenu21.Index = 0 Me.mnuMenu21.MergeOrder = 1 Me.mnuMenu21.Text = "Menu 2.1"

' 'mnuMenu22 ' Me.mnuMenu22.Index = 1 Me.mnuMenu22.MergeOrder = 2 Me.mnuMenu22.MergeType = System.Windows.Forms.MenuMerge.Replace Me.mnuMenu22.Text = "Menu 2.2" ' 'mnuMenu23 ' Me.mnuMenu23.Index = 2 Me.mnuMenu23.MergeOrder = 3 Me.mnuMenu23.MergeType = System.Windows.Forms.MenuMerge.Remove Me.mnuMenu23.Text = "Menu 2.3" ' 'mnuMenu24 ' Me.mnuMenu24.Index = 3 Me.mnuMenu24.MergeOrder = 5 Me.mnuMenu24.Text = "Menu 2.4" ' 'mnuSpecial ' Me.mnuSpecial.Index = 7 Me.mnuSpecial.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuODVo Me.mnuSpecial.Text = "Special" ' 'mnuODVote ' Me.mnuODVote.Index = 0 Me.mnuODVote.OwnerDraw = True Me.mnuODVote.Text = "Vote" ' 'mnuODShazam ' Me.mnuODShazam.Index = 1 Me.mnuODShazam.OwnerDraw = True Me.mnuODShazam.Text = "Shazam" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(456, 106) Me.IsMdiContainer = True Me.Menu = Me.mainMenu1 Me.Name = "Form1" Me.Text = "Form1" End Sub #End Region

Private Sub mnuODVote_DrawItem(ByVal sender As Object, ByVal e As System.Windows.For Handles mnuODVote.DrawItem, mnuODShazam.DrawItem Dim img As Image img = Image.FromFile(files(e.Index)) Dim r As Rectangle r = e.Bounds Dim p As Pen = New Pen(e.BackColor, 2) r.Inflate(-6, -6)

e.Graphics.DrawRectangle(p, r) e.Graphics.DrawImage(img, r) End Sub Private Sub mnuODVote_MeasureItem(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MeasureItemEventArgs) _ Handles mnuODVote.MeasureItem, mnuODShazam.MeasureItem Dim img As Image img = Image.FromFile(files(e.Index)) e.ItemHeight = img.Height e.ItemWidth = img.Width End Sub

Private Sub mnuODDraw_Click(ByVal sender As System.Object,ByVal e As System.EventArg Handles mnuODVote.Click, mnuODShazam.Click Dim item As MenuItem = CType(sender, MenuItem) Dim choice As String = item.Text MessageBox.Show("You clicked " & choice,"Menu Event Tester", MessageBoxButtons.O MessageBoxIcon.Asterisk) End Sub End Class

MenuStrip Demo

Imports Imports Imports Imports

System.Windows.Forms System.Drawing.Text System.Drawing System.Drawing.Drawing2D

public class MenuStripDemo public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Private Sub Form1 ToolStripMenuItem1_Click ( ByVal expeditor Ca System.Object, ByVal e

Button1.Visible = False End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System . Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.MenuStrip1 = New System.Windows.Forms.MenuStrip Me.ToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem2 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem3 = New System.Windows.Forms.ToolStripMenuItem mine. ToolStripMenuItem4 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem5 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem6 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem7 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem8 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem9 = New System.Windows.Forms.ToolStripSeparator Me.MyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem Me.Button1 = Nou

Boolean )

System.Windows.Forms.ToolStripItem () { Me.ToolStripMenuItem1 }) Me.MenuStrip1.Location = New System.Drawing.Point ( 0 , 0 ) Me.MenuStrip1.Name = "MenuStrip1" Me.MenuStrip1.Size = Sistem. Drawing.Size ( 455 , 24 ) Me.MenuStrip1.TabIndex = 0 Me.MenuStrip1.Text = "MenuStrip1" " "Pentru a olStripMenuItem1 " Me.ToolStripMenuItem1.DropDownItems.AddRange ( New System.Windows.Forms.ToolStri Me.ToolStripMenuItem1.Name = "ToolStripMenuItem1" Me.ToolStripMenuItem1.ShortcutKeys = Ctype (( System.Windows.Forms.Keys.Alt Sau Me.ToolStripMenuItem1.Size = New System.Drawing.Size ( 41 , 20 ) Me.ToolStripMenuItem1.Text = "Edit" " "Pentru a olStripMenuItem2 " Me.ToolStripMenuItem2.DropDownItems.AddRange ( nou sistem. Windows.Forms.ToolStr Me.ToolStripMenuItem2.Name = "ToolStripMenuItem2" Me.ToolStripMenuItem2.Size = New System.Drawing.Size ( 178 , 22 )

Me.ToolStripMenuItem2.Text = "ToolStripMenuItem2" " " Pentru a olStripMenuItem3 " Me.ToolStripMenuItem3.DropDownItems.AddRange ( New System.Windows.Forms.ToolStri Me.ToolStripMenuItem3.Name = "ToolStripMenuItem3" Me.ToolStripMenuItem3.Size = New System.Drawing.Size ( 178 , 22 ) Me.ToolStripMenuItem3.Text = "ToolStripMenuItem3" " "Pentru a olStripMenuItem4 " Me.ToolStripMenuItem4.DropDownItems.AddRange ( New System.Windows.Forms.ToolStri Me.ToolStripMenuItem4.Name = "ToolStripMenuItem4" Me.ToolStripMenuItem4.Size = New System.Drawing.Size ( 178 , 22 ) Me.ToolStripMenuItem4.Text = "ToolStripMenuItem4" " "Pentru a olStripMenuItem5 " Me.ToolStripMenuItem5.DropDownItems.AddRange ( System.Windows.Forms noi. ToolStr Me.ToolStripMenuItem5.Name = "ToolStripMenuItem5" Me.ToolStripMenuItem5.Size = New System.Drawing.Size ( 178 , 22 ) Me.ToolStripMenuItem5.Text = "ToolStripMenuItem5" " "Pentru a olStripMenuItem6 " Me . ToolStripMenuItem6.Name = "ToolStripMenuItem6" Me.ToolStripMenuItem6.Size = New System.Drawing.Size ( 178 , 22 ) Me.ToolStripMenuItem6.Text = "ToolStripMenuItem6" " "Pentru a olStripMenuItem7 " Me.ToolStripMenuItem7.DropDownItems.AddRange ( nou sistem. Windows.Forms.ToolStr Me.ToolStripMenuItem7.Name = "ToolStripMenuItem7" Me.ToolStripMenuItem7.Size = New System.Drawing.Size ( 178 , 22 ) Me.ToolStripMenuItem7.Text = "ToolStripMenuItem7" " " Pentru a olStripMenuItem8 ' Me.ToolStripMenuItem8.Name = "ToolStripMenuItem8" Me.ToolStripMenuItem8.Size = New System.Drawing.Size ( 178 , 22 ) Me.ToolStripMenuItem8.Text = "ToolStripMenuItem8" " "Pentru a olStripMenuItem9 ' Me.ToolStripMenuItem9.Name = " ToolStripMenuItem9 " Me.ToolStripMenuItem9.Size = New System.Drawing.Size ( 175 , 6 ), " "My ToolStripMenuItem ' Me.MyToolStripMenuItem.Name = "MyToolStripMenuItem" Me.MyToolStripMenuItem.Size = New System.Drawing.Size ( 178 , 22 ) Me.MyToolStripMenuItem.Text = "un sir" " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 74 , 92 ) Me.Button1.Name = "Button1" Me.Button1.Size = Sistem. Drawing.Size ( 75 , 23 ) Me.Button1.TabIndex = 1 Me.Button1.Text = "Button1" Me.Button1.UseVisualStyleBackColor = True

' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou = Me.MenuStrip1 Me.Name = "Form1" Me.Text

12.0 ! )

End Sub prieten WithEvents MenuStrip1 Ca System.Windows.Forms.MenuStrip prieten WithEvents ToolStripMenuItem1 Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents ToolStripMenuItem2 Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents ToolStripMenuItem3 Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents ToolStripMenuItem4 Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents ToolStripMenuItem5 Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents ToolStripMenuItem6 Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents ToolStripMenuItem7 Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents ToolStripMenuItem8 Ca System.Windows.Forms. ToolStripMenuItem prieten WithEvents MyToolStripMenuItem Ca System.Windows.Forms.ToolStripMenuItem prieten WithEvents ToolStripMenuItem9 Ca System.Windows.Forms.ToolStripSeparator prieten WithEvents Button1 Ca System.Windows.Forms.Button End Class

Imports Imports Imports Imports

System.Windows.Forms System.Drawing.Text System.Drawing System.Drawing.Drawing2D

public class MenuStripDemo public Shared Sub Main

Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As Syste Button1.Visible = False End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.MenuStrip1 = New System.Windows.Forms.MenuStrip Me.ToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem2 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem3 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem4 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem5 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem6 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem7 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem8 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem9 = New System.Windows.Forms.ToolStripSeparator Me.MyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem Me.Button1 = New System.Windows.Forms.Button Me.MenuStrip1.SuspendLayout() Me.SuspendLayout() ' 'MenuStrip1 ' Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolSt Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) Me.MenuStrip1.Name = "MenuStrip1" Me.MenuStrip1.Size = New System.Drawing.Size(455, 24) Me.MenuStrip1.TabIndex = 0 Me.MenuStrip1.Text = "MenuStrip1" ' 'ToolStripMenuItem1 ' Me.ToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripI Me.ToolStripMenuItem1.Name = "ToolStripMenuItem1" Me.ToolStripMenuItem1.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or Sys Me.ToolStripMenuItem1.Size = New System.Drawing.Size(41, 20)

Me.ToolStripMenuItem1.Text = "Edit" ' 'ToolStripMenuItem2 ' Me.ToolStripMenuItem2.DropDownItems.AddRange(New System.Windows.Forms.ToolStripI Me.ToolStripMenuItem2.Name = "ToolStripMenuItem2" Me.ToolStripMenuItem2.Size = New System.Drawing.Size(178, 22) Me.ToolStripMenuItem2.Text = "ToolStripMenuItem2" ' 'ToolStripMenuItem3 ' Me.ToolStripMenuItem3.DropDownItems.AddRange(New System.Windows.Forms.ToolStripI Me.ToolStripMenuItem3.Name = "ToolStripMenuItem3" Me.ToolStripMenuItem3.Size = New System.Drawing.Size(178, 22) Me.ToolStripMenuItem3.Text = "ToolStripMenuItem3" ' 'ToolStripMenuItem4 ' Me.ToolStripMenuItem4.DropDownItems.AddRange(New System.Windows.Forms.ToolStripI Me.ToolStripMenuItem4.Name = "ToolStripMenuItem4" Me.ToolStripMenuItem4.Size = New System.Drawing.Size(178, 22) Me.ToolStripMenuItem4.Text = "ToolStripMenuItem4" ' 'ToolStripMenuItem5 ' Me.ToolStripMenuItem5.DropDownItems.AddRange(New System.Windows.Forms.ToolStripI Me.ToolStripMenuItem5.Name = "ToolStripMenuItem5" Me.ToolStripMenuItem5.Size = New System.Drawing.Size(178, 22) Me.ToolStripMenuItem5.Text = "ToolStripMenuItem5" ' 'ToolStripMenuItem6 ' Me.ToolStripMenuItem6.Name = "ToolStripMenuItem6" Me.ToolStripMenuItem6.Size = New System.Drawing.Size(178, 22) Me.ToolStripMenuItem6.Text = "ToolStripMenuItem6" ' 'ToolStripMenuItem7 ' Me.ToolStripMenuItem7.DropDownItems.AddRange(New System.Windows.Forms.ToolStripI Me.ToolStripMenuItem7.Name = "ToolStripMenuItem7" Me.ToolStripMenuItem7.Size = New System.Drawing.Size(178, 22) Me.ToolStripMenuItem7.Text = "ToolStripMenuItem7" ' 'ToolStripMenuItem8 ' Me.ToolStripMenuItem8.Name = "ToolStripMenuItem8" Me.ToolStripMenuItem8.Size = New System.Drawing.Size(178, 22) Me.ToolStripMenuItem8.Text = "ToolStripMenuItem8" ' 'ToolStripMenuItem9 ' Me.ToolStripMenuItem9.Name = "ToolStripMenuItem9" Me.ToolStripMenuItem9.Size = New System.Drawing.Size(175, 6) ' 'MyToolStripMenuItem ' Me.MyToolStripMenuItem.Name = "MyToolStripMenuItem" Me.MyToolStripMenuItem.Size = New System.Drawing.Size(178, 22) Me.MyToolStripMenuItem.Text = "a string" ' 'Button1

' Me.Button1.Location = New System.Drawing.Point(74, 92) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(75, 23) Me.Button1.TabIndex = 1 Me.Button1.Text = "Button1" Me.Button1.UseVisualStyleBackColor = True ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(455, 202) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.MenuStrip1) Me.MainMenuStrip = Me.MenuStrip1 Me.Name = "Form1" Me.Text = "Form1" Me.MenuStrip1.ResumeLayout(False) Me.MenuStrip1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class MenuStrip1 As System.Windows.Forms.MenuStrip ToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem2 As System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem3 As System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem4 As System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem5 As System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem6 As System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem7 As System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem8 As System.Windows.Forms.ToolStripMenuItem MyToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem9 As System.Windows.Forms.ToolStripSeparator Button1 As System.Windows.Forms.Button

Intrare 14.23.1.Get din casuta de text si Set de etichete

Importurile Importurile

System.Drawing System.Drawing.Drawing2D

Importurile

System.Windows.Forms

public class GetTextInTextBoxAndSetToLabel public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Button1 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout () " "La bel1 ' Me.Label1.Location = Nou System.Drawing.Point ( 48 , 16 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 160 , 32 ) Me.Label1.TabIndex = 0 ' 'Te xtBox1 " Me. TextBox1.Location = New System.Drawing.Point ( 64 , 64 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 120 , 20 ) Me.TextBox1.TabIndex = 1 Me. TextBox1.Text = "" " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 88 , 104 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 72 , 24 ) Me.Button1.TabIndex = 2 Me.Button1.Text = "Display"

" "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , Me.ClientSize = Nou

13 )

= "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub Private Sub Button1_Click ( ByVal expeditor Ca System.Object, ByVal e Label1.Text = "Hello" + TextBox1.Text + "" End Sub End Class ca

System

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class GetTextInTextBoxAndSetToLabel public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(48, 16) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(160, 32) Me.Label1.TabIndex = 0 ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(64, 64) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(120, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(88, 104) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(72, 24) Me.Button1.TabIndex = 2 Me.Button1.Text = "Display" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(256, 166) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Label1.Text = "Hello," + TextBox1.Text + "" End Sub End Class

Valoare de intrare 14.23.2.Convert ntr-un TextField

Importurile

System.Windows.Forms

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial Clasa ConvertForm Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.SourceFahrenheit = New System.Windows.Forms.RadioButton Me.SourceCelsius = New System.Windows.Forms.RadioButton Me.SourceKelvin = New System.Windows.Forms.RadioButton Me.ValueFahrenheit = New System.Windows.Forms.TextBox mine. ValueCelsius = New System.Windows.Forms.TextBox Me.ValueKelvin = New System.Windows.Forms.TextBox Me.ConvertTemperature = New System.Windows.Forms.Button Me.SuspendLayout () " "Deci, urceFahrenheit ' Me.SourceFahrenheit.AutoSize = Adevrat Me.SourceFahrenheit.Checked = True Me.SourceFahrenheit.Location = New System.Drawing.Point ( 16 , 24 ) Me.SourceFahrenheit.Name = "SourceFahrenheit" Me.SourceFahrenheit.Size = New System.Drawing.Size ( 75 , 17 ) Me.SourceFahrenheit.TabIndex = 0 Me.SourceFahrenheit.TabStop = True Me.SourceFahrenheit.Text = "& Fahrenheit"

Boolean )

Me.SourceFahrenheit.UseVisualStyleBackColor = True ' 'Deci urceCelsius ' Me.SourceCelsius.AutoSize = True Me.SourceCelsius.Location = Nou System.Drawing.Point ( 16 , 56 ) Me.SourceCelsius.Name = "SourceCelsius" Me.SourceCelsius.Size = New System.Drawing.Size ( 58 , 17 ) Me.SourceCelsius.TabIndex = 2 Me.SourceCelsius.Text = " & Celsius " Me.SourceCelsius.UseVisualStyleBackColor = True ' 'Deci urceKelvin ' Me.SourceKelvin.AutoSize = True Me.SourceKelvin.Location = New System.Drawing.Point ( 16 , 88 ) Me.SourceKelvin.Name = "SourceKelvin" Me.SourceKelvin . Dimensiune = New System.Drawing.Size ( 53 , 17 ) Me.SourceKelvin.TabIndex = 4 Me.SourceKelvin.Text = "& Kelvin" Me.SourceKelvin.UseVisualStyleBackColor = True ' 'Va lueFahrenheit ' Me.ValueFahrenheit.Location = Sistem . Drawing.Point ( 120 , 24 ) Me.ValueFahrenheit.Name = "ValueFahrenheit" Me.ValueFahrenheit.Size = New System.Drawing.Size ( 100 , 20 ) Me.ValueFahrenheit.TabIndex = 1 ' 'Va lueCelsius ' Me.ValueCelsius . Locaia = New System.Drawing.Point ( 120 , 56 ) Me.ValueCelsius.Name = "ValueCelsius" Me.ValueCelsius.Size = New System.Drawing.Size ( 100 , 20 ) Me.ValueCelsius.TabIndex = 3 ' 'Va lueKelvin ' Me.ValueKelvin.Location = New System.Drawing.Point ( 120 , 88 ) Me.ValueKelvin.Name = "ValueKelvin" Me.ValueKelvin.Size = New System.Drawing.Size ( 100 , 20 ) Me.ValueKelvin.TabIndex = 5 ' 'Co nvertTemperature ' Me.ConvertTemperature.Location = New System.Drawing.Point ( 144 , 128 ) Me.ConvertTemperature.Name = "ConvertTemperature" Me.ConvertTemperature.Size = New System.Drawing.Size ( 75 , 23 ) Me.ConvertTemperature.TabIndex = 6 Me.ConvertTemperature.Text = "Convert" Me.ConvertTemperature.UseVisualStyleBackColor = True ' 'Co nvertForm " Me.AcceptButton = Me.ConvertTemperature Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou

= System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = Fals Me.MinimizeBox = false Me.Name = "ConvertForm" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Convert Temperaturi" Me. ResumeLayout ( False ) Me.PerformLayout () Sub End prieten WithEvents SourceFahrenheit Ca System.Windows.Forms.RadioButton prieten WithEvents SourceCelsius Ca System.Windows.Forms.RadioButton prieten WithEvents SourceKelvin Ca System.Windows.Forms.RadioButton prieten WithEvents ValueFahrenheit Ca System.Windows.Forms.TextBox prieten WithEvents ValueCelsius Ca System.Windows.Forms.TextBox prieten WithEvents ValueKelvin Ca System.Windows.Forms.TextBox prieten WithEvents ConvertTemperature Ca System.Windows.Forms.Button Sfrit clasa public class ConvertForm Private Sub ConvertTemperature_Click ( ByVal expeditor Pe de eroare Reluare urmtoare

Ca

System.Object, ByVal e

n cazul n care ( SourceFahrenheit.Checked = True ) Atunci Daca ( IsNumeric ( ValueFahrenheit.Text ) = True ) Apoi ValueCelsius.Text = _ ( Val ( ValueFahrenheit.Text ) - 32 ) / 1.8 ValueKelvin.Text = _ (( Val ( ValueFahrenheit.Text ) - 32 ) / 1.8 ) + Altfel ValueCelsius.Text = "Eroare" ValueKelvin.Text = "Eroare" End Dac elseif ( SourceCelsius.Checked = True ) Atunci Daca ( IsNumeric ( ValueCelsius.Text ) = True ) Apoi ValueFahrenheit.Text = _ ( Val ( ValueCelsius.Text ) * 1.8 ) + 32 ValueKelvin.Text = Val ( ValueCelsius.Text ) + 273,15 Altfel ValueFahrenheit.Text = "Eroare" ValueKelvin.Text = "Eroare" End Dac Altfel Dac ( IsNumeric ( ValueKelvin. Textul ) = True ) Apoi ValueFahrenheit.Text = _ (( Val ( ValueKelvin.Text ) - 273.15 ) * 1.8 ) + ValueCelsius.Text = Val ( ValueKelvin.Text ) - 273.15 Altfel ValueFahrenheit.Text = "Eroare" ValueCelsius.Text = "Eroare" End Dac End Dac End Sub End Class public class FahrenheitCelsiusConverter

273,15

32

public comun Sub Main () Application.Run ( New ConvertForm ) End Sub End Class

Original

Imports System.Windows.Forms <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class ConvertForm Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SourceFahrenheit = New System.Windows.Forms.RadioButton Me.SourceCelsius = New System.Windows.Forms.RadioButton Me.SourceKelvin = New System.Windows.Forms.RadioButton Me.ValueFahrenheit = New System.Windows.Forms.TextBox Me.ValueCelsius = New System.Windows.Forms.TextBox Me.ValueKelvin = New System.Windows.Forms.TextBox Me.ConvertTemperature = New System.Windows.Forms.Button Me.SuspendLayout() ' 'SourceFahrenheit ' Me.SourceFahrenheit.AutoSize = True

Me.SourceFahrenheit.Checked = True Me.SourceFahrenheit.Location = New System.Drawing.Point(16, 24) Me.SourceFahrenheit.Name = "SourceFahrenheit" Me.SourceFahrenheit.Size = New System.Drawing.Size(75, 17) Me.SourceFahrenheit.TabIndex = 0 Me.SourceFahrenheit.TabStop = True Me.SourceFahrenheit.Text = "&Fahrenheit" Me.SourceFahrenheit.UseVisualStyleBackColor = True ' 'SourceCelsius ' Me.SourceCelsius.AutoSize = True Me.SourceCelsius.Location = New System.Drawing.Point(16, 56) Me.SourceCelsius.Name = "SourceCelsius" Me.SourceCelsius.Size = New System.Drawing.Size(58, 17) Me.SourceCelsius.TabIndex = 2 Me.SourceCelsius.Text = "&Celsius" Me.SourceCelsius.UseVisualStyleBackColor = True ' 'SourceKelvin ' Me.SourceKelvin.AutoSize = True Me.SourceKelvin.Location = New System.Drawing.Point(16, 88) Me.SourceKelvin.Name = "SourceKelvin" Me.SourceKelvin.Size = New System.Drawing.Size(53, 17) Me.SourceKelvin.TabIndex = 4 Me.SourceKelvin.Text = "&kelvin" Me.SourceKelvin.UseVisualStyleBackColor = True ' 'ValueFahrenheit ' Me.ValueFahrenheit.Location = New System.Drawing.Point(120, 24) Me.ValueFahrenheit.Name = "ValueFahrenheit" Me.ValueFahrenheit.Size = New System.Drawing.Size(100, 20) Me.ValueFahrenheit.TabIndex = 1 ' 'ValueCelsius ' Me.ValueCelsius.Location = New System.Drawing.Point(120, 56) Me.ValueCelsius.Name = "ValueCelsius" Me.ValueCelsius.Size = New System.Drawing.Size(100, 20) Me.ValueCelsius.TabIndex = 3 ' 'ValueKelvin ' Me.ValueKelvin.Location = New System.Drawing.Point(120, 88) Me.ValueKelvin.Name = "ValueKelvin" Me.ValueKelvin.Size = New System.Drawing.Size(100, 20) Me.ValueKelvin.TabIndex = 5 ' 'ConvertTemperature ' Me.ConvertTemperature.Location = New System.Drawing.Point(144, 128) Me.ConvertTemperature.Name = "ConvertTemperature" Me.ConvertTemperature.Size = New System.Drawing.Size(75, 23) Me.ConvertTemperature.TabIndex = 6 Me.ConvertTemperature.Text = "Convert" Me.ConvertTemperature.UseVisualStyleBackColor = True ' 'ConvertForm '

Me.AcceptButton = Me.ConvertTemperature Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(245, 169) Me.Controls.Add(Me.ConvertTemperature) Me.Controls.Add(Me.ValueKelvin) Me.Controls.Add(Me.ValueCelsius) Me.Controls.Add(Me.ValueFahrenheit) Me.Controls.Add(Me.SourceKelvin) Me.Controls.Add(Me.SourceCelsius) Me.Controls.Add(Me.SourceFahrenheit) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "ConvertForm" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Convert Temperatures" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents SourceFahrenheit As System.Windows.Forms.RadioButton SourceCelsius As System.Windows.Forms.RadioButton SourceKelvin As System.Windows.Forms.RadioButton ValueFahrenheit As System.Windows.Forms.TextBox ValueCelsius As System.Windows.Forms.TextBox ValueKelvin As System.Windows.Forms.TextBox ConvertTemperature As System.Windows.Forms.Button

End Class Public Class ConvertForm Private Sub ConvertTemperature_Click(ByVal sender As System.Object, ByVal e As Syste On Error Resume Next If (SourceFahrenheit.Checked = True) Then If (IsNumeric(ValueFahrenheit.Text) = True) Then ValueCelsius.Text = _ (Val(ValueFahrenheit.Text) - 32) / 1.8 ValueKelvin.Text = _ ((Val(ValueFahrenheit.Text) - 32) / 1.8) + 273.15 Else ValueCelsius.Text = "Error" ValueKelvin.Text = "Error" End If ElseIf (SourceCelsius.Checked = True) Then If (IsNumeric(ValueCelsius.Text) = True) Then ValueFahrenheit.Text = _ (Val(ValueCelsius.Text) * 1.8) + 32 ValueKelvin.Text = Val(ValueCelsius.Text) + 273.15 Else ValueFahrenheit.Text = "Error" ValueKelvin.Text = "Error" End If Else If (IsNumeric(ValueKelvin.Text) = True) Then ValueFahrenheit.Text = _ ((Val(ValueKelvin.Text) - 273.15) * 1.8) + 32 ValueCelsius.Text = Val(ValueKelvin.Text) - 273.15 Else ValueFahrenheit.Text = "Error" ValueCelsius.Text = "Error"

End If End If End Sub End Class public class FahrenheitCelsiusConverter Public Shared Sub Main() Application.Run(New ConvertForm) End Sub End Class

Inherit TextBox pentru a crea controlul personalizat bazat pe TextB


Imports Imports Imports Imports Imports Imports System System.Collections System.IO System.Windows.Forms System.Drawing System.Drawing.Drawing2D

Public class FileTextBox Motenete TextBox # Region "Component Designer codul generat" Ca System.ComponentModel.IContainer ) clasa Compoziie Designer suport

Public Sub New ( containere ByVal MyClass.New ()

"Re quired pentru Windows.Forms Container.Add ( Me ) End Sub Public Sub New () MyBase.New ()

"Th este apel este necesar de Designer Component. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Co mponent prevaleaz dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Component Designer Private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este necesar de Designer Component "Acesta poate fi modificat cu ajutorul . Designer Componenta "Nu -l modificai folosind . editorul de cod <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () componentele = Nou System.ComponentModel.Container () End Sub # End Regiunea

Protejate nlocuiete Sub OnTextChanged ( e ByVal Dac Nu File.Exists ( Me.Text ) Apoi Me.ForeColor = Color.Red Altfel Me.ForeColor = Color.Black End Dac MyBase.OnTextChanged ( e ) End Sub End Class

Ca

System.EventArgs )

Original

Imports Imports Imports Imports Imports Imports

System System.Collections System.IO System.Windows.Forms System.Drawing System.Drawing.Drawing2D

Public Class FileTextBox Inherits TextBox #Region " Component Designer generated code " Public Sub New(ByVal Container As System.ComponentModel.IContainer) MyClass.New() 'Required for Windows.Forms Class Composition Designer support Container.Add(Me) End Sub Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Component overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Component Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Component Designer 'It can be modified using the Component Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() components = New System.ComponentModel.Container() End Sub #End Region

Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs) If Not File.Exists(Me.Text) Then Me.ForeColor = Color.Red Else Me.ForeColor = Color.Black End If MyBase.OnTextChanged(e) End Sub End Class

Fiier text 14.23.4.Display ntr-un TextBox

Importurile

System.IO

Importurile

System.Windows.Forms

public class TextFileDisplayTextBox public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa

Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button () Me.TextBox1 = New System.Windows.Forms.TextBox () Me . SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 104 , 24 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Selecteaza un fiier " " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 20 , 80 ) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Ca apel

Bool

Me.TextBox1.Size = Sistem. Drawing.Size ( 250 , 150 ) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Sistem. Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Button1, Me.Text Me.Name = "Form1" Me.Text = "Form1" Me. ResumeLayout ( Fals ) End Sub # End Regiunea Ca obiect, ByVal e ca

Private Sub Button1_Click ( expeditor ByVal Dim FileDB Ca New OpenFileDialog () FileDB.Filter =

System.EventA

"Toate fiierele | * | *. fiiere Word * | doc |. fiiere text 3 "C: \ Temp" = DialogResult.OK ) Apoi

FileDB.FilterIndex =

FileDB.InitialDirectory =

n cazul n care ( FileDB.ShowDialog () Dim FS Ca FileStream ncercai s FS = FileDB.OpenFile () Catch MsgBox ( "Eroare la deschiderea" End ncercai Dim Dim Dim Dim Nu TextData ( 1025 ) Ca Byte BytesRead Ca Integer am Ca Integer NewText Ca String

& FileDB.FileName )

ncercai BytesRead = FS.Read ( TextData,

1 ,

1024 )

NewText = "" pentru i = 1 Pentru a BytesRead NewText = NewText & Chr. ( TextData ( I )) nainte TextBox1.AppendText ( NewText ) Catch MsgBox ( "Eroare citind fisierul" ) End ncercai Bucla de timp FS.Close () Else MsgBox ( "utilizator selectat Cancel" ) End If End Sub ( BytesRead <> 0 )

End Class

Original

Imports System.IO Imports System.Windows.Forms public class TextFileDisplayTextBox public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then

components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(104, 24) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Select a File" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(20, 80) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(250, 150) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.TextBox1 Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handl Dim FileDB As New OpenFileDialog() FileDB.Filter = "All files | *.* | Word files | *.doc | Text files | *.txt" FileDB.FilterIndex = 3 FileDB.InitialDirectory = "C:\Temp" If (FileDB.ShowDialog() = DialogResult.OK) Then Dim FS As FileStream Try

FS = FileDB.OpenFile() Catch MsgBox("Error opening " & FileDB.FileName) End Try Dim Dim Dim Dim Do Try BytesRead = FS.Read(TextData, 1, 1024) NewText = "" For I = 1 To BytesRead NewText = NewText & Chr(TextData(I)) Next TextBox1.AppendText(NewText) Catch MsgBox("Error reading file") End Try Loop While (BytesRead <> 0) FS.Close() Else MsgBox("User selected Cancel") End If End Sub End Class TextData(1025) As Byte BytesRead As Integer I As Integer NewText As String

Numeric TextBox

Importurile

System.Windows.Forms

public class NumericTextBoxDemo public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents NumTextBox1 Ca NumTextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button () Me.NumTextBox1 = New NumTextBox () Me.SuspendLayout () " "Bu tton1 " Me.Button1 . Locaia = New System.Drawing.Point ( 144 , 120 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 1 Me.Button1.Text = "Do It!" " "Nu mTextBox1 " Me.NumTextBox1. Locaie = New System.Drawing.Point ( 32 , 56 ) Me.NumTextBox1.Name = "NumTextBox1" Me.NumTextBox1.TabIndex = 3 Me.NumTextBox1.Text = "NumTextBox1" " "Fo RM1 ' Me.AutoScaleBaseSize = Sistem. Drawing.Size ( 5 , 13 ) Ca apel

Bool

Me.ClientSize = New System.Drawing.Size ( 292 , 266 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.NumTextBox1, Me.Bu Me . Nume = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

End Class Public class NumTextBox Motenete System.Windows.Forms.TextBox # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Noi erControl1 suprascrie dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () " "Nu mTextBox " End Sub # End Regiunea Ca apel

Boole

Protejate nlocuiete Sub OnLeave ( ByVal e ca System.EventArgs ) n cazul n care nu IsNumeric ( Me.Text ) Atunci MessageBox.Show ( "Trebuie s introducei o valoare numeric!" , _ "V rugm s ncercai din nou ...." , MessageBoxButtons.OK, _ MessageBoxIcon.Exclamation ) Me.Focus ()

End If MyBase.OnLeave ( e ) End Sub End Class

Original

Imports System.Windows.Forms public class NumericTextBoxDemo public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If

End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents NumTextBox1 As NumTextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.NumTextBox1 = New NumTextBox() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(144, 120) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 1 Me.Button1.Text = "Do It!" ' 'NumTextBox1 ' Me.NumTextBox1.Location = New System.Drawing.Point(32, 56) Me.NumTextBox1.Name = "NumTextBox1" Me.NumTextBox1.TabIndex = 3 Me.NumTextBox1.Text = "NumTextBox1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.NumTextBox1, Me.Button Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region End Class Public Class NumTextBox Inherits System.Windows.Forms.TextBox #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call

End Sub 'UserControl1 overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() ' 'NumTextBox ' End Sub #End Region Protected Overrides Sub OnLeave(ByVal e As System.EventArgs) If Not IsNumeric(Me.Text) Then MessageBox.Show("You must enter a numeric value!", _ "Please try again....", MessageBoxButtons.OK, _ MessageBoxIcon.Exclamation) Me.Focus() End If MyBase.OnLeave(e) End Sub End Class

TextBox Text schimbat Eveniment

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class TextBoxTextChanged: motenete Form

dim txt ca TextBox dim BTN ca Button dim strOriginal ca ir publice sub noi () Text = "TextBox modificate i TextChanged" Size = new Dimensiune ( 300 , 375 )

txt = new TextBox () txt.Parent = ma txt.Text = "Introduceti textul aici." txt.Size = new Dimensiune ( 280 , 275 ) txt.Location = new Punct ( 10 , 10 ) AddHandler txt.TextChanged, AddressOf txt_TextChanged txt.Multiline = true txt.BorderStyle = BorderStyle.Fixed3D txt.ScrollBars = ScrollBars.Vertical txt.Anchor = AnchorStyles.Left sau AnchorStyles.Right sau AnchorStyles.Top sau Ancho strOriginal = txt.Text BTN = new Button () btn.Parent = ma btn.Text = "Check" btn.Location = new Punct ( 20 , 320 ) AddHandler btn.Click, AddressOf btn_Click btn.Anchor = AnchorStyles.Bottom end sub comune sub Main ()

publice

Application.Run ( nou end sub

TextBoxTextChanged ())

privat sub txt_TextChanged ( expeditor ByVal ca obiect, e ByVal ca EventArgs ) Console.WriteLine ( "txt_TextChanged" ) dac strOriginal = txt.Text apoi txt.Modified = false altfel txt.Modified = true final, dac finali sub privat sub btn_Click ( expeditor ByVal ca obiect, e ByVal ca EventArgs ) n cazul n care txt.Modified apoi Console.WriteLine ( "modificat." ) strOriginal = txt.Text txt.Modified = false altceva Console.WriteLine ( "nu a fost modificat." ) capt n cazul n sfrit sub clasa de sfritul

Original

imports System imports System.Drawing imports System.Windows.Forms public class TextBoxTextChanged : inherits Form

dim txt as TextBox dim btn as Button dim strOriginal as string public sub New() Text = "TextBox Modified and TextChanged" Size = new Size(300, 375)

txt = new TextBox() txt.Parent = me txt.Text = "Enter text here." txt.Size = new Size(280, 275) txt.Location = new Point(10,10) AddHandler txt.TextChanged, AddressOf txt_TextChanged txt.Multiline = true txt.BorderStyle = BorderStyle.Fixed3D txt.ScrollBars = ScrollBars.Vertical txt.Anchor = AnchorStyles.Left or AnchorStyles.Right or AnchorStyles.Top or AnchorSt strOriginal = txt.Text btn = new Button() btn.Parent = me btn.Text = "Check " btn.Location = new Point(20,320) AddHandler btn.Click, AddressOf btn_Click btn.Anchor = AnchorStyles.Bottom end sub public shared sub Main() Application.Run(new TextBoxTextChanged()) end sub private sub txt_TextChanged(ByVal sender as object,ByVal e as EventArgs) Console.WriteLine("txt_TextChanged") if strOriginal = txt.Text then txt.Modified = false else txt.Modified = true end if end sub private sub btn_Click(ByVal sender as object,ByVal e as EventArgs) if txt.Modified then Console.WriteLine("modified.") strOriginal = txt.Text txt.Modified = false else Console.WriteLine("not been modified." ) end if end sub end class

Demo 14.23.7.Comprehensive pentru TextBox

"Pr. ogramming. net aplicaii Windows [ Illustrated ] ( Paperback ) "de Jesse Liberty ( Autor ) , Dan Hurwitz ( Autor ) "# "# "# "# Editura: O 'Re illy Media, Inc; Limba: englez ISBN- 10 : 0596003218 ISBN- 13 : 978 - 0596003210 de sistem System.Drawing System.Windows.Forms System.Text 1 ediie ( octombrie 28 , 2003 )

importurile importurile importurile importurile

spaiu de nume ProgrammingWinApps public class casete: motenete Form dim yDelta ca ntregi yPos dim ca ntreg = 20 txtSingle dim ca TextBox dim txtMulti ca TextBox txtDisplay dim ca TextBox BTN dim ca Button txtBoxes dim ( 1 ) ca TextBox publice sub noi () Text = "casete" Size = new Dimensiune ( 450 , 375 ) lblSingle dim ca nou Label () lblSingle.Parent = ma lblSingle.Text = "TextBox Single Line:" lblSingle.Location = new Punct ( 10 , yPos ) lblSingle.Size = new Dimensiune ( 150 , 20 ) lblSingle.TextAlign = ContentAlignment. MiddleRight yDelta = lblSingle.Height + 10

txtSingle = new TextBox () txtSingle.Parent = ma txtSingle.Text = "singur linie" txtSingle.Size = new Dimensiune ( 200 , txtSingle.PreferredHeight ) txtSingle.Location = new Punct ( lblSingle.Left + _ lblSingle.Size.Width, yPos ) txtSingle.Multiline = false txtSingle.BorderStyle = BorderStyle.Fixed3D dim lblMulti ca nou Label () lblMulti.Parent = ma lblMulti.Text = "Linia TextBox Multi:" lblMulti.Location = new Punct ( 10 , yPos + yDelta ) lblMulti.Size = new Dimensiune ( 150 , 20 ) lblMulti.TextAlign = ContentAlignment.MiddleRight txtMulti = new TextBox () txtMulti.Parent = ma txtMulti.Text = "Multi Linia" txtMulti.Size = new Dimensiune ( 200 , 100 ) txtMulti.Location = new Punct ( lblMulti.Left + _ lblMulti.Size.Width, yPos + yDelta ) txtMulti.AcceptsTab = true txtMulti.Multiline = true txtMulti.BorderStyle = BorderStyle.Fixed3D txtMulti.ScrollBars = ScrollBars.Vertical BTN = new Button () btn.Parent = ma btn.Text = "Arat MultiLines" btn.Location = new Punct ( lblMulti.Left + _ lblMulti.Size.Width, yPos + ( 5 * yDelta )) AddHandler btn.Click, AddressOf btn_Click dim xSize ca ntreg = Ctype (( Font.Height * .75 ) * _ btn.Text.Length, ntreg ) ySize dim ca ntreg = Font.Height + 10 btn.Size = new Dimensiuni ( xSize, ySize ) txtDisplay = new TextBox () txtDisplay.Parent = ma txtDisplay.Text = "" txtDisplay.Size = new Dimensiune ( 200 , 100 ) txtDisplay.Location = new Punct ( lblMulti.Left + _ lblMulti.Size.Width, yPos + ( 6 * yDelta )) txtDisplay.Multiline = true txtDisplay.BorderStyle = BorderStyle.FixedSingle txtDisplay.BackColor = Color.LightGray txtDisplay.ScrollBars = ScrollBars.Vertical txtDisplay.ReadOnly = true " Umplei serie de casete txtBoxes ( 0 ) = txtSingle txtBoxes ( 1 ) = txtMulti " meniuri " Modificai elementele de meniu dim mnuDash1 ca noi MenuItem ( "-" ) mnuDash2 dim ca noi MenuItem ( "-" ) mnuUndo dim ca noi MenuItem ( "& Undo" , _ nou EventHandler ( AddressOf mnuUndo_Click ) , _ Shortcut.CtrlZ )

dim mnuCut ca noi MenuItem ( "Cu & T" , _ nou EventHandler ( AddressOf mnuCut_Click ) , _ Shortcut.CtrlX ) mnuCopy dim ca noi MenuItem ( "& Copy" , _ nou EventHandler ( AddressOf mnuCopy_Click ) , _ Shortcut.CtrlC ) mnuPaste dim ca noi MenuItem ( "& Paste" , _ nou EventHandler ( AddressOf mnuPaste_Click ) , _ Shortcut.CtrlV ) mnuDelete dim ca noi MenuItem ( "& Delete" , _ nou EventHandler ( AddressOf mnuDelete_Click )) mnuSelectAll dim ca noi MenuItem ( "Select & ai tot" , _ nou EventHandler ( AddressOf mnuSelectAll_Click ) , _ Shortcut.CtrlA ) dim mnuSelect5 ca noi MenuItem ( "Select First & 5" , _ nou EventHandler ( AddressOf mnuSelect5_Click ) , _ Shortcut.Ctrl5 ) dim mnuClear ca noi MenuItem ( "Clea & R" , _ nou EventHandler ( AddressOf mnuClear_Click )) dim mnuEdit ca noi MenuItem ( "& Edit" , _ nou MenuItem () { mnuUndo, mnuDash1, _ mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuDash2, _ mnuSelectAll, mnuSelect5, mnuClear }) " Vezi produsele meniu mnuScrollToCaret dim ca noi MenuItem ( "& Alegei caret" , _ nou EventHandler ( AddressOf mnuScrollToCaret_Click )) mnuView dim ca noi MenuItem ( "& View" , _ nou MenuItem () { mnuScrollToCaret }) " Meniul principal Meniul = new MainMenu ( nou end sub " aproape de MenuItem () { mnuEdit, mnuView })

constructor

public comun sub Main () Application.Run ( noi casete ()) finali sub privat sub mnuUndo_Click ( expeditor ByVal Ca obiect, _ ByVal e ca EventArgs ) dim i ca ntreg pentru i = 0 la txtBoxes.Length - 1 dac txtBoxes ( i ) . Axat apoi dim txt ca TextBox = Ctype ( txtBoxes ( i ) , TextBox ) n cazul n care txt.CanUndo = true atunci txt.Undo () txt.ClearUndo () final, dac final, dac urmtoarele finali sub privat sub mnuCut_Click ( expeditor ByVal Ca obiect, _ ByVal e ca EventArgs ) dim i ca ntreg pentru i = 0 la txtBoxes.Length - 1 dac txtBoxes ( i ) . Axat apoi dim txt ca TextBox = Ctype ( txtBoxes ( i ) , TextBox ) n cazul n txt.SelectedText <> "" , apoi

txt.Cut () final, dac final, dac urmtoarele finali sub privat sub mnuCopy_Click ( expeditor ByVal Ca obiect, _ ByVal e ca EventArgs ) dim i ca ntreg pentru i = 0 la txtBoxes.Length - 1 dac txtBoxes ( i ) . Axat apoi dim txt ca TextBox = Ctype ( txtBoxes ( i ) , TextBox ) n cazul n txt.SelectionLength> 0 atunci txt.Copy () final, dac final, dac urmtoarele finali sub privat

sub mnuPaste_Click ( expeditor ByVal Ca obiect, _ ByVal e Ca EventArgs ) n cazul n care Clipboard.GetDataObject () . GetDataPresent ( DataFormats.Text ) dim i ca ntreg pentru i = 0 la txtBoxes.Length - 1 dac txtBoxes ( i ) . Axat apoi dim txt ca TextBox = Ctype ( txtBoxes ( i ) , TextBox ), n cazul n txt.SelectionLength> 0 atunci dac MessageBox.Show ( _ "Vrei s suprascrie textul selectat?" , _ "Cut & Paste" , MessageBoxButtons.YesNo ) = _ DialogResult.No apoi txt.SelectionStart = txt.SelectionStart + _ txt.SelectionLength final, dac capt dac txt.Paste () final, dac urmtor scop dac finali sub privat sub mnuDelete_Click ( expeditor ByVal Ca obiect, _ ByVal e ca EventArgs ) dim i ca ntreg pentru i = 0 la txtBoxes.Length - 1 dac txtBoxes ( i ) . Axat apoi dim txt ca TextBox = Ctype ( txtBoxes ( i ) , TextBox ) n cazul n txt.SelectionLength> 0 atunci txt.SelectedText = "" sfrit dac sfrit dac urmtoarele finali sub privat sub mnuClear_Click ( expeditor ByVal Ca obiect, _ ByVal e ca EventArgs ) dim i ca ntreg pentru i = 0 la txtBoxes.Length - 1 dac txtBoxes ( i ) . Axat apoi dim txt ca TextBox = Ctype ( txtBoxes ( i ) , TextBox ) txt.Clear ()

final, dac urmtoarele finali sub privat sub mnuSelect5_Click ( expeditor ByVal Ca obiect, _ ByVal e ca EventArgs ) dim i ca ntreg pentru i = 0 la txtBoxes.Length - 1 dac txtBoxes ( i ) . Axat apoi dim txt ca TextBox = Ctype ( txtBoxes ( i ) , TextBox ) n cazul n care txt.Text.Length> = 5 atunci txt.Select ( 0 , 5 ) altfel txt.Select ( 0 , txt.Text.Length ) final, dac final, dac urmtoarele finali sub privat sub mnuSelectAll_Click ( expeditor ByVal Ca obiect, _ ByVal e ca EventArgs ) dim i ca ntreg pentru i = 0 la txtBoxes.Length - 1 dac txtBoxes ( i ) . Axat apoi dim txt ca TextBox = Ctype ( txtBoxes ( i ) , TextBox ) txt.SelectAll () final, dac urmtoarele finali sub privat sub mnuScrollToCaret_Click ( expeditor ByVal Ca obiect, _ ByVal e ca EventArgs ) dim i ca ntreg pentru i = 0 la txtBoxes.Length - 1 dac txtBoxes ( i ) . Axat apoi dim txt ca TextBox = Ctype ( txtBoxes ( i ) , TextBox ) txt.ScrollToCaret () final, dac urmtoarele finali sub privat sub btn_Click ( expeditor ByVal ca obiect, _ ByVal e ca EventArgs ) "C uzul cu o matrice ir de a deine proprietatea Lines. arLines dim ( txtMulti.Lines.Length - 1 ) ca ir arLines = txtMulti.Lines " Utilizarea StringBuilder de eficien. str. dim ca string = "Linia" + vbTab + "String" dim SB ca nou StringBuilder () sb.Append ( str ) + vbCrLf

"Am terate prin matrice & afia fiecare linie. dim i ca ntreg pentru i = 0 la arLines.Length - 1 str = i.ToString () + "." + + vbTab arLines ( i ) sb.Append ( str. ) urmtor txtDisplay.Text = sb.ToString () finali sub

+ vbCrLf

Clasa sfritul final Spaiul

Original

'Programming .Net Windows Applications [ILLUSTRATED] (Paperback) 'by Jesse Liberty (Author), Dan Hurwitz (Author) '# '# '# '# Publisher: O'Reilly Media, Inc.; 1 edition (October 28, 2003) Language: English ISBN-10: 0596003218 ISBN-13: 978-0596003210 System System.Drawing System.Windows.Forms System.Text

imports imports imports imports

namespace ProgrammingWinApps public class TextBoxes : inherits Form dim dim dim dim dim dim dim yDelta as integer yPos as integer = 20 txtSingle as TextBox txtMulti as TextBox txtDisplay as TextBox btn as Button txtBoxes(1) as TextBox

public sub New() Text = "TextBoxes" Size = new Size(450,375) dim lblSingle as new Label() lblSingle.Parent = me lblSingle.Text = "Single Line TextBox:" lblSingle.Location = new Point(10,yPos) lblSingle.Size = new Size(150,20) lblSingle.TextAlign = ContentAlignment.MiddleRight yDelta = lblSingle.Height + 10 txtSingle = new TextBox() txtSingle.Parent = me txtSingle.Text = "Single Line" txtSingle.Size = new Size(200, txtSingle.PreferredHeight) txtSingle.Location = new Point(lblSingle.Left + _ lblSingle.Size.Width, yPos) txtSingle.Multiline = false txtSingle.BorderStyle = BorderStyle.Fixed3D dim lblMulti as new Label() lblMulti.Parent = me lblMulti.Text = "Multi Line TextBox:" lblMulti.Location = new Point(10, yPos + yDelta) lblMulti.Size = new Size(150,20) lblMulti.TextAlign = ContentAlignment.MiddleRight txtMulti = new TextBox() txtMulti.Parent = me txtMulti.Text = "Multi Line" txtMulti.Size = new Size(200,100) txtMulti.Location = new Point(lblMulti.Left + _ lblMulti.Size.Width, yPos + yDelta) txtMulti.AcceptsTab = true txtMulti.Multiline = true txtMulti.BorderStyle = BorderStyle.Fixed3D txtMulti.ScrollBars = ScrollBars.Vertical btn = new Button() btn.Parent = me btn.Text = "Show MultiLines" btn.Location = new Point(lblMulti.Left + _ lblMulti.Size.Width, yPos + (5 * yDelta)) AddHandler btn.Click, AddressOf btn_Click dim xSize as integer = CType((Font.Height * .75) * _ btn.Text.Length, integer) dim ySize as integer = Font.Height + 10 btn.Size = new Size(xSize, ySize) txtDisplay = new TextBox() txtDisplay.Parent = me txtDisplay.Text = "" txtDisplay.Size = new Size(200,100) txtDisplay.Location = new Point(lblMulti.Left + _ lblMulti.Size.Width, yPos + (6 * yDelta)) txtDisplay.Multiline = true txtDisplay.BorderStyle = BorderStyle.FixedSingle txtDisplay.BackColor = Color.LightGray txtDisplay.ScrollBars = ScrollBars.Vertical txtDisplay.ReadOnly = true

' Fill the array of TextBoxes txtBoxes(0) = txtSingle txtBoxes(1) = txtMulti ' Menus ' Edit menu items dim mnuDash1 as new MenuItem("-") dim mnuDash2 as new MenuItem("-") dim mnuUndo as new MenuItem("&Undo", _ new EventHandler(AddressOf mnuUndo_Click), _ Shortcut.CtrlZ) dim mnuCut as new MenuItem("Cu&t", _ new EventHandler(AddressOf mnuCut_Click), _ Shortcut.CtrlX) dim mnuCopy as new MenuItem("&Copy", _ new EventHandler(AddressOf mnuCopy_Click), _ Shortcut.CtrlC) dim mnuPaste as new MenuItem("&Paste", _ new EventHandler(AddressOf mnuPaste_Click), _ Shortcut.CtrlV) dim mnuDelete as new MenuItem("&Delete", _ new EventHandler(AddressOf mnuDelete_Click)) dim mnuSelectAll as new MenuItem("Select &All", _ new EventHandler(AddressOf mnuSelectAll_Click), _ Shortcut.CtrlA) dim mnuSelect5 as new MenuItem("Select First &5", _ new EventHandler(AddressOf mnuSelect5_Click), _ Shortcut.Ctrl5) dim mnuClear as new MenuItem("Clea&r", _ new EventHandler(AddressOf mnuClear_Click)) dim mnuEdit as new MenuItem("&Edit", _ new MenuItem() {mnuUndo, mnuDash1, _ mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuDash2, _ mnuSelectAll, mnuSelect5, mnuClear}) ' View Menu items dim mnuScrollToCaret as new MenuItem("&Scroll to Caret", _ new EventHandler(AddressOf mnuScrollToCaret_Click)) dim mnuView as new MenuItem("&View", _ new MenuItem() {mnuScrollToCaret}) ' Main menu Menu = new MainMenu(new MenuItem() {mnuEdit, mnuView}) end sub ' close for constructor

public shared sub Main() Application.Run(new TextBoxes()) end sub private sub mnuUndo_Click(ByVal sender As Object, _ ByVal e As EventArgs) dim i as integer for i = 0 to txtBoxes.Length - 1 if txtBoxes(i).Focused then dim txt as TextBox = CType(txtBoxes(i), TextBox) if txt.CanUndo = true then txt.Undo() txt.ClearUndo()

end if end if next end sub private sub mnuCut_Click(ByVal sender As Object, _ ByVal e As EventArgs) dim i as integer for i = 0 to txtBoxes.Length - 1 if txtBoxes(i).Focused then dim txt as TextBox = CType(txtBoxes(i), TextBox) if txt.SelectedText <> "" then txt.Cut() end if end if next end sub private sub mnuCopy_Click(ByVal sender As Object, _ ByVal e As EventArgs) dim i as integer for i = 0 to txtBoxes.Length - 1 if txtBoxes(i).Focused then dim txt as TextBox = CType(txtBoxes(i), TextBox) if txt.SelectionLength > 0 then txt.Copy() end if end if next end sub private sub mnuPaste_Click(ByVal sender As Object, _ ByVal e As EventArgs) if Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) = true then dim i as integer for i = 0 to txtBoxes.Length - 1 if txtBoxes(i).Focused then dim txt as TextBox = CType(txtBoxes(i), TextBox) if txt.SelectionLength > 0 then if MessageBox.Show( _ "Do you want to overwrite the currently selected text?", _ "Cut & Paste", MessageBoxButtons.YesNo) = _ DialogResult.No then txt.SelectionStart = txt.SelectionStart + _ txt.SelectionLength end if end if txt.Paste() end if next end if end sub private sub mnuDelete_Click(ByVal sender As Object, _ ByVal e As EventArgs) dim i as integer for i = 0 to txtBoxes.Length - 1 if txtBoxes(i).Focused then dim txt as TextBox = CType(txtBoxes(i), TextBox) if txt.SelectionLength > 0 then txt.SelectedText = ""

end if end if next end sub private sub mnuClear_Click(ByVal sender As Object, _ ByVal e As EventArgs) dim i as integer for i = 0 to txtBoxes.Length - 1 if txtBoxes(i).Focused then dim txt as TextBox = CType(txtBoxes(i), TextBox) txt.Clear() end if next end sub private sub mnuSelect5_Click(ByVal sender As Object, _ ByVal e As EventArgs) dim i as integer for i = 0 to txtBoxes.Length - 1 if txtBoxes(i).Focused then dim txt as TextBox = CType(txtBoxes(i), TextBox) if txt.Text.Length >= 5 then txt.Select(0,5) else txt.Select(0,txt.Text.Length) end if end if next end sub private sub mnuSelectAll_Click(ByVal sender As Object, _ ByVal e As EventArgs) dim i as integer for i = 0 to txtBoxes.Length - 1 if txtBoxes(i).Focused then dim txt as TextBox = CType(txtBoxes(i), TextBox) txt.SelectAll() end if next end sub private sub mnuScrollToCaret_Click(ByVal sender As Object, _ ByVal e As EventArgs) dim i as integer for i = 0 to txtBoxes.Length - 1 if txtBoxes(i).Focused then dim txt as TextBox = CType(txtBoxes(i), TextBox) txt.ScrollToCaret() end if next end sub private sub btn_Click(ByVal sender as object, _ ByVal e as EventArgs) ' Create a string array to hold the Lines property. dim arLines(txtMulti.Lines.Length - 1) as string arLines = txtMulti.Lines ' Use stringBuilder for efficiency. dim str as string = "Line" + vbTab + "String" + vbCrLf

dim sb as new StringBuilder() sb.Append(str) ' Iterate through the array & display each line. dim i as integer for i = 0 to arLines.Length - 1 str = i.ToString() + "." + vbTab + arLines(i) + vbCrLf sb.Append(str) next txtDisplay.Text = sb.ToString() end sub end class end namespace

Font TextBox 14.23.8.Change de RadioButon i CheckBox

Importurile

System.Windows.Forms

public class RadioButtonControlFont public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 publice mysize Ca Integer publice mybold Ca Boolean publice myItalic Ca Boolean Private Sub RadioButton1_CheckedChanged ( expeditor ByVal CheckBox1.Checked = 1 End Sub Ca

System.Object, ByVal

Private Sub CheckBox1_CheckedChanged ( expeditor ByVal Ca System.Object, ByVal e myItalic = Nu myItalic TextBox1.Font = New System.Drawing.Font ( "" , mysize, Drawing.FontStyle.Regular Dac myItalic i mybold Apoi TextBox1.Font = New System.Drawing.Font ( "" , mysize, Drawing.FontStyle.Ita

Elseif myItalic Apoi TextBox1.Font = New System.Drawing.Font ( "" , mysize, Drawing.FontStyle.Ita elseif mybold Apoi,

TextBox1.Font = New System.Drawing.Font ( "" , mysize, Drawing.FontStyle.Bol End If End Sub Private Sub End Sub Private Sub Form1_Load ( ByVal expeditor mybold = Fals myItalic = false mysize = 25 End Sub Private Sub RadioButton1_CheckedChanged_1 ( expeditor ByVal mysize = 36 TextBox1.Font = New System.Drawing.Font ( "" , mysize ) End Sub Private Sub RadioButton2_CheckedChanged ( expeditor ByVal Ca mysize = 25 TextBox1.Font = New System.Drawing.Font ( "" , mysize ) End Sub Ca Ca System.Object, ByVal e ca GroupBox1_Enter ( expeditor ByVal Ca System.Object, ByVal e ca

Syst

System.Ev

System.Object, ByV

System.Object, ByVal

Private Sub CheckBox2_CheckedChanged ( expeditor ByVal Ca System.Object, ByVal e mybold = Nu mybold TextBox1.Font = New System.Drawing.Font ( "" , mysize, Drawing.FontStyle.Regular Dac myItalic i mybold Apoi TextBox1.Font = New System.Drawing.Font ( "" , mysize, Drawing.FontStyle.Bol elseif myItalic Apoi TextBox1.Font = New System.Drawing.Font ( "" , mysize, Drawing.FontStyle.Ita elseif mybold Apoi TextBox1.Font = New System.Drawing.Font ( "" , mysize, Drawing.FontStyle.Bol End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Boolean )

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.CheckBox1 = System.Windows.Forms.CheckBox New Me.CheckBox2 = System.Windows.Forms.CheckBox New Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.RadioButton1 = New System.Windows.Forms.RadioButton mine. RadioButton2 = New System.Windows.Forms.RadioButton Me.TextBox1 = Nou

= True Me.CheckBox1.Location = New System.Drawing.Point Me.CheckBox1.Name = "CheckBox1" Me.CheckBox1.Size = New System.Drawing.Size ( 48 Me.CheckBox1.TabIndex = 1 Me.CheckBox1.Text = "Italic" Me.CheckBox1.UseVisualStyleBackColor = True ' 'Ch eckBox2 ' Me.CheckBox2.AutoSize = True Me.CheckBox2.Location = New System.Drawing.Point Me.CheckBox2 . Nume = "CheckBox2" Me.CheckBox2.Size = New System.Drawing.Size ( 48 Me.CheckBox2.TabIndex = 2 Me.CheckBox2.Text = "Bold" Me.CheckBox2.UseVisualStyleBackColor =

( 230 , , 16 )

34 )

( 230 , , 16 )

56 )

= New System.Drawing.Point ( 224 , 85 ) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size ( 132 , 77 ) Me.GroupBox1.TabIndex = 3 Me.GroupBox1.TabStop = false Me.GroupBox1.Text = "Font size" " "Ra dioButton1 ' Me.RadioButton1.AutoSize = True Me.RadioButton1.Location = New System.Drawing.Point ( 6 , 20 ) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.Size = New System.Drawing.Size ( 59 , 16 ) Me.RadioButton1.TabIndex = 1 Me.RadioButton1.TabStop = True Me.RadioButton1.Text = "font mai mare" Me.RadioButton1.UseVisualStyleBackColor = True ' " Ra dioButton2 ' Me.RadioButton2.AutoSize = True Me.RadioButton2.Location = New System.Drawing.Point ( 6 , 42 ) Me.RadioButton2.Name = "RadioButton2"

Me.RadioButton2.Size = New System.Drawing.Size ( 59 , 16 ) Me.RadioButton2.TabIndex = 2 Me.RadioButton2.TabStop = True Me.RadioButton2.Text = "font mai mic" Me.RadioButton2.UseVisualStyleBackColor = True ' 'Te xtBox1 ' Me.TextBox1.Location = New System.Drawing. punctul ( 12 , 12 ) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 195 , 150 ) Me.TextBox1.TabIndex = 4 Me.TextBox1. Text = "www.java2s.com" " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 12.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou

= "Form1" Me.Text

Sub End prieten WithEvents CheckBox1 Ca System.Windows.Forms.CheckBox prieten WithEvents CheckBox2 Ca System.Windows.Forms.CheckBox prieten WithEvents GroupBox1 Ca System.Windows.Forms.GroupBox prieten WithEvents RadioButton2 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton1 Ca System.Windows.Forms.RadioButton prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox End Class

Original

Imports System.Windows.Forms public class RadioButtonControlFont public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Public mysize As Integer Public mybold As Boolean Public myItalic As Boolean

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy CheckBox1.Checked = 1 End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste myItalic = Not myItalic TextBox1.Font = New System.Drawing.Font("", mysize, Drawing.FontStyle.Regular) If myItalic And mybold Then TextBox1.Font = New System.Drawing.Font("", mysize, Drawing.FontStyle.Italic

ElseIf myItalic Then TextBox1.Font = New System.Drawing.Font("", mysize, Drawing.FontStyle.Italic ElseIf mybold Then TextBox1.Font = New System.Drawing.Font("", mysize, Drawing.FontStyle.Bold) End If End Sub

Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventAr End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H mybold = False myItalic = False mysize = 25 End Sub Private Sub RadioButton1_CheckedChanged_1(ByVal sender As System.Object, ByVal e As mysize = 36

TextBox1.Font = New System.Drawing.Font("", mysize) End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy mysize = 25 TextBox1.Font = New System.Drawing.Font("", mysize) End Sub

Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste mybold = Not mybold TextBox1.Font = New System.Drawing.Font("", mysize, Drawing.FontStyle.Regular) If myItalic And mybold Then TextBox1.Font = New System.Drawing.Font("", mysize, Drawing.FontStyle.Bold) ElseIf myItalic Then TextBox1.Font = New System.Drawing.Font("", mysize, Drawing.FontStyle.Italic ElseIf mybold Then TextBox1.Font = New System.Drawing.Font("", mysize, Drawing.FontStyle.Bold) End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.CheckBox1 = New System.Windows.Forms.CheckBox Me.CheckBox2 = New System.Windows.Forms.CheckBox Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.TextBox1 = New System.Windows.Forms.TextBox Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'CheckBox1 ' Me.CheckBox1.AutoSize = True Me.CheckBox1.Location = New System.Drawing.Point(230, 34) Me.CheckBox1.Name = "CheckBox1" Me.CheckBox1.Size = New System.Drawing.Size(48, 16) Me.CheckBox1.TabIndex = 1 Me.CheckBox1.Text = "Italic"

Me.CheckBox1.UseVisualStyleBackColor = True ' 'CheckBox2 ' Me.CheckBox2.AutoSize = True Me.CheckBox2.Location = New System.Drawing.Point(230, 56) Me.CheckBox2.Name = "CheckBox2" Me.CheckBox2.Size = New System.Drawing.Size(48, 16) Me.CheckBox2.TabIndex = 2 Me.CheckBox2.Text = "Bold" Me.CheckBox2.UseVisualStyleBackColor = True ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.RadioButton2) Me.GroupBox1.Controls.Add(Me.RadioButton1) Me.GroupBox1.Location = New System.Drawing.Point(224, 85) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(132, 77) Me.GroupBox1.TabIndex = 3 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Font size" ' 'RadioButton1 ' Me.RadioButton1.AutoSize = True Me.RadioButton1.Location = New System.Drawing.Point(6, 20) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.Size = New System.Drawing.Size(59, 16) Me.RadioButton1.TabIndex = 1 Me.RadioButton1.TabStop = True Me.RadioButton1.Text = "Larger font" Me.RadioButton1.UseVisualStyleBackColor = True ' 'RadioButton2 ' Me.RadioButton2.AutoSize = True Me.RadioButton2.Location = New System.Drawing.Point(6, 42) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.Size = New System.Drawing.Size(59, 16) Me.RadioButton2.TabIndex = 2 Me.RadioButton2.TabStop = True Me.RadioButton2.Text = "Smaller font" Me.RadioButton2.UseVisualStyleBackColor = True ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(12, 12) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(195, 150) Me.TextBox1.TabIndex = 4 Me.TextBox1.Text = "www.java2s.com" ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(368, 174) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.GroupBox1)

Me.Controls.Add(Me.CheckBox2) Me.Controls.Add(Me.CheckBox1) Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout(False) Me.GroupBox1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class CheckBox1 As System.Windows.Forms.CheckBox CheckBox2 As System.Windows.Forms.CheckBox GroupBox1 As System.Windows.Forms.GroupBox RadioButton2 As System.Windows.Forms.RadioButton RadioButton1 As System.Windows.Forms.RadioButton TextBox1 As System.Windows.Forms.TextBox

Textul 14.23.9.Get selectat n caseta

Imports Imports Imports Imports

System.Windows.Forms System.Drawing.Text System.Drawing System.Drawing.Drawing2D

public class TextBoxSelectionLength public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Form1 ca

Private Sub Button1_Click ( ByVal expeditor Ca System.Object, ByVal e Dac TextBox1.SelectionLength = 0 Apoi MessageBox.Show ( TextBox1.Text ) Else MessageBox.Show ( TextBox1.SelectedText )

System

Dac End End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout () " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 12 , 12 ) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 410 , 137 ) Me.TextBox1.TabIndex = 0 ' 'Bu tton1 " Me.Button1. Locaie = New System.Drawing.Point ( 150 , 173 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 131 , 23 ) Me.Button1.TabIndex = 1 Me.Button1. Text = "text selectat Display" Me.Button1.UseVisualStyleBackColor = True ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 12.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me . ClientSize = Nou

Boolean )

End Sub prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Button1 Ca System.Windows.Forms.Button End Class

Original

Imports Imports Imports Imports

System.Windows.Forms System.Drawing.Text System.Drawing System.Drawing.Drawing2D

public class TextBoxSelectionLength public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs If TextBox1.SelectionLength = 0 Then MessageBox.Show(TextBox1.Text) Else MessageBox.Show(TextBox1.SelectedText) End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(12, 12) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(410, 137) Me.TextBox1.TabIndex = 0 ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(150, 173) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(131, 23) Me.Button1.TabIndex = 1 Me.Button1.Text = "Display selected text" Me.Button1.UseVisualStyleBackColor = True ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(434, 208) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox1) Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button End Class

Copy selecie de text dintr-o casuta de text si pasta la altul

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class TextBoxCopyPaste public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox Ca apel

Bool

prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents TextBox2 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.TextBox1 = Sistem. Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Te xtBox1 " Me.TextBox1.Location = New System.Drawing.Point ( 128 , 72 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 112 , 20 ) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 128 , 120 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing . Dimensiune ( 112 , 23 ) Me.Button1.TabIndex = 1 Me.Button1.Text = "Copie textul selectat" " "La bel1 ' Me.Label1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 24.0 !, Sys Me.Label1.Location = New System.Drawing.Point ( 0 , 0 ) Me.Label1.Name = "Label1 " Me.Label1.Size = New System.Drawing.Size ( 344 , 48 ) Me.Label1.TabIndex = 2 Me.Label1.Text = "Copierea textului selectat" " "Te xtBox2 ' Me.TextBox2.Location = Sistem. Drawing.Point ( 128 , 168 ) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size ( 112 , 20 ) Me.TextBox2.TabIndex = 3 Me.TextBox2.Text = "" ' "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub Button1_Click ( ByVal expeditor TextBox1.Copy ()

System

TextBox2.Paste () End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class TextBoxCopyPaste public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If

End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents TextBox2 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(128, 72) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(112, 20) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(128, 120) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(112, 23) Me.Button1.TabIndex = 1 Me.Button1.Text = "Copy Selected Text" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.D Me.Label1.Location = New System.Drawing.Point(0, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(344, 48) Me.Label1.TabIndex = 2 Me.Label1.Text = "Copying Selected Text" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(128, 168) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(112, 20) Me.TextBox2.TabIndex = 3 Me.TextBox2.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(360, 253) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.Button1)

Me.Controls.Add(Me.TextBox1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs TextBox1.Copy() TextBox2.Paste() End Sub End Class

utii text 14.23.12.Multiline

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class TextBoxMultiline public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () apel

End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 5 , 5 ) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.ScrollBars = System.Windows.Forms. ScrollBars.Both Me.TextBox1.Size = New System.Drawing.Size ( 200 , 150 ) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 288 , 189 ) Me.Controls.Add ( Me.TextBox1 ) Me.Controls.Add ( Me.Label1 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca

Bool

End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class TextBoxMultiline public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox

Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(5, 5) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both Me.TextBox1.Size = New System.Drawing.Size(200, 150) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(288, 189) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region End Class

Disable TextBox Context Menu

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class DisableTextBoxContextMenu public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa

Public Class Form1 Private Sub Form1_Load ( expeditor ByVal Ca obiect, ByVal e ca System.EventArgs Dim text_box Ca New NoCtxMnuTextBox text_box.Location = New Punctul ( TextBox1.Left, TextBox1.Top + TextBox1.Height text_box . Dimensiuni = TextBox1.Size Me.Controls.Add ( text_box ) End Sub

End Class Public class NoCtxMnuTextBox Motenete System.Windows.Forms.TextBox Protejate nlocuiete Sub WndProc ( ByRef m Const WM_CONTEXTMENU Ca Integer = & H7B Dac Ca System.Windows.Forms.Message )

m.Msg <> WM_CONTEXTMENU Apoi MyBase.WndProc ( m ) Dac End End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 16 , 16 ) Me.TextBox1.Name = "TextBox1" Me. TextBox1.Size = New System.Drawing.Size ( 120 , 20 ) Me.TextBox1.TabIndex = 0 ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = sistem. Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 156 , 102 ) Me.Controls.Add ( Me.TextBox1 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( fals ) Me.PerformLayout () End Sub prieten WithEvents TextBox1 End Class Ca System.Windows.Forms.TextBox

Boolean )

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DisableTextBoxContextMenu public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dim text_box As New NoCtxMnuTextBox text_box.Location = New Point(TextBox1.Left, TextBox1.Top + TextBox1.Height + 4) text_box.Size = TextBox1.Size Me.Controls.Add(text_box) End Sub End Class Public Class NoCtxMnuTextBox Inherits System.Windows.Forms.TextBox Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Const WM_CONTEXTMENU As Integer = &H7B If m.Msg <> WM_CONTEXTMENU Then MyBase.WndProc(m) End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(16, 16) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(120, 20) Me.TextBox1.TabIndex = 0 ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(156, 102) Me.Controls.Add(Me.TextBox1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents TextBox1 As System.Windows.Forms.TextBox End Class

Textul 14.23.14.Save n caseta ntr-un fiier


Importurile Importurile System.IO System.Windows.Forms

public class SaveTextBoxToFile public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () apel

End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button () Me.TextBox1 = New System.Windows.Forms.TextBox () Me . SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 104 , 24 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Salvare n fiier " " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 20 , 80 ) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = Sistem. Drawing.Size ( 250 , 150 ) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Sistem. Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Button1, Me.Text Me.Name = "Form1" Me.Text = "SaveTextToFile" Me. ResumeLayout ( Fals ) End Sub # End Regiunea Ca obiect, ByVal e ca

Private Sub Button1_Click ( expeditor ByVal Dim FileDB Ca New SaveFileDialog () FileDB.Filter =

System.EventA

"Toate fiierele | * | *. fiiere Word * | doc |. fiiere text 3

FileDB.FilterIndex =

FileDB.InitialDirectory = "C: \ Temp" FileDB.AddExtension = True FileDB.DefaultExt = "txt" n cazul n care ( FileDB.ShowDialog () Dim FS Ca FileStream = DialogResult.OK ) Apoi

ncercai s FS = New FileStream ( FileDB.FileName, FileMode.Create ) Dim I Ca Integer

Pentru i = 0 Pentru a TextBox1.Text.Length - 1 FS.WriteByte ( Asc ( TextBox1.Text.Chars ( I ))) nainte Catch Console.WriteLine ( "fiier Eroare de scriere" ) End ncercai FS.Close () MsgBox ( "text salvat n" Else MsgBox ( "utilizator selectat Cancel" ) End If End Sub End Class & FileDB.FileName )

Original

Imports System.IO Imports System.Windows.Forms public class SaveTextBoxToFile public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(104, 24) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Save to File" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(20, 80) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(250, 150) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.TextBox1 Me.Name = "Form1" Me.Text = "SaveTextToFile" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handl Dim FileDB As New SaveFileDialog() FileDB.Filter = "All files | *.* | Word files | *.doc | Text files | *.txt" FileDB.FilterIndex = 3 FileDB.InitialDirectory = "C:\Temp" FileDB.AddExtension = True

FileDB.DefaultExt = "txt" If (FileDB.ShowDialog() = DialogResult.OK) Then Dim FS As FileStream Try FS = New FileStream(FileDB.FileName, FileMode.Create) Dim I As Integer For I = 0 To TextBox1.Text.Length - 1 FS.WriteByte(Asc(TextBox1.Text.Chars(I))) Next Catch Console.WriteLine("Error writing file") End Try FS.Close() MsgBox("Text saved to " & FileDB.FileName) Else MsgBox("User selected Cancel") End If End Sub End Class

Handles cazul clic pe un buton pentru a schimba culoarea de fund text.


Opiunea stricte cu privire la Importurile Importurile Importurile System.ComponentModel System.Windows.Forms System.Drawing

Public class myform Motenete formular private cutie Ca TextBox private WithEvents myButton

Ca

Button

Public Sub New () cutie = New TextBox () box.BackColor = System.Drawing.Color.Cyan box.Size = noua dimensiune ( 100 , 100 ) box.Location = nou punct ( 50 , 50 ) box.Text = "Hello " myButton = New Button () myButton.Location = punct nou ( 50 , myButton.Text = "Click Me" 100 )

AddHandler myButton.Click, AddressOf Me.Button_Click

Controls.Add ( cutie ) Controls.Add ( myButton ) End Sub Private Sub Button_Click ( expeditor ca obiect, e box.BackColor = System.Drawing.Color.Green End Sub <STAThreadAttribute () > _ Public Shared Sub Main ( args () Ca Application.Run ( New myform ()) End Sub End Class String ) ca EventArgs )

Original

Option Strict On Imports System.ComponentModel Imports System.Windows.Forms Imports System.Drawing Public Class MyForm Inherits Form Private box As TextBox Private WithEvents myButton As Button Public Sub New() box = New TextBox() box.BackColor = System.Drawing.Color.Cyan box.Size = New Size(100, 100) box.Location = New Point(50, 50) box.Text = "Hello" myButton = New Button() myButton.Location = New Point(50, 100) myButton.Text = "Click Me" AddHandler myButton.Click, AddressOf Me.Button_Click Controls.Add(box) Controls.Add(myButton) End Sub Private Sub Button_Click(sender As Object, e As EventArgs) box.BackColor = System.Drawing.Color.Green End Sub <STAThreadAttribute()> _ Public Shared Sub Main(args() As String) Application.Run(New MyForm()) End Sub End Class

Button, Meniu, ComboBox din bara de instrumente

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ToolBarButtonComboBox public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents ToolBar1 Ca System.Windows.Forms.ToolBar prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents ToolBarButton1 Ca System.Windows.Forms.ToolBarButton prieten WithEvents ToolBarButton2 Ca System.Windows.Forms.ToolBarButton prieten WithEvents ToolBarButton3 Ca System.Windows.Forms. ToolBarButton prieten WithEvents ContextMenu1 Ca System.Windows.Forms.ContextMenu prieten WithEvents MenuItem1 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem2 Ca System.Windows.Forms.MenuItem prieten WithEvents MenuItem3 Ca System.Windows.Forms.MenuItem prieten WithEvents ToolBarButton4 Ca sistem . Windows.Forms.ToolBarButton prieten WithEvents ToolBarButton5 Ca System.Windows.Forms.ToolBarButton prieten WithEvents ToolBarButton6 Ca System.Windows.Forms.ToolBarButton prieten WithEvents ComboBox1 Ca System.Windows.Forms.ComboBox <System.Diagnostics.DebuggerStepThrough () > Sub Private InitializeComponent () Me.ToolBar1 = New System.Windows.Forms.ToolBar Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.ToolBarButton1 = New System.Windows.Forms. ToolBarButton Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton Me.ContextMenu1 = New System.Windows.Forms.ContextMenu Me.MenuItem1 = New System.Windows.Forms.MenuItem Me . MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.ToolBarButton4 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton5 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton6 = New System.Windows.Forms.ToolBarButton Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.SuspendLayout () " "Pentru a olBar1 " Me.ToolBar1.Buttons.AddRange ( New System.Windows.Forms.ToolBarButton () { Me.To Me.ToolBar1.DropDownArrows = True Me.ToolBar1.Location = New System.Drawing.Point ( 0 , 0 ) Me . ToolBar1.Name = "ToolBar1" Me.ToolBar1.ShowToolTips = True Me.ToolBar1.Size = New System.Drawing.Size ( 368 , 42 ) Me.ToolBar1.TabIndex = 0 ' 'La bel1 ' Me.Label1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 24.0 !, Sys Me.Label1.Location = New System.Drawing. punctul ( 0 , 48 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 160 , 40 ) Me.Label1.TabIndex = 1 Me.Label1.Text = "Bare de instrumente" " " Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 72 , 136 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 152 , 20 ) Me.TextBox1. tabindex = 2 Me.TextBox1.Text = ""

" "Pentru a olBarButton1 ' Me.ToolBarButton1.Text = "Buton 1" " "Pentru a olBarButton2 ' Me.ToolBarButton2.Text = "Butonul 2" " "Pentru a olBarButton3 " Me.ToolBarButton3. style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton Me.ToolBarButton3.Text = "buton de comutare" " "Co ntextMenu1 " Me.ContextMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.M " "Eu nuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.Text = "Red" " "Me nuItem2 ' Me.MenuItem2.Index = 1 Me.MenuItem2.Text = "verde" " "Eu nuItem3 ' Me.MenuItem3.Index = 2 Me.MenuItem3.Text = "Blue" " "Pentru a olBarButton4 ' Me.ToolBarButton4.DropDownMenu = Me.ContextMenu1 Me.ToolBarButton4.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton Me.ToolBarButton4.Text = "Butonul 4" " "Pentru a olBarButton5 ' Me.ToolBarButton5.Style = System.Windows.Forms.ToolBarButtonStyle.Separator ' 'Pentru a olBarButton6 ' Me.ToolBarButton6.Style = System.Windows.Forms.ToolBarButtonStyle.Separator " "Co mboBox1 " Me.ComboBox1.Items.AddRange ( Object Nou () { "punctul 0" , "punctul 1" , "pun Me.ComboBox1.Location = New System.Drawing.Point ( 264 , 8 ) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size ( 88 , 21 ) Me.ComboBox1.TabIndex = 3 ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea System.Object, ByVal e ca

Private Sub ToolBar1_ButtonClick ( ByVal expeditor Ca TextBox1.Text = "Ai fcut clic" i e.Button.Text End Sub

Private Sub MenuItem1_Click ( ByVal expeditor Ca System.Object, ByVal e TextBox1.Text = "ai fcut clic pe elementul Red." End Sub Private Sub MenuItem2_Click ( ByVal expeditor Ca System.Object, ByVal e TextBox1.Text = "ai fcut clic pe elementul verde." End Sub Private Sub MenuItem3_Click ( ByVal expeditor Ca System.Object, ByVal e TextBox1.Text = "ai fcut clic pe elementul albastru." End Sub

ca

Syst

ca

Syst

ca

Syst

Private Sub ComboBox1_SelectedIndexChanged ( expeditor ByVal Ca System.Object, By TextBox1.Text = "Ai selectat elementul" & ComboBox1.SelectedIndex End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D

Imports System.Windows.Forms public class ToolBarButtonComboBox public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem Friend WithEvents ToolBarButton4 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton5 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton6 As System.Windows.Forms.ToolBarButton Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.ToolBar1 = New System.Windows.Forms.ToolBar Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton Me.ContextMenu1 = New System.Windows.Forms.ContextMenu

Me.MenuItem1 = New System.Windows.Forms.MenuItem Me.MenuItem2 = New System.Windows.Forms.MenuItem Me.MenuItem3 = New System.Windows.Forms.MenuItem Me.ToolBarButton4 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton5 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton6 = New System.Windows.Forms.ToolBarButton Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.SuspendLayout() ' 'ToolBar1 ' Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBa Me.ToolBar1.DropDownArrows = True Me.ToolBar1.Location = New System.Drawing.Point(0, 0) Me.ToolBar1.Name = "ToolBar1" Me.ToolBar1.ShowToolTips = True Me.ToolBar1.Size = New System.Drawing.Size(368, 42) Me.ToolBar1.TabIndex = 0 ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 24.0!, System.D Me.Label1.Location = New System.Drawing.Point(0, 48) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(160, 40) Me.Label1.TabIndex = 1 Me.Label1.Text = "Toolbars" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(72, 136) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(152, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "" ' 'ToolBarButton1 ' Me.ToolBarButton1.Text = "Button 1" ' 'ToolBarButton2 ' Me.ToolBarButton2.Text = "Button 2" ' 'ToolBarButton3 ' Me.ToolBarButton3.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton Me.ToolBarButton3.Text = "Toggle Button " ' 'ContextMenu1 ' Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuI ' 'MenuItem1 ' Me.MenuItem1.Index = 0 Me.MenuItem1.Text = "Red" ' 'MenuItem2 ' Me.MenuItem2.Index = 1

Me.MenuItem2.Text = "Green" ' 'MenuItem3 ' Me.MenuItem3.Index = 2 Me.MenuItem3.Text = "Blue" ' 'ToolBarButton4 ' Me.ToolBarButton4.DropDownMenu = Me.ContextMenu1 Me.ToolBarButton4.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton Me.ToolBarButton4.Text = "Button 4" ' 'ToolBarButton5 ' Me.ToolBarButton5.Style = System.Windows.Forms.ToolBarButtonStyle.Separator ' 'ToolBarButton6 ' Me.ToolBarButton6.Style = System.Windows.Forms.ToolBarButtonStyle.Separator ' 'ComboBox1 ' Me.ComboBox1.Items.AddRange(New Object() {"Item 0", "Item 1", "Item 2"}) Me.ComboBox1.Location = New System.Drawing.Point(264, 8) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(88, 21) Me.ComboBox1.TabIndex = 3 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(368, 273) Me.Controls.Add(Me.ComboBox1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.ToolBar1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Wi TextBox1.Text = "You clicked " & e.Button.Text End Sub

Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventAr TextBox1.Text = "You clicked the Red item." End Sub

Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventAr TextBox1.Text = "You clicked the Green item." End Sub

Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventAr TextBox1.Text = "You clicked the Blue item." End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As TextBox1.Text = "You selected item " & ComboBox1.SelectedIndex End Sub End Class

Add asculttor aciune a butoanelor de pe o bar de instrumente

Importurile

System.Windows.Forms

public class ToolBarMenu public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Ca apel

Bool

"Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

"NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents MainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents mnuEdit Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEditCut Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEditCopy Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEditPaste Ca System.Windows.Forms.MenuItem prieten WithEvents TxtEdit ca System.Windows.Forms. TextBox prieten WithEvents ContextMenu1 Ca System.Windows.Forms.ContextMenu prieten WithEvents MenuItem7 Ca System.Windows.Forms.MenuItem prieten WithEvents ImageList1 Ca System.Windows.Forms.ImageList prieten WithEvents ToolBarButton1 Ca System.Windows.Forms.ToolBarButton prieten WithEvents ToolBarButton2 Ca sistem . Windows.Forms.ToolBarButton prieten WithEvents ToolBarButton3 Ca System.Windows.Forms.ToolBarButton prieten WithEvents ToolBar1 Ca System.Windows.Forms.ToolBar prieten WithEvents cmnuCut Ca System.Windows.Forms.MenuItem prieten WithEvents cmnuCopy Ca System.Windows.Forms.MenuItem Prietenul WithEvents cmnuPaste Ca System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.components = New System.ComponentModel.Container () Me.MainMenu1 = New System.Windows.Forms.MainMenu ( ) Me.mnuEdit = New System.Windows.Forms.MenuItem () Me.mnuEditCut = New System.Windows.Forms.MenuItem () Me.mnuEditCopy = New System.Windows.Forms.MenuItem () Me.mnuEditPaste = Sistem. Windows.Forms.MenuItem () Me.txtEdit = New System.Windows.Forms.TextBox () Me.ContextMenu1 = New System.Windows.Forms.ContextMenu () Me.cmnuCut = New System.Windows.Forms.MenuItem () Me . cmnuCopy = New System.Windows.Forms.MenuItem () Me.cmnuPaste = New System.Windows.Forms.MenuItem () Me.MenuItem7 = New System.Windows.Forms.MenuItem () Me.ImageList1 = New System.Windows. Forms.ImageList ( Me.components ) Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton () Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton () Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton () Me.ToolBar1 = New System.Windows.Forms.ToolBar () Me.SuspendLayout () " "Ma inMenu1 " Me.MainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuE " " mil. uEdit ' Me.mnuEdit.Index = 0 Me.mnuEdit.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuEdi Me.mnuEdit.Text = "& Editare " " "milioane uEditCut ' Me.mnuEditCut.Index = 0 Me.mnuEditCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX Me.mnuEditCut.Text = "Cu & t" ' 'mil. uEditCopy ' Me.mnuEditCopy.Index = 1

Me . mnuEditCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC Me.mnuEditCopy.Text = "& Copy", " 'mil. uEditPaste ' Me.mnuEditPaste.Index = 2 Me.mnuEditPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV Me.mnuEditPaste.Text = "& Paste" " "TX tEdit ' Me.txtEdit.ContextMenu = Me.ContextMenu1 Me.txtEdit.Location = New System.Drawing.Point ( 0 , 24 ) Me.txtEdit.Multiline = True Me.txtEdit . Nume = "TxtEdit" Me.txtEdit.ScrollBars = System.Windows.Forms.ScrollBars.Both Me.txtEdit.Size = New System.Drawing.Size ( 248 , 176 ) Me.txtEdit.TabIndex = 0 Me.txtEdit.Text = "" " "Co ntextMenu1 " Me.ContextMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.c " "cm nuCut " Me.cmnuCut.Index = 0 Me.cmnuCut.Text = "Cut" " "cm nuCopy ' Me.cmnuCopy.Index = 1 Me.cmnuCopy.Text = "Copy" " "cm nuPaste ' Me.cmnuPaste.Index = 2 Me.cmnuPaste.Text = "Paste" " "Me nuItem7 ' Me.MenuItem7.Index = - 1 Me.MenuItem7.Text = "" " "Pentru a olBarButton1 ' Me.ToolBarButton1.ImageIndex = 0 ' 'Pentru a olBarButton2 ' Me.ToolBarButton2.ImageIndex = 1 ' ' Pentru a olBarButton3 ' Me.ToolBarButton3.ImageIndex = 2 ' 'Pentru a olBar1 " Me.ToolBar1.Buttons.AddRange ( New System.Windows.Forms.ToolBarButton () { Me.To Me.ToolBar1 . ButtonSize = New System.Drawing.Size ( 23 , 22 ) Me.ToolBar1.DropDownArrows = True

Me.ToolBar1.Name = "ToolBar1" Me.ToolBar1.ShowToolTips = True Me.ToolBar1.Size = New System.Drawing.Size ( 248 , 25 ) Me.ToolBar1.TabIndex = 1 ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 248 , 201 ) Me.Controls. AddRange ( New System.Windows.Forms.Control () { Me.ToolBar1, Me.tx Me.Menu = Me.MainMenu1 Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea System.Object, ByVal e ca

Private Sub ToolBar1_ButtonClick ( ByVal expeditor Ca Select Case ToolBar1.Buttons.IndexOf ( e.Button ) Case 0 mnuEditCut_Click ( expeditorul, e ) Cazul 1 mnuEditCopy_Click ( expeditor, e ) Cazul 2 mnuEditPaste_Click ( expeditorul, e ) End Select End Sub Private Sub mnuEditCut_Click ( expeditor ByVal txtEdit.Cut () End Sub Private Sub mnuEditCopy_Click ( expeditor ByVal txtEdit.Copy () End Sub Private Sub mnuEditPaste_Click ( expeditor ByVal txtEdit.Paste () End Sub End Class Ca

obiect, ByVal e

ca

System.Eve

Ca

obiect, ByVal e

ca

System.Ev

Ca

obiect, ByVal e

ca

System.E

Original

Imports System.Windows.Forms public class ToolBarMenu public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents mnuEdit As System.Windows.Forms.MenuItem Friend WithEvents mnuEditCut As System.Windows.Forms.MenuItem Friend WithEvents mnuEditCopy As System.Windows.Forms.MenuItem Friend WithEvents mnuEditPaste As System.Windows.Forms.MenuItem

Friend WithEvents txtEdit As System.Windows.Forms.TextBox Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu Friend WithEvents MenuItem7 As System.Windows.Forms.MenuItem Friend WithEvents ImageList1 As System.Windows.Forms.ImageList Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar Friend WithEvents cmnuCut As System.Windows.Forms.MenuItem Friend WithEvents cmnuCopy As System.Windows.Forms.MenuItem Friend WithEvents cmnuPaste As System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Me.MainMenu1 = New System.Windows.Forms.MainMenu() Me.mnuEdit = New System.Windows.Forms.MenuItem() Me.mnuEditCut = New System.Windows.Forms.MenuItem() Me.mnuEditCopy = New System.Windows.Forms.MenuItem() Me.mnuEditPaste = New System.Windows.Forms.MenuItem() Me.txtEdit = New System.Windows.Forms.TextBox() Me.ContextMenu1 = New System.Windows.Forms.ContextMenu() Me.cmnuCut = New System.Windows.Forms.MenuItem() Me.cmnuCopy = New System.Windows.Forms.MenuItem() Me.cmnuPaste = New System.Windows.Forms.MenuItem() Me.MenuItem7 = New System.Windows.Forms.MenuItem() Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components) Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton() Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton() Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton() Me.ToolBar1 = New System.Windows.Forms.ToolBar() Me.SuspendLayout() ' 'MainMenu1 ' Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEdit} ' 'mnuEdit ' Me.mnuEdit.Index = 0 Me.mnuEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEditCut Me.mnuEdit.Text = "&Edit" ' 'mnuEditCut ' Me.mnuEditCut.Index = 0 Me.mnuEditCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX Me.mnuEditCut.Text = "Cu&t" ' 'mnuEditCopy ' Me.mnuEditCopy.Index = 1 Me.mnuEditCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC Me.mnuEditCopy.Text = "&Copy" ' 'mnuEditPaste ' Me.mnuEditPaste.Index = 2 Me.mnuEditPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV Me.mnuEditPaste.Text = "&Paste" ' 'txtEdit '

Me.txtEdit.ContextMenu = Me.ContextMenu1 Me.txtEdit.Location = New System.Drawing.Point(0, 24) Me.txtEdit.Multiline = True Me.txtEdit.Name = "txtEdit" Me.txtEdit.ScrollBars = System.Windows.Forms.ScrollBars.Both Me.txtEdit.Size = New System.Drawing.Size(248, 176) Me.txtEdit.TabIndex = 0 Me.txtEdit.Text = "" ' 'ContextMenu1 ' Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.cmnuC ' 'cmnuCut ' Me.cmnuCut.Index = 0 Me.cmnuCut.Text = "Cut" ' 'cmnuCopy ' Me.cmnuCopy.Index = 1 Me.cmnuCopy.Text = "Copy" ' 'cmnuPaste ' Me.cmnuPaste.Index = 2 Me.cmnuPaste.Text = "Paste" ' 'MenuItem7 ' Me.MenuItem7.Index = -1 Me.MenuItem7.Text = "" ' 'ToolBarButton1 ' Me.ToolBarButton1.ImageIndex = 0 ' 'ToolBarButton2 ' Me.ToolBarButton2.ImageIndex = 1 ' 'ToolBarButton3 ' Me.ToolBarButton3.ImageIndex = 2 ' 'ToolBar1 ' Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBa Me.ToolBar1.ButtonSize = New System.Drawing.Size(23, 22) Me.ToolBar1.DropDownArrows = True Me.ToolBar1.Name = "ToolBar1" Me.ToolBar1.ShowToolTips = True Me.ToolBar1.Size = New System.Drawing.Size(248, 25) Me.ToolBar1.TabIndex = 1 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(248, 201) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ToolBar1, Me.txtEdit Me.Menu = Me.MainMenu1

Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Wi Select Case ToolBar1.Buttons.IndexOf(e.Button) Case 0 mnuEditCut_Click(sender, e) Case 1 mnuEditCopy_Click(sender, e) Case 2 mnuEditPaste_Click(sender, e) End Select End Sub

Private Sub mnuEditCut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Ha txtEdit.Cut() End Sub

Private Sub mnuEditCopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) H txtEdit.Copy() End Sub Private Sub mnuEditPaste_Click(ByVal sender As Object, ByVal e As System.EventArgs) txtEdit.Paste() End Sub End Class

Fereastra Formular 14.49.1.Create de mn


Opiunea stricte cu privire la Importurile Importurile System.Drawing System.Windows.Forms

Clasa publice Form1: Inherits Forma privat WithEvents cmdClickCtr Ca Button = New Button () Public Sub New () Me.cmdClickCtr.Location = Punctul noi ( 100 , Me.cmdClickCtr.Size = noua dimensiune ( 100 , Me.cmdClickCtr.Text = "Click Counter" Me.Controls.Add ( cmdClickCtr ) Me . Text = "Click Counter" End Sub Private Sub cmdClickCtr_Click ( ByVal expeditor ByVal e ca System.EventArgs ) _ Manere cmdClickCtr.Click CTR-ul static Ca Integer = 1 Ca System.Object, _ 75 ) 50 )

MsgBox ( "Butonul a fost apsat butonul" CTR + = 1 End Sub Public comun Sub Main () Dim FRM Ca New Form1 () frm.ShowDialog () End Sub End Class

& ctr &

" ori. " )

Original

Option Strict On Imports System.Drawing Imports System.Windows.Forms Public Class Form1 : Inherits Form Private WithEvents cmdClickCtr As Button = New Button() Public Sub New() Me.cmdClickCtr.Location = New Point(100, 75) Me.cmdClickCtr.Size = New Size(100, 50) Me.cmdClickCtr.Text = "Click Counter" Me.Controls.Add(cmdClickCtr) Me.Text = "Click Counter" End Sub Private Sub cmdClickCtr_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles cmdClickCtr.Click Static ctr As Integer = 1 MsgBox("Button was clicked " & ctr & " times.") ctr += 1 End Sub Public Shared Sub Main() Dim frm As New Form1() frm.ShowDialog() End Sub End Class

Controlul 14.49.2.Add la Formular dinamic

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class AddButtonToForm public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. Ca apel

Bool

prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 104 , 56 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Click Me" " " Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 96 , 168 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Fo RM1 " Me . AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.Add ( Me.TextBox1 ) Me.Controls.Add ( Me.Button1 ) Me . Nume = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Dim Regiunea WithEvents Button2 Ca Button

Private Sub Button1_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere Button1.Click Button2 = buton nou Button2.Location = nou punct ( 104 , 104 ) Button2.Size = dimensiune nou ( 75 , 23 ) Button2 . Text = "i pentru mine!" AddHandler Button2.Click, AddressOf Button2_Clicked Controls.Add ( Button2 ) End Sub Sub Private Button2_Clicked ( expeditor ByVal TextBox1.Text = "Nici o problem!" End Sub End Class Ca obiect, e ByVal Ca

System.Even

Formular 14.49.3.Set Icon

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class MyResourcesMainFormIcon public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e Me.Icon = noua icoana ( "1.ico" ) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices . DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form

ca

System.Ev

"Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.SuspendLayout () " "Fo RM1 '

Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub End Class

13.0 ! )

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class MyResourcesMainFormIcon public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H Me.Icon = New Icon("1.ico") End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SuspendLayout() ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 273) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub End Class

Form estompare

Importurile

System.Windows.Forms

public class FormFadeOut public comun Sub principal Application.Run ( New Form1 )

End Sub End clasa Public Class Form1 Private Sub ActClose_Click ( expeditor ByVal Dim contra Ca Integer Ca obiect, ByVal e ca

System.Event

Pentru contor = 90 Pentru a 10 Pasul - 5 Me.Opacity = counter / 100 Me.Refresh () Threading.Thread.Sleep ( 100 ) counter urmtoare Me.Close () End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.ActClose = New System.Windows.Forms.Button Me.SuspendLayout () " "Ac tClose ' Me.ActClose.Location = New System.Drawing.Point ( 104 , 112 ) Me.ActClose.Name = "ActClose" Me. ActClose.Size = New System.Drawing.Size ( 75 , 23 ) Me.ActClose.TabIndex = 0 Me.ActClose.Text = "Close" Me.ActClose.UseVisualStyleBackColor = True ' 'Fo RM1 ' Me.AutoScaleDimensions = Sistem. Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 292 , 266 ) Me.Controls.Add ( Me.ActClose ) Me. FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = false Me.Name = "Form1" Me.Text = "Fading Form" Me.ResumeLayout ( Fals )

Boolean )

End Sub prieten WithEvents ActClose End Class

Ca

System.Windows.Forms.Button

Original

Imports System.Windows.Forms public class FormFadeOut public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Private Sub ActClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Hand Dim counter As Integer For counter = 90 To 10 Step -5 Me.Opacity = counter / 100 Me.Refresh() Threading.Thread.Sleep(100) Next counter Me.Close() End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _

Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.ActClose = New System.Windows.Forms.Button Me.SuspendLayout() ' 'ActClose ' Me.ActClose.Location = New System.Drawing.Point(104, 112) Me.ActClose.Name = "ActClose" Me.ActClose.Size = New System.Drawing.Size(75, 23) Me.ActClose.TabIndex = 0 Me.ActClose.Text = "Close" Me.ActClose.UseVisualStyleBackColor = True ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.Add(Me.ActClose) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "Fading Form" Me.ResumeLayout(False) End Sub Friend WithEvents ActClose As System.Windows.Forms.Button End Class

Border form mai puin

Importurile public class

System.Windows.Forms ConvertMouseEventToFormDragEvent

public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Const HT_CAPTION Ca Integer = & H2 WM_NCLBUTTONDOWN Const Ca Integer = & HA1 Sub privat DragBar_MouseDown ( expeditor ByVal Ca obiect, e ByVal Dac ( e.Button = Windows.Forms.MouseButtons.Left ) Apoi DragBar.Capture = false Me.WndProc ( Message.Create ( Me.Handle, WM_NCLBUTTONDOWN, _ Ctype ( HT_CAPTION, IntPtr ) , IntPtr.Zero )) End If End Sub Private Sub ActClose_Click ( ByVal expeditor Me.Close () End Sub End Class Ca System.Object, ByVal e ca Ca

System.Win

Syste

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.ActClose = New System.Windows.Forms.Button Me.DragBar = New System.Windows.Forms.PictureBox Ctype ( Me.DragBar,

Boolean )

= System.Windows.Forms.DialogResult.Cancel Me.ActClose.Location = New System.Drawing.Point ( 208 , Me.ActClose.Name = "ActClose" Me.ActClose.Size = New System.Drawing.Size ( 75 , 23 ) Me.ActClose.TabIndex = 0 Me.ActClose.Text = "Close" Me.ActClose.UseVisualStyleBackColor = True '

80 )

"Dr. Agbar ' Me.DragBar.BackColor = System.Drawing.SystemColors.ActiveCaption Me.DragBar.Location = New System.Drawing.Point ( 8 , 8 ) Me.DragBar.Name = "DragBar" Me.DragBar.Size = New System.Drawing.Size ( 280 , 24 ) Me.DragBar.TabIndex = 1 Me.DragBar.TabStop = fals " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.ActClose Me.ClientSize = Nou = System.Windows.Forms.FormBorderStyle.None Me.Name = "Form1" Me.Text = "Form1" Ctype ( Me.DragBar, System.ComponentModel.ISupportInitialize ) . EndInit () Me.ResumeLayout ( Fals ) End Sub prieten WithEvents ActClose Ca System.Windows.Forms.Button prieten WithEvents DragBar Ca System.Windows.Forms.PictureBox End Class

Original

Imports System.Windows.Forms public class ConvertMouseEventToFormDragEvent public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Const HT_CAPTION As Integer = &H2 Const WM_NCLBUTTONDOWN As Integer = &HA1

Private Sub DragBar_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Form If (e.Button = Windows.Forms.MouseButtons.Left) Then DragBar.Capture = False

Me.WndProc(Message.Create(Me.Handle, WM_NCLBUTTONDOWN, _ CType(HT_CAPTION, IntPtr), IntPtr.Zero)) End If End Sub

Private Sub ActClose_Click(ByVal sender As System.Object, ByVal e As System.EventArg Me.Close() End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.ActClose = New System.Windows.Forms.Button Me.DragBar = New System.Windows.Forms.PictureBox CType(Me.DragBar, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'ActClose ' Me.ActClose.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.ActClose.Location = New System.Drawing.Point(208, 80) Me.ActClose.Name = "ActClose" Me.ActClose.Size = New System.Drawing.Size(75, 23) Me.ActClose.TabIndex = 0 Me.ActClose.Text = "Close" Me.ActClose.UseVisualStyleBackColor = True ' 'DragBar ' Me.DragBar.BackColor = System.Drawing.SystemColors.ActiveCaption Me.DragBar.Location = New System.Drawing.Point(8, 8) Me.DragBar.Name = "DragBar" Me.DragBar.Size = New System.Drawing.Size(280, 24) Me.DragBar.TabIndex = 1 Me.DragBar.TabStop = False ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.ActClose

Me.ClientSize = New System.Drawing.Size(292, 114) Me.Controls.Add(Me.DragBar) Me.Controls.Add(Me.ActClose) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None Me.Name = "Form1" Me.Text = "Form1" CType(Me.DragBar, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub Friend WithEvents ActClose As System.Windows.Forms.Button Friend WithEvents DragBar As System.Windows.Forms.PictureBox End Class

Owner form remiz


Importurile Importurile Importurile System.Windows.Forms System.Drawing System.Drawing.Drawing2D

public class PartialVisible public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Form1 Ca obiect, ByVal e ca

Private Sub Form1_Click ( expeditor ByVal Me.Close () End Sub

System.EventArg

Private Sub Form1_Paint ( expeditor ByVal Ca obiect, ByVal e ca System.Windows. e.Graphics.Clear ( Color.Fuchsia ) e.Graphics.FillRectangle ( Brushes.Gold, 0.0f , _ Me. ClientRectangle.Height / 3.0f , _ CSng ( Me.ClientRectangle.Width ) , _ Me.ClientRectangle.Height / 3.0f ) Dim largerFont = New Font ( Me.Font.Name, 20 ) e.Graphics.DrawString ( "Acest lucru este o form " , largerFont, Brushes.Black, 20 , ( Me.ClientRectangle.Height / 2 ) - ( largerFont.Height / 2 )) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca

Boolean )

dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.SuspendLayout () " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 292 , 266 ) = Me.FormBorderStyle System.Windows.Forms.FormBorderStyle.None Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Form1" Me.TransparencyKey = Sistem . Drawing.Color.Fuchsia Me.ResumeLayout ( Fals ) End Sub End Class

Dac

Original

Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D public class PartialVisible public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Close() End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.Pain e.Graphics.Clear(Color.Fuchsia) e.Graphics.FillRectangle(Brushes.Gold, 0.0F, _

Me.ClientRectangle.Height / 3.0F, _ CSng(Me.ClientRectangle.Width), _ Me.ClientRectangle.Height / 3.0F) Dim largerFont = New Font(Me.Font.Name, 20) e.Graphics.DrawString("This is a form", largerFont, Brushes.Black, _ 20, (Me.ClientRectangle.Height / 2) - (largerFont.Height / 2)) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SuspendLayout() ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 266) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Form1" Me.TransparencyKey = System.Drawing.Color.Fuchsia Me.ResumeLayout(False) End Sub End Class

Formular 14.49.7.Build ierarhic

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class InheritedForm: motenete BaseForm privat WithEvents BTN ca Button publice sub noi () Text = "forma mostenita" BTN = new Button () btn.Location = new Punct ( 25 , 150 ) btn.Size = new Dimensiune ( 125 , 25 ) btn.Text = "C & pierde pe motenit" Controls.Add ( BTN ) lbl.Text = end sub "Acum, din InheritedForm"

Publice Shadows comun Sub Main () Application.Run ( nou InheritedForm ()) end sub privat sub btn_Click ( expeditor ByVal Application.Exit () finali sub Ca obiect, e ByVal Ca EventArgs ) Manere

protejate nlocuiete Sub someMethod () MessageBox.Show ( "Acesta este someMethod nlocuit numit" "de la InheritedForm." ) sfritul sub clasa de final public class BaseForm: motenete System.Windows.Forms.Form privat WithEvents btnClose ca Button privat WithEvents btnApp ca Button protejate LBL ca etichet

+ _

public Sub New () btnClose = new Button () btnClose.Location = new Punct ( 25 , 100 ) btnClose.Size = new Dimensiune ( 100 , 25 ) btnClose.Text = "& Close" btnApp = new Button () btnApp.Location = new Punct ( 200 , 100 ) btnApp.Size = new Dimensiune ( 150 , 25 ) btnApp.Text = "Application & Base" LBL = new Label () lbl.Location = new Punct ( 25 , 25 ) lbl.Size = new Dimensiune ( 100 , 25 ) lbl.Text = "Aceasta eticheta de pe BaseForm" Controls.AddRange ( nou finali sub control () { LBL, btnClose, btnApp }) Ca obiect, e ByVal Ca EventArgs )

privat sub btnClose_Click ( expeditor ByVal Application.Exit () finali sub

Ma

privat sub btnApp_Click ( expeditor ByVal Ca obiect, e ByVal MessageBox.Show ( "Aceasta este aplicaia de baz." ) someMethod () finali sub

Ca

EventArgs )

Mane

protejate supracomandabile Sub someMethod () MessageBox.Show ( "Acest lucru este someMethod numit de BaseForm." ) sfritul sub clasa de final

Original

imports System imports System.Drawing imports System.Windows.Forms public class InheritedForm : inherits BaseForm private WithEvents btn as Button public sub New() Text = "Inherited Form" btn = new Button() btn.Location = new Point(25,150) btn.Size = new Size(125,25) btn.Text = "C&lose on Inherited" Controls.Add(btn) lbl.Text = "Now from InheritedForm" end sub Public Shadows Shared Sub Main() Application.Run(new InheritedForm()) end sub private sub btn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn.Click Application.Exit() end sub protected Overrides Sub SomeMethod() MessageBox.Show("This is the overridden SomeMethod called " + _ "from InheritedForm.") end sub end class public class BaseForm : inherits System.Windows.Forms.Form private WithEvents btnClose as Button private WithEvents btnApp as Button protected lbl as Label public Sub New() btnClose = new Button() btnClose.Location = new Point(25,100) btnClose.Size = new Size(100,25) btnClose.Text = "&Close" btnApp = new Button() btnApp.Location = new Point(200,100) btnApp.Size = new Size(150,25) btnApp.Text = "&Base Application" lbl = new Label() lbl.Location = new Point(25,25) lbl.Size = new Size(100,25) lbl.Text = "This label on BaseForm" Controls.AddRange(new Control(){lbl, btnClose, btnApp}) end sub

private sub btnClose_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCl

Application.Exit() end sub

private sub btnApp_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnApp. MessageBox.Show("This is the Base application.") SomeMethod() end sub protected Overridable Sub SomeMethod() MessageBox.Show("This is SomeMethod called from BaseForm.") end sub end class

Form Motenire

Importurile

System.Windows.Forms

public class FormInheritance public comun Sub principal Application.Run ( New Startup ) End Sub End clasa Public class pornire Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent ()

"Anuntul d orice iniializare dup InitializeComponent () End Sub

apel

"Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Button2 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button () Me.Button2 = New System.Windows.Forms.Button () Me . SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 48 , 48 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "BaseForm " " "Bu tton2 ' Me.Button2.Location = New System.Drawing.Point ( 152 , 48 ) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size ( 88 , 23 ) Me . Button2.TabIndex = 1 Me.Button2.Text = "InheritedForm" " "Sf. artup ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Button2, Me.Button1 }) Me.Name = "Startup" Me.Text = "Startup" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub Button1_Click ( ByVal expeditor dim frm1 ca nou BaseForm () frm1.Show () End Sub

System.E

Private Sub Button2_Click ( ByVal expeditor dim frm2 ca nou InheritedForm () frm2.Show () End Sub End Class Public class BaseForm Motenete System.Windows.Forms.Form # Region

Ca

System.Object, ByVal e

ca

System.E

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. protejate WithEvents lblHeading Ca System.Windows.Forms.Label protejat WithEvents BTN Ca System.Windows.Forms.Button protejat WithEvents lblOutput Ca System.Windows.Forms.Label private WithEvents Label3 Ca System.Windows.Forms.Label private WithEvents Label2 Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > privat Sub InitializeComponent () Me.lblHeading = New System.Windows.Forms.Label () Me.btn = New System.Windows.Forms.Button () Me.lblOutput = New System.Windows.Forms.Label () Me.Label3 = New System.Windows.Forms.Label () Me.Label2 = New System.Windows.Forms.Label () Me.SuspendLayout () " "lb lHeading ' Me.lblHeading.Font = New System.Drawing.Font ( "Sans Microsoft serif " , 15.75 !, Syste Me.lblHeading.Location = New System.Drawing.Point ( 24 , 16 ) Me.lblHeading. name = "lblHeading" Me.lblHeading.Size = New System.Drawing.Size ( 248 , 23 ) Me.lblHeading.TabIndex = 0 Me.lblHeading.Text = "Baza Form" Me.lblHeading.TextAlign = System.Drawing.ContentAlignment . MiddleCenter "

"bt n ' Me.btn.Location = New System.Drawing.Point ( 96 , 72 ) Me.btn.Name = "btn" Me.btn.TabIndex = 1 Me.btn.Text = "Timpul" " "lb lOutput ' Me.lblOutput.Location = New System.Drawing.Point ( 64 , 128 ) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size ( 136 , 23 ) Me.lblOutput tabindex =. 2 Me.lblOutput.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'La bel3 ' Me.Label3.Location = New System.Drawing.Point ( 80 , 200 ) Me.Label3.Name = "Label3" Me. Label3.TabIndex = 3 Me.Label3.Text = "Baza Form" Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'La bel2 ' Me.Label2.Location = New System.Drawing.Point ( 40 , 232 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 216 , 23 ) Me.Label2.TabIndex = 4 Me.Label2.Text = "Creat n Visual Studio. NET" Me.Label2 . TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Ba seForm ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Label2, Me.Label3, Me.lb Me.Name = "BaseForm" Me.Text = "Formular de motenire Visual" Me . ResumeLayout ( Fals ) End Sub # End Regiunea ca

Private Sub btn_Click ( ByVal expeditor Ca System.Object, ByVal e lblOutput.Text = "Timpul este:" + DateTime.Now.ToString ( "T" ) End Sub End Class

System.Event

Public class InheritedForm Motenete BaseForm # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New ()

"Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () btn.Text = "Data" lblHeading.Text = "forma mostenita" End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . SuspendLayout () " "lb lHeading ' Me.lblHeading.BackColor = System.Drawing.Color.Yellow Me.lblHeading.Visible = True ' "bt n ' Me.btn.BackColor = System.Drawing.Color.Yellow Me.btn . Visible = True ' 'lb lOutput ' Me.lblOutput.BackColor = System.Drawing.Color.Yellow Me.lblOutput.Visible = True ' 'n heritedForm ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me . BackColor = System.Drawing.Color.Yellow Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.lblOutput, Me.btn, Me.lb Me.Name = "InheritedForm" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

Private Sub btn_Click ( ByVal expeditor Ca System.Object, ByVal e ca lblOutput.Text = "Astazi este:" + DateTime.Now.ToString ( "D" ) End Sub

System.Event

End Class

Original

Imports System.Windows.Forms public class FormInheritance public Shared Sub Main Application.Run(New Startup) End Sub End class Public Class Startup Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If

MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() Me.Button2 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(48, 48) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "BaseForm" ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(152, 48) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(88, 23) Me.Button2.TabIndex = 1 Me.Button2.Text = "InheritedForm" ' 'Startup ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1}) Me.Name = "Startup" Me.Text = "Startup" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) dim frm1 as new BaseForm() frm1.Show() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) dim frm2 as new InheritedForm() frm2.Show() End Sub End Class Public Class BaseForm Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code "

Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Protected WithEvents lblHeading As System.Windows.Forms.Label Protected WithEvents btn As System.Windows.Forms.Button Protected WithEvents lblOutput As System.Windows.Forms.Label Private WithEvents Label3 As System.Windows.Forms.Label Private WithEvents Label2 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.lblHeading = New System.Windows.Forms.Label() Me.btn = New System.Windows.Forms.Button() Me.lblOutput = New System.Windows.Forms.Label() Me.Label3 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'lblHeading ' Me.lblHeading.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, System.Draw Me.lblHeading.Location = New System.Drawing.Point(24, 16) Me.lblHeading.Name = "lblHeading" Me.lblHeading.Size = New System.Drawing.Size(248, 23) Me.lblHeading.TabIndex = 0 Me.lblHeading.Text = "Base Form" Me.lblHeading.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'btn ' Me.btn.Location = New System.Drawing.Point(96, 72) Me.btn.Name = "btn" Me.btn.TabIndex = 1 Me.btn.Text = "Time" ' 'lblOutput ' Me.lblOutput.Location = New System.Drawing.Point(64, 128) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size(136, 23)

Me.lblOutput.TabIndex = 2 Me.lblOutput.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Label3 ' Me.Label3.Location = New System.Drawing.Point(80, 200) Me.Label3.Name = "Label3" Me.Label3.TabIndex = 3 Me.Label3.Text = "Base Form" Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(40, 232) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(216, 23) Me.Label2.TabIndex = 4 Me.Label2.Text = "Created in Visual Studio .NET" Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'BaseForm ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label2, Me.Label3, Me.lblOut Me.Name = "BaseForm" Me.Text = "Visual Form Inheritance" Me.ResumeLayout(False) End Sub #End Region

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand lblOutput.Text = "The time is: " + DateTime.Now.ToString("T") End Sub End Class

Public Class InheritedForm Inherits BaseForm #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call btn.Text = "Date" lblHeading.Text = "Inherited Form" End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then

If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.SuspendLayout() ' 'lblHeading ' Me.lblHeading.BackColor = System.Drawing.Color.Yellow Me.lblHeading.Visible = True ' 'btn ' Me.btn.BackColor = System.Drawing.Color.Yellow Me.btn.Visible = True ' 'lblOutput ' Me.lblOutput.BackColor = System.Drawing.Color.Yellow Me.lblOutput.Visible = True ' 'InheritedForm ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.Yellow Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblOutput, Me.btn, Me.lblHea Me.Name = "InheritedForm" Me.ResumeLayout(False) End Sub #End Region

Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Hand lblOutput.Text = "Today is: " + DateTime.Now.ToString("D") End Sub End Class

Form: spectacol, ascunde i de a obine date de la

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class FormShowHide public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. Ca apel

Bool

prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Button2 Ca System.Windows.Forms.Button prieten WithEvents button3 Ca System.Windows.Forms.Button prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = Sistem. Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Button3 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Bu tton1 " Me.Button1.Location = New System.Drawing.Point ( 80 , 40 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 120 , 23 ) Me.Button1.TabIndex = 0 Me.Button1.Text = "Arat" " "Bu tton2 ' Me.Button2.Location = New System.Drawing.Point ( 80 , 96 ) Me.Button2.Name = "Button2" Me.Button2.Size = Sistem. Drawing.Size ( 120 , 23 ) Me.Button2.TabIndex = 1 Me.Button2.Text = "Ascunde" " "Bu tton3 ' Me.Button3.Location = New System.Drawing.Point ( 80 , 152 ) Me.Button3. name = "button3" Me.Button3.Size = New System.Drawing.Size ( 120 , 23 ) Me.Button3.TabIndex = 2 Me.Button3.Text = "Get textul" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 80 , 208 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 120 , 20 ) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Dim frmTwo Ca New form2 Private Sub Button1_Click ( ByVal expeditor frmTwo.Show ()

Ca

System.Object, ByVal e

ca

System

End Sub Private Sub Button2_Click ( ByVal expeditor frmTwo.Hide () End Sub Private Sub Button3_Click ( ByVal expeditor TextBox1.Text = frmTwo.TextBox1.Text End Sub End Class public class form2 Motenete System.Windows.Forms.Form # Region Ca System.Object, ByVal e ca

System

Ca

System.Object, ByVal e

ca

System

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics . DebuggerStepThrough () > Private Sub InitializeComponent () Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 96 , 64 ) Me . TextBox1.Name = "TextBox1" Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "Bun venit la form2" " "Fo RM2 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.Add ( Me.TextBox1 ) Me.Name = "form2" Me.Text = "form2" Me.ResumeLayout ( Fals ) Ca apel

Bool

End Sub # End Regiunea

End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class FormShowHide public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Button3 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(80, 40) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(120, 23) Me.Button1.TabIndex = 0 Me.Button1.Text = "Show" ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(80, 96) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(120, 23) Me.Button2.TabIndex = 1 Me.Button2.Text = "Hide" ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(80, 152) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(120, 23) Me.Button3.TabIndex = 2 Me.Button3.Text = "Get text" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(80, 208) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(120, 20) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub

#End Region Dim frmTwo As New Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs frmTwo.Show() End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs frmTwo.Hide() End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs TextBox1.Text = frmTwo.TextBox1.Text End Sub End Class Public Class Form2 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() '

'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(96, 64) Me.TextBox1.Name = "TextBox1" Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "Welcome to Form2" ' 'Form2 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.TextBox1) Me.Name = "Form2" Me.Text = "Form2" Me.ResumeLayout(False) End Sub #End Region End Class

Message Filtru

Importurile Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms System.Math

public class MessageFilter public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa

public class Form1 public class NoLeftDownMessageFilter Implementeaz IMessageFilter Public Funcia PreFilterMessage ( ByRef m Ca WM_LBUTTONDOWN Const Ca lung = & H201 retur ( m.Msg = WM_LBUTTONDOWN ) End Function End Class System.Windows.Forms.Message )

Private Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e Dim no_left_down_message_filter Ca New NoLeftDownMessageFilter Application.AddMessageFilter ( no_left_down_message_filter ) End Sub Private Sub Form1_Click ( expeditor ByVal Ca obiect, ByVal e ca Application.UseWaitCursor = Nu Application.UseWaitCursor End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial public class Form1 motenete System.Windows.Forms.Form

ca

System.Ev

System.EventArg

"Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.SuspendLayout () " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Name = "Form1" Me.Text = "UseMessageFilter" Me.ResumeLayout ( Fals ) End Sub End Class

Original

Imports Imports Imports Imports

System.Drawing System.Drawing.Drawing2D System.Windows.Forms System.Math

public class MessageFilter public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Public Class NoLeftDownMessageFilter Implements IMessageFilter

Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) As Boo Const WM_LBUTTONDOWN As Long = &H201 Return (m.Msg = WM_LBUTTONDOWN) End Function End Class

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H Dim no_left_down_message_filter As New NoLeftDownMessageFilter Application.AddMessageFilter(no_left_down_message_filter) End Sub

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Application.UseWaitCursor = Not Application.UseWaitCursor End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If

MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SuspendLayout() ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 273) Me.Name = "Form1" Me.Text = "UseMessageFilter" Me.ResumeLayout(False) End Sub End Class

Show formular de mesaj

Importurile

System.Windows.Forms

public class OverrideWndProc public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa

Publice clasa Form1 protejate nlocuiete Sub WndProc ( ByRef m Ca System.Windows.Forms.Message ) Console.WriteLine ( m.ToString ) MyBase.WndProc ( m ) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.SuspendLayout () " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Name = "Form1" Me.Text = "ShowMessages" Me.ResumeLayout ( Fals ) End Sub End Class

Boolean )

Original

Imports System.Windows.Forms public class OverrideWndProc public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Console.WriteLine(m.ToString) MyBase.WndProc(m) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SuspendLayout() ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

Me.ClientSize = New System.Drawing.Size(292, 273) Me.Name = "Form1" Me.Text = "ShowMessages" Me.ResumeLayout(False) End Sub End Class

Form Evenimente Ilustraie

Importurile Importurile

System.Diagnostics System.Windows.Forms

public class FormEvents public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () Console.WriteLine ( "eveniment nou concediat" ) End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Console.WriteLine ( "Metoda Eliminarea executat" ) n cazul n care dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac Ca apel

Bool

MyBase.Dispose ( eliminare End Sub prieten WithEvents btnLoop Ca prieten WithEvents btnRemember prieten WithEvents Button1 Ca prieten WithEvents Button2 Ca prieten WithEvents button3 Ca

) System.Windows.Forms.Button Ca System.Windows.Forms.Button System.Windows.Forms.Button sistem. Windows.Forms.Button System.Windows.Forms.Button

"Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . btnLoop = New System.Windows.Forms.Button () Me.btnRemember = New System.Windows.Forms.Button () Me.Button1 = New System.Windows.Forms.Button () Me.Button2 = New System.Windows. Forms.Button () Me.Button3 = New System.Windows.Forms.Button () Me.SuspendLayout () " "bt nLoop ' Me.btnLoop.Location = New System.Drawing.Point ( 24 , 56 ) Me.btnLoop. name = "btnLoop" Me.btnLoop.TabIndex = 0 Me.btnLoop.Text = "bucl" " "bt nReinei ' Me.btnRemember.Location = New System.Drawing.Point ( 136 , 56 ) Me.btnRemember.Name = " btnRemember " Me.btnRemember.Size = New System.Drawing.Size ( 112 , 23 ) Me.btnRemember.TabIndex = 1 Me.btnRemember.Text = "Amintii-Position" " "Bu tton1 ' Me.Button1.Location = Sistem. Drawing.Point ( 24 , 16 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 2 Me.Button1.Text = "Button1" " "Bu tton2 ' Me.Button2.Location = New System.Drawing.Point ( 128 , 16 ) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 3 Me.Button2.Text = "Button2" ' 'Bu tton3 ' Me.Button3.Location = New System.Drawing.Point ( 224 , 16 ) Me.Button3.Name = "button3" Me.Button3.Size = New System.Drawing.Size ( 72 , 24 ) Me.Button3.TabIndex = 4 Me.Button3.Text = "button3" " "Fo RM1 "

Me . AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 320 , 134 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Button3, Me.Butt Me.Name = "Form1" Me.Text = "Eveniment-O-Rama" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Dim formsize Ca Dim formlocation System.Drawing.Size Ca System.Drawing.Point ca

Private Sub Form1_Load ( expeditor ByVal Ca obiect, ByVal e Console.WriteLine ( "Load Eveniment concediat" ) formsize = Me.Size formlocation = Me.Location End Sub

System.EventArgs

Private Sub Form1_Activated ( expeditor ByVal Ca obiect, e ByVal Console.WriteLine ( "Evenimentul activat concediat" ) End Sub Sub Private Form1_Closed ( expeditor ByVal Ca obiect, ByVal e Console.WriteLine ( "eveniment nchis concediat" ) End Sub ca

Ca

System.Even

System.EventAr

Sub Private Form1_Closing ( expeditor ByVal Ca obiect, e ByVal Ca System.Compon Console.WriteLine ( "Evenimentul de nchidere concediat" ) Dim rspuns Ca MsgBoxResult answer = MsgBox ( "Nu dorii s nchidei aceast fereastr?" , MsgBoxStyle.YesN Dac answer = MsgBoxResult.No Apoi e.Cancel = True End If End Sub Private Sub Form1_Click ( expeditor ByVal Ca obiect, ByVal e Console.WriteLine ( "Apsai Eveniment concediat" ) End Sub ca

System.EventArg

Private Sub Form1_MouseMove ( expeditor ByVal Ca obiect, ByVal e Console.WriteLine ( "MouseMove Eveniment concediat" ) End Sub

ca

System.Wind

Sub privat Form1_Resize ( expeditor ByVal Ca obiect, e ByVal Ca System.EventArg Console.WriteLine ( "Evenimentul Resize concediat" & Me.Size.Width.ToString ()) End Sub Sub Private Form1_Deactivate ( expeditor ByVal Ca obiect, e ByVal Console.WriteLine ( "Dezactivarea Eveniment concediat" ) End Sub Private Sub Form1_Paint ( expeditor ByVal Ca obiect, ByVal e Console.WriteLine ( "Evenimentul Paint concediat" ) End Sub Private Sub Form1_Leave ( expeditor ByVal Ca obiect, ByVal e Console.WriteLine ( "Las Evenimentul concediat" ) End Sub ca Ca

System.Eve

System.Windows.

ca

System.EventArg

Sub privat Form1_Enter ( expeditor ByVal Ca obiect, e ByVal Console.WriteLine ( "Enter Eveniment concediat" ) End Sub

Ca

System.EventArgs

Sub privat btnLoop_Enter ( expeditor ByVal Ca obiect, e ByVal Ca Console.WriteLine ( "btnLoop Introducei Eveniment concediat" ) "bt nLoop_Leave ( expeditorul, e ) End Sub Private Sub btnLoop_Leave ( expeditor ByVal Ca obiect, ByVal e ca Console.WriteLine ( "btnLoop caz de un concediu concediat" ) "bt nLoop_Enter ( expeditorul, e ) End Sub Private Sub btnRemember_Click ( expeditor ByVal Ca obiect, ByVal e Me.Size = formsize Me.Location = formlocation End Sub Private Sub Button1_Click ( expeditor ByVal Ca obiect, ByVal e Manere Button1.Click, Button2.Click, Button3.Click MsgBox ( sender.Text & "a fost fcut clic!" ) End Sub End Class ca

System.EventAr

System.EventA

ca

System.Ev

System.EventA

Original

Imports System.Diagnostics Imports System.Windows.Forms public class FormEvents public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call Console.WriteLine("New Event Fired") End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) Console.WriteLine("Dispose Method Executed") If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents btnLoop As System.Windows.Forms.Button Friend WithEvents btnRemember As System.Windows.Forms.Button Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.btnLoop = New System.Windows.Forms.Button() Me.btnRemember = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button() Me.Button2 = New System.Windows.Forms.Button() Me.Button3 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'btnLoop ' Me.btnLoop.Location = New System.Drawing.Point(24, 56) Me.btnLoop.Name = "btnLoop" Me.btnLoop.TabIndex = 0 Me.btnLoop.Text = "Loop" ' 'btnRemember ' Me.btnRemember.Location = New System.Drawing.Point(136, 56) Me.btnRemember.Name = "btnRemember" Me.btnRemember.Size = New System.Drawing.Size(112, 23) Me.btnRemember.TabIndex = 1 Me.btnRemember.Text = "Remember Position" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(24, 16) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 2 Me.Button1.Text = "Button1" '

'Button2 ' Me.Button2.Location = New System.Drawing.Point(128, 16) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 3 Me.Button2.Text = "Button2" ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(224, 16) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(72, 24) Me.Button3.TabIndex = 4 Me.Button3.Text = "Button3" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(320, 134) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button3, Me.Button2, Me.Name = "Form1" Me.Text = "Event-O-Rama" Me.ResumeLayout(False) End Sub #End Region Dim formsize As System.Drawing.Size Dim formlocation As System.Drawing.Point Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Console.WriteLine("Load Event Fired") formsize = Me.Size formlocation = Me.Location End Sub

Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Han Console.WriteLine("Activated Event Fired") End Sub

Private Sub Form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handle Console.WriteLine("Closed Event Fired") End Sub

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.C Console.WriteLine("Closing Event Fired") Dim answer As MsgBoxResult answer = MsgBox("Do you want to close this window?", MsgBoxStyle.YesNo, "Demonst If answer = MsgBoxResult.No Then e.Cancel = True End If End Sub

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Console.WriteLine("Click Event Fired") End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms. Console.WriteLine("MouseMove Event Fired") End Sub

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handle Console.WriteLine("Resize Event Fired " & Me.Size.Width.ToString()) End Sub

Private Sub Form1_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Ha Console.WriteLine("Deactivate Event Fired") End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.Pain Console.WriteLine("Paint Event Fired") End Sub

Private Sub Form1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Console.WriteLine("Leave Event Fired") End Sub

Private Sub Form1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Console.WriteLine("Enter Event Fired") End Sub

Private Sub btnLoop_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handl Console.WriteLine("btnLoop Enter Event Fired") 'btnLoop_Leave(sender, e) End Sub

Private Sub btnLoop_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handl Console.WriteLine("btnLoop Leave Event Fired") 'btnLoop_Enter(sender, e) End Sub Private Sub btnRemember_Click(ByVal sender As Object, ByVal e As System.EventArgs) H Me.Size = formsize Me.Location = formlocation End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Button1.Click, Button2.Click, Button3.Click MsgBox(sender.Text & " was clicked!") End Sub End Class

Form Resize: raport fix

"Vi SUAL de baz 2005 Programator 's ", cu Rod Stephens ( Autor ) "# "# "# "# Publisher: Wrox ( octombrie Limba: englez ISBN- 10 : 0764571982 ISBN- 13 : 978 - 0764571985 21 ,

de referin 2005 )

Importurile Importurile

System.Runtime.InteropServices System.Windows.Forms

public class FixedRatio public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Publice Structura

Ca System.Windows.Forms.Message ) WM_SIZING Const Ca lung = & H214 WMSZ_LEFT Const Ca Integer = 1 Const WMSZ_RIGHT Ca Integer = 2 WMSZ_TOP constructii Ca Integer = 3 WMSZ_TOPLEFT Const Ca Integer = 4 WMSZ_TOPRIGHT Const Ca Integer = 5 Const WMSZ_BOTTOM Ca Integer = 6 WMSZ_BOTTOMLEFT Const Ca Integer = 7 WMSZ_BOTTOMRIGHT Const Ca Integer = 8 fixed_aspect_ratio static cum dubl = 0 Dim new_aspect_ratio cum dubl Dac m.Msg = WM_SIZING i m.HWnd.Equals ( Me.Handle ) "T urna mesajul e lParam ntr-un rect. Dim r Ca Rect r = DirectCast ( _

Apoi,

Marshal.PtrToStructure ( m.LParam, gettype ( rect )) , _ rect ), "G et dimensiunile actuale. Dim wid cum dubl = r.right - r.left Dim HGT cum dubl = r.bottom - r.top "G et nou . raportul de aspect new_aspect_ratio = hgt / wid 'T . el prima dat, salvai formularul e raportul de aspect Daca fixed_aspect_ratio = 0 Apoi fixed_aspect_ratio = new_aspect_ratio End Dac "S ee dac raportul de aspect se schimb. Dac fixed_aspect_ratio <> new_aspect_ratio Apoi, "T o s decid ce dimensiune trebuie s pstrm, e ee care frontiera ce utilizatorul este glisarea. Dac m.WParam.ToInt32 = WMSZ_TOPLEFT Sau _ m.WParam. ToInt32 = WMSZ_TOPRIGHT Sau _ m.WParam.ToInt32 = WMSZ_BOTTOMLEFT Sau _ m.WParam.ToInt32 = WMSZ_BOTTOMRIGHT _ Apoi, "T a utilizatorului este glisarea un col. " P rezerv dimensiune mai mare. Dac new_aspect_ratio> fixed_aspect_ratio Apoi, "am t e prea nalt i subire. F-l mai larg. wid = hgt / fixed_aspect_ratio Altele "Am t e prea scurt i larg. Face mai inalt. hgt = wid * fixed_aspect_ratio End Dac elseif m.WParam.ToInt32 = WMSZ_LEFT Sau _ m.WParam.ToInt32 = WMSZ_RIGHT _ Apoi, "T a utilizatorului este glisarea o parte. " P rezerv limea. HGT = wid * fixed_aspect_ratio elseif m.WParam.ToInt32 = WMSZ_TOP Sau _ m.WParam.ToInt32 = WMSZ_BOTTOM _ Apoi, "T a utilizatorului este glisarea n partea de sus sau de jos. " P rezerv nlime. WID = hgt / fixed_aspect_ratio End If 'F igure afla dac a reseta partea de sus / de jos ", a a stnga / dreapta. " S ee dac utilizatorul este glisarea marginea de sus. Dac m.WParam.ToInt32 = WMSZ_TOP Sau _ m.WParam.ToInt32 = WMSZ_TOPLEFT Sau _ m.WParam.ToInt32 = WMSZ_TOPRIGHT _ Apoi, "R ESET partea de sus. r.top = R . de jos - CInt ( HGT ) Else "R ESET partea de jos. r.bottom = r.top + CInt ( HGT ) End If 'S ee dac utilizatorul este glisarea marginea din stnga. Dac m.WParam.ToInt32 = WMSZ_LEFT sau _ m.WParam.ToInt32 = WMSZ_TOPLEFT Sau _ m.WParam.ToInt32 = WMSZ_BOTTOMLEFT _ Apoi, "R ESET stnga.

r.left = r.right - CInt ( wid ) Else "R . ESET dreptul r.right = r.left + CInt ( wid ) Dac End "U pdate obiect Mesajul e domeniul lParam. Marshal.StructureToPtr ( R, m.LParam, Adevrat ) End Dac End Dac MyBase.WndProc ( m ) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.SuspendLayout () " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Name = "Form1" Me.Text = "FixedAspectRatio" Me.ResumeLayout ( Fals ) End Sub End Class

Boolean )

Original

'Visual Basic 2005 Programmer's Reference 'by Rod Stephens (Author) '# '# '# '# Publisher: Wrox (October 21, 2005) Language: English ISBN-10: 0764571982 ISBN-13: 978-0764571985

Imports System.Runtime.InteropServices Imports System.Windows.Forms public class FixedRatio public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Public Structure Rect Public left As Integer Public top As Integer Public right As Integer Public bottom As Integer End Structure Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Const WM_SIZING As Long = &H214 Const WMSZ_LEFT As Integer = 1 Const WMSZ_RIGHT As Integer = 2 Const WMSZ_TOP As Integer = 3 Const WMSZ_TOPLEFT As Integer = 4 Const WMSZ_TOPRIGHT As Integer = 5 Const WMSZ_BOTTOM As Integer = 6 Const WMSZ_BOTTOMLEFT As Integer = 7 Const WMSZ_BOTTOMRIGHT As Integer = 8 Static fixed_aspect_ratio As Double = 0 Dim new_aspect_ratio As Double If m.Msg = WM_SIZING And m.HWnd.Equals(Me.Handle) Then ' Turn the messages lParam into a Rect. Dim r As Rect r = DirectCast( _

Marshal.PtrToStructure(m.LParam, GetType(Rect)), _ Rect) ' Get the current dimensions. Dim wid As Double = r.right - r.left Dim hgt As Double = r.bottom - r.top ' Get the new aspect ratio. new_aspect_ratio = hgt / wid ' The first time, save the forms aspect ratio. If fixed_aspect_ratio = 0 Then fixed_aspect_ratio = new_aspect_ratio End If ' See if the aspect ratio is changing. If fixed_aspect_ratio <> new_aspect_ratio Then ' To decide which dimension we should preserve, ' see what border the user is dragging. If m.WParam.ToInt32 = WMSZ_TOPLEFT Or _ m.WParam.ToInt32 = WMSZ_TOPRIGHT Or _ m.WParam.ToInt32 = WMSZ_BOTTOMLEFT Or _ m.WParam.ToInt32 = WMSZ_BOTTOMRIGHT _ Then ' The user is dragging a corner. ' Preserve the bigger dimension. If new_aspect_ratio > fixed_aspect_ratio Then ' Its too tall and thin. Make it wider. wid = hgt / fixed_aspect_ratio Else ' Its too short and wide. Make it taller. hgt = wid * fixed_aspect_ratio End If ElseIf m.WParam.ToInt32 = WMSZ_LEFT Or _ m.WParam.ToInt32 = WMSZ_RIGHT _ Then ' The user is dragging a side. ' Preserve the width. hgt = wid * fixed_aspect_ratio ElseIf m.WParam.ToInt32 = WMSZ_TOP Or _ m.WParam.ToInt32 = WMSZ_BOTTOM _ Then ' The user is dragging the top or bottom. ' Preserve the height. wid = hgt / fixed_aspect_ratio End If ' Figure out whether to reset the top/bottom ' and left/right. ' See if the user is dragging the top edge. If m.WParam.ToInt32 = WMSZ_TOP Or _ m.WParam.ToInt32 = WMSZ_TOPLEFT Or _ m.WParam.ToInt32 = WMSZ_TOPRIGHT _ Then ' Reset the top. r.top = r.bottom - CInt(hgt) Else ' Reset the bottom. r.bottom = r.top + CInt(hgt) End If ' See if the user is dragging the left edge. If m.WParam.ToInt32 = WMSZ_LEFT Or _ m.WParam.ToInt32 = WMSZ_TOPLEFT Or _ m.WParam.ToInt32 = WMSZ_BOTTOMLEFT _ Then ' Reset the left.

r.left = r.right - CInt(wid) Else ' Reset the right. r.right = r.left + CInt(wid) End If ' Update the Message objects LParam field. Marshal.StructureToPtr(r, m.LParam, True) End If End If MyBase.WndProc(m) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SuspendLayout() ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 273) Me.Name = "Form1" Me.Text = "FixedAspectRatio" Me.ResumeLayout(False) End Sub End Class

Evenimentul cheie 14.50.5.Add Formular fereastr

Importurile

System.Windows.Forms

public class FormEventKey public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: "Acesta "Nu -l prieten prieten prieten prieten prieten prieten prieten Urmtoarea procedur este cerut de formularul de designer pentru Windows poate fi modificat cu ajutorul . Form Designer pentru Windows modificai folosind editorul de cod. WithEvents keyDataLabel Ca System.Windows.Forms.Label WithEvents label1 Ca System.Windows.Forms.Label WithEvents Label2 Ca System.Windows.Forms.Label WithEvents keyCodeLabel Ca System.Windows.Forms.Label WithEvents modifiersLabel Ca System.Windows.Forms.Label WithEvents label4 Ca System.Windows.Forms. Eticheta WithEvents keyValueLabel Ca System.Windows.Forms.Label Ca apel

Bool

prieten WithEvents label5 Ca System.Windows.Forms.Label prieten WithEvents label3 Ca System.Windows.Forms.Label prieten WithEvents keyCharLabel Ca System.Windows.Forms.Label <System.Diagnostics. DebuggerStepThrough () > Private Sub InitializeComponent () Me.keyDataLabel = New System.Windows.Forms.Label () Me.label1 = New System.Windows.Forms.Label () Me.label2 = New System.Windows.Forms.Label ( ) Me.keyCodeLabel = New System.Windows.Forms.Label () Me.modifiersLabel = New System.Windows.Forms.Label () Me.label4 = New System.Windows.Forms.Label () Me.keyValueLabel = Sistem. Windows.Forms.Label () Me.label5 = New System.Windows.Forms.Label () Me.label3 = New System.Windows.Forms.Label () Me.keyCharLabel = New System.Windows.Forms.Label () Me . SuspendLayout () " "Ke yDataLabel ' Me.keyDataLabel.Anchor = (( System.Windows.Forms.AnchorStyles.Top sau System.Wi Sau System.Windows.Forms.AnchorStyles.Right ) Me . keyDataLabel.Location = New System.Drawing.Point ( 120 , 8 ) Me.keyDataLabel.Name = "keyDataLabel" Me.keyDataLabel.Size = New System.Drawing.Size ( 228 , 23 ) Me.keyDataLabel.TabIndex = 9 ' "La bel1 ' Me.label1.Location = New System.Drawing.Point ( 8 , 8 ) Me.label1.Name = "Label1" Me.label1.TabIndex = 5 Me.label1.Text = "KeyData" " "la bel2 " Me.label2.Location = New System.Drawing.Point ( 8 , 40 ) Me.label2.Name = "Label2" Me.label2.TabIndex = 6 Me.label2.Text = "cel dorit" " "Ke yCodeLabel " Me. keyCodeLabel.Anchor = (( System.Windows.Forms.AnchorStyles.Top sau System.W Sau System.Windows.Forms.AnchorStyles.Right ) Me.keyCodeLabel.Location = New System.Drawing.Point ( 120 , 40 ) Me.keyCodeLabel.Name = "keyCodeLabel" Me.keyCodeLabel.Size = New System.Drawing.Size ( 228 , 23 ) Me.keyCodeLabel.TabIndex = 10 ' 'mo difiersLabel ' Me.modifiersLabel.Anchor = ( ( System.Windows.Forms.AnchorStyles.Top Sau System Sau System.Windows.Forms.AnchorStyles.Right ) Me.modifiersLabel.Location = New System.Drawing.Point ( 120 , 72 ) Me.modifiersLabel.Name = "modifiersLabel" Me.modifiersLabel.Size = New System.Drawing.Size ( 228 , 23 ) Me.modifiersLabel.TabIndex = 11 ' 'la bel4 ' Me.label4.Location = New System.Drawing.Point ( 8 , 72 ) Me.label4.Name = "label4"

Me.label4.TabIndex = 4 Me.label4.Text = "Modificatorii" " "Ke yValueLabel " Me.keyValueLabel.Anchor = (( System.Windows.Forms.AnchorStyles . sus sau System Sau System.Windows.Forms.AnchorStyles.Right ) Me.keyValueLabel.Location = New System.Drawing.Point ( 120 , 104 ) Me.keyValueLabel.Name = "keyValueLabel " Me.keyValueLabel.Size = New System.Drawing.Size ( 228 , 23 ) Me.keyValueLabel.TabIndex = 8 ' 'la bel5 ' Me.label5.Location = New System.Drawing.Point ( 8 , 104 ) Me.label5 . Nume = "label5" Me.label5.TabIndex = 3 Me.label5.Text = "KeyValue" " "la bel3 ' Me.label3.Location = New System.Drawing.Point ( 8 , 136 ) Me.label3.Name = "label3" Me.label3.TabIndex = 2 Me.label3.Text = "KeyChar" " "Ke yCharLabel ' Me.keyCharLabel.Anchor = (( System.Windows.Forms.AnchorStyles.Top Or System.Win Sau System.Windows.Forms.AnchorStyles.Right ) Me.keyCharLabel.Location = New System.Drawing.Point ( 120 , 136 ) Me.keyCharLabel.Name = "keyCharLabel" Me.keyCharLabel.Size = New System.Drawing . Dimensiune ( 228 , 23 ) Me.keyCharLabel.TabIndex = 7 ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 328 , 174 ) Me . Controls.AddRange ( New System.Windows.Forms.Control () { Me.keyDataLabel, Me.Name = "Form1" Me.Text = "KeyTest" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca

Sub privat Form1_KeyDown ( expeditor ByVal Ca obiect, e ByVal keyDataLabel.Text = e.KeyData.ToString () keyCodeLabel.Text = e.KeyCode.ToString () modifiersLabel.Text = e.Modifiers.ToString () keyValueLabel.Text = e.KeyValue.ToString () End Sub Sub privat Form1_KeyPress ( expeditor ByVal Ca keyCharLabel.Text = e.KeyChar.ToString () End Sub End Class obiect, e ByVal

System.Windows

Ca

System.Window

Original

Imports System.Windows.Forms public class FormEventKey public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents keyDataLabel As System.Windows.Forms.Label Friend WithEvents label1 As System.Windows.Forms.Label

Friend WithEvents label2 As System.Windows.Forms.Label Friend WithEvents keyCodeLabel As System.Windows.Forms.Label Friend WithEvents modifiersLabel As System.Windows.Forms.Label Friend WithEvents label4 As System.Windows.Forms.Label Friend WithEvents keyValueLabel As System.Windows.Forms.Label Friend WithEvents label5 As System.Windows.Forms.Label Friend WithEvents label3 As System.Windows.Forms.Label Friend WithEvents keyCharLabel As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.keyDataLabel = New System.Windows.Forms.Label() Me.label1 = New System.Windows.Forms.Label() Me.label2 = New System.Windows.Forms.Label() Me.keyCodeLabel = New System.Windows.Forms.Label() Me.modifiersLabel = New System.Windows.Forms.Label() Me.label4 = New System.Windows.Forms.Label() Me.keyValueLabel = New System.Windows.Forms.Label() Me.label5 = New System.Windows.Forms.Label() Me.label3 = New System.Windows.Forms.Label() Me.keyCharLabel = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'keyDataLabel ' Me.keyDataLabel.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windo Or System.Windows.Forms.AnchorStyles.Right) Me.keyDataLabel.Location = New System.Drawing.Point(120, 8) Me.keyDataLabel.Name = "keyDataLabel" Me.keyDataLabel.Size = New System.Drawing.Size(228, 23) Me.keyDataLabel.TabIndex = 9 ' 'label1 ' Me.label1.Location = New System.Drawing.Point(8, 8) Me.label1.Name = "label1" Me.label1.TabIndex = 5 Me.label1.Text = "KeyData" ' 'label2 ' Me.label2.Location = New System.Drawing.Point(8, 40) Me.label2.Name = "label2" Me.label2.TabIndex = 6 Me.label2.Text = "KeyCode" ' 'keyCodeLabel ' Me.keyCodeLabel.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windo Or System.Windows.Forms.AnchorStyles.Right) Me.keyCodeLabel.Location = New System.Drawing.Point(120, 40) Me.keyCodeLabel.Name = "keyCodeLabel" Me.keyCodeLabel.Size = New System.Drawing.Size(228, 23) Me.keyCodeLabel.TabIndex = 10 ' 'modifiersLabel ' Me.modifiersLabel.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Win Or System.Windows.Forms.AnchorStyles.Right) Me.modifiersLabel.Location = New System.Drawing.Point(120, 72) Me.modifiersLabel.Name = "modifiersLabel" Me.modifiersLabel.Size = New System.Drawing.Size(228, 23) Me.modifiersLabel.TabIndex = 11

' 'label4 ' Me.label4.Location = New System.Drawing.Point(8, 72) Me.label4.Name = "label4" Me.label4.TabIndex = 4 Me.label4.Text = "Modifiers" ' 'keyValueLabel ' Me.keyValueLabel.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Wind Or System.Windows.Forms.AnchorStyles.Right) Me.keyValueLabel.Location = New System.Drawing.Point(120, 104) Me.keyValueLabel.Name = "keyValueLabel" Me.keyValueLabel.Size = New System.Drawing.Size(228, 23) Me.keyValueLabel.TabIndex = 8 ' 'label5 ' Me.label5.Location = New System.Drawing.Point(8, 104) Me.label5.Name = "label5" Me.label5.TabIndex = 3 Me.label5.Text = "KeyValue" ' 'label3 ' Me.label3.Location = New System.Drawing.Point(8, 136) Me.label3.Name = "label3" Me.label3.TabIndex = 2 Me.label3.Text = "KeyChar" ' 'keyCharLabel ' Me.keyCharLabel.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windo Or System.Windows.Forms.AnchorStyles.Right) Me.keyCharLabel.Location = New System.Drawing.Point(120, 136) Me.keyCharLabel.Name = "keyCharLabel" Me.keyCharLabel.Size = New System.Drawing.Size(228, 23) Me.keyCharLabel.TabIndex = 7 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(328, 174) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.keyDataLabel, Me.lab Me.Name = "Form1" Me.Text = "KeyTest" Me.ResumeLayout(False) End Sub #End Region

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.Ke keyDataLabel.Text = e.KeyData.ToString() keyCodeLabel.Text = e.KeyCode.ToString() modifiersLabel.Text = e.Modifiers.ToString() keyValueLabel.Text = e.KeyValue.ToString() End Sub

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.K

keyCharLabel.Text = e.KeyChar.ToString() End Sub End Class

Close un formular

Importurile

System.Windows.Forms

public class FormCloseAction public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac Aruncarea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( Aruncarea ) End Sub Ca apel

Bool

Private

WithEvents btnClose

Ca

System.Windows.Forms.Button

"Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . btnClose = New System.Windows.Forms.Button () Me.SuspendLayout () " "bt nClose ' Me.btnClose.Location = New System.Drawing.Point ( 108 , 102 ) Me.btnClose.Name = "btnClose" Me . btnClose.Size = New System.Drawing.Size ( 56 , 32 ) Me.btnClose.TabIndex = 0 Me.btnClose.Text = "Close" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 272 , 237 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.btnClose }) Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea ca

Private Sub btnClose_Click ( ByVal expeditor Ca System.Object, ByVal e Dim drQuit Ca DialogResult drQuit = MessageBox.Show ( "Chiar vrei s renun?" , _ "certificat de ieire" , _ MessageBoxButtons . YesNo, _ MessageBoxIcon.Warning, _ MessageBoxDefaultButton.Button2 ) Dac drQuit = DialogResult.Yes Apoi Me.Close () End Sub End Class

Syste

Original

Imports System.Windows.Forms public class FormCloseAction public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If Disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(Disposing) End Sub Private WithEvents btnClose As System.Windows.Forms.Button 'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.btnClose = New System.Windows.Forms.Button()

Me.SuspendLayout() ' 'btnClose ' Me.btnClose.Location = New System.Drawing.Point(108, 102) Me.btnClose.Name = "btnClose" Me.btnClose.Size = New System.Drawing.Size(56, 32) Me.btnClose.TabIndex = 0 Me.btnClose.Text = "Close" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(272, 237) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnClose}) Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArg Dim drQuit As DialogResult drQuit = MessageBox.Show("Do you really want to quit?", _ "Exit Confirmation", _ MessageBoxButtons.YesNo, _ MessageBoxIcon.Warning, _ MessageBoxDefaultButton.Button2) If drQuit = DialogResult.Yes Then Me.Close() End Sub End Class

Form eveniment mouse-ul: mouse-ul Enter, mouse-ul jos, mouse-u mouse-ul, roata mouse-ului, concediul mouse-ul

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class FormMouseEvent public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod Ca apel

Bool

prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics . DebuggerStepThrough () > Private Sub InitializeComponent () Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 16 , 48 ) Me . TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 256 , 20 ) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = Nou System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.Add ( Me.TextBox1 ) Me.Name = "Form1" Me.Text = "Form1" Me . ResumeLayout ( Fals ) End Sub # End Regiunea Private Sub Form1_MouseEnter ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere MyBase.MouseEnter TextBox1.Text = "Mouse-ul a intrat n zona client." End Sub Sub privat Form1_MouseDown ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere MyBase.MouseDown Dac e.Button = MouseButtons.Left Apoi TextBox1.Text = "butonul mouse-ului este n jos la (" Dac End End Sub Private Sub Form1_MouseHover ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere MyBase.MouseHover TextBox1.Text = "Mouse-ul este situndu-se." End Sub Private Sub Form1_MouseMove ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere MyBase.MouseMove TextBox1.Text = "mouse-ul sa mutat la: (" & CStr ( EX ) End Sub

& CStr ( eX )

&

",

&

","

& CStr ( eY )

Sub privat Form1_MouseUp ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere MyBase.MouseUp Dac e.Button = MouseButtons.Left Apoi TextBox1.Text = "butonul din stnga al mouse-ului a crescut de la (" Dac End End Sub Private Sub Form1_MouseWheel ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere MyBase.MouseWheel TextBox1.Text = "mouse-ului se rotete roata" si CStr ( e.Delta )

& CSt

"decupl

End Sub Private Sub Form1_MouseLeave ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere MyBase.MouseLeave TextBox1.Text = "stnga mouse-ului n zona client." End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class FormMouseEvent public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(16, 48) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(256, 20) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.TextBox1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Form1_MouseEnter(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.MouseEnter TextBox1.Text = "The mouse entered the client area." End Sub

Private Sub Form1_MouseDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then TextBox1.Text = "The left mouse button is down at (" & CStr(e.X) & ", " & CS End If End Sub Private Sub Form1_MouseHover(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.MouseHover TextBox1.Text = "The mouse is hovering." End Sub Private Sub Form1_MouseMove(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _

Handles MyBase.MouseMove TextBox1.Text = "The mouse moved to: (" & CStr(e.X) & ", " & CStr(e.Y) & ")" End Sub

Private Sub Form1_MouseUp(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles MyBase.MouseUp If e.Button = MouseButtons.Left Then TextBox1.Text = "The left mouse button went up at (" & CStr(e.X) & ", " & CS End If End Sub Private Sub Form1_MouseWheel(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles MyBase.MouseWheel TextBox1.Text = "The mouse wheel rotated " & CStr(e.Delta) & " detents" End Sub Private Sub Form1_MouseLeave(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles MyBase.MouseLeave TextBox1.Text = "The mouse left the client area." End Sub End Class

Evenimentul mouse-ul 14.50.8.Convert pentru a forma drag-and-d

Importurile

System.Windows.Forms

public class ConvertMouseEventToFormDragEvent public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Const HT_CAPTION Ca Integer = & H2 WM_NCLBUTTONDOWN Const Ca Integer = & HA1 Sub privat DragBar_MouseDown ( expeditor ByVal Ca obiect, e ByVal Dac ( e.Button = Windows.Forms.MouseButtons.Left ) Apoi DragBar.Capture = false Me.WndProc ( Message.Create ( Me.Handle, WM_NCLBUTTONDOWN, _ Ctype ( HT_CAPTION, IntPtr ) , IntPtr.Zero )) End If End Sub Ca

System.Win

Private Sub ActClose_Click ( ByVal expeditor Me.Close () End Sub End Class

Ca

System.Object, ByVal e

ca

Syste

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.ActClose = New System.Windows.Forms.Button Me.DragBar = New System.Windows.Forms.PictureBox Ctype ( Me.DragBar,

Boolean )

= System.Windows.Forms.DialogResult.Cancel Me.ActClose.Location = New System.Drawing.Point ( 208 , 80 ) Me.ActClose.Name = "ActClose" Me.ActClose.Size = New System.Drawing.Size ( 75 , 23 ) Me.ActClose.TabIndex = 0 Me.ActClose.Text = "Close" Me.ActClose.UseVisualStyleBackColor = True ' "Dr. Agbar ' Me.DragBar.BackColor = System.Drawing.SystemColors.ActiveCaption Me.DragBar.Location = New System.Drawing.Point ( 8 , 8 ) Me.DragBar.Name = "DragBar" Me.DragBar.Size = New System.Drawing.Size ( 280 , 24 ) Me.DragBar.TabIndex = 1 Me.DragBar.TabStop = fals " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.ActClose Me.ClientSize = Nou = System.Windows.Forms.FormBorderStyle.None

Me.Name = "Form1" Me.Text = "Form1" Ctype ( Me.DragBar, System.ComponentModel.ISupportInitialize ) . EndInit () Me.ResumeLayout ( Fals ) End Sub prieten WithEvents ActClose Ca System.Windows.Forms.Button prieten WithEvents DragBar Ca System.Windows.Forms.PictureBox End Class

Original

14.50.8.Convert Mouse event to form caption drag and drop event

Imports System.Windows.Forms public class ConvertMouseEventToFormDragEvent public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Const HT_CAPTION As Integer = &H2 Const WM_NCLBUTTONDOWN As Integer = &HA1

Private Sub DragBar_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Form If (e.Button = Windows.Forms.MouseButtons.Left) Then DragBar.Capture = False Me.WndProc(Message.Create(Me.Handle, WM_NCLBUTTONDOWN, _ CType(HT_CAPTION, IntPtr), IntPtr.Zero)) End If End Sub

Private Sub ActClose_Click(ByVal sender As System.Object, ByVal e As System.EventArg Me.Close() End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.ActClose = New System.Windows.Forms.Button Me.DragBar = New System.Windows.Forms.PictureBox CType(Me.DragBar, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'ActClose ' Me.ActClose.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.ActClose.Location = New System.Drawing.Point(208, 80) Me.ActClose.Name = "ActClose" Me.ActClose.Size = New System.Drawing.Size(75, 23) Me.ActClose.TabIndex = 0 Me.ActClose.Text = "Close" Me.ActClose.UseVisualStyleBackColor = True ' 'DragBar ' Me.DragBar.BackColor = System.Drawing.SystemColors.ActiveCaption Me.DragBar.Location = New System.Drawing.Point(8, 8) Me.DragBar.Name = "DragBar" Me.DragBar.Size = New System.Drawing.Size(280, 24) Me.DragBar.TabIndex = 1 Me.DragBar.TabStop = False ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.ActClose Me.ClientSize = New System.Drawing.Size(292, 114) Me.Controls.Add(Me.DragBar) Me.Controls.Add(Me.ActClose) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None Me.Name = "Form1" Me.Text = "Form1" CType(Me.DragBar, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub Friend WithEvents ActClose As System.Windows.Forms.Button Friend WithEvents DragBar As System.Windows.Forms.PictureBox End Class

Evenimentul Aspect 14.50.9.Form

Importurile

System.Windows.Forms

public class FormLayoutEvent public comun Sub principal Application.Run ( New GridForm ) End Sub End clasa Public class GridForm Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents button1 Ca System.Windows.Forms.Button prieten WithEvents button2 Ca System.Windows.Forms.Button prieten WithEvents button3 Ca System.Windows.Forms.Button prieten WithEvents button4 Ca System.Windows.Forms.Button prieten WithEvents button5 Ca System.Windows.Forms.Button prieten WithEvents button6 Ca System.Windows.Forms. Butonul prieten WithEvents button7 Ca System.Windows.Forms.Button prieten WithEvents button8 Ca System.Windows.Forms.Button prieten WithEvents button9 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me. button1 = New System.Windows.Forms.Button () Me.button2 = New System.Windows.Forms.Button () Me.button3 = New System.Windows.Forms.Button () Me.button4 = New System.Windows.Forms . Butonul () Me.button5 = New System.Windows.Forms.Button () Me.button6 = New System.Windows.Forms.Button () Me.button7 = New System.Windows.Forms.Button () Me.button8 = nou System.Windows.Forms.Button () Me.button9 = New System.Windows.Forms.Button () Me.SuspendLayout () " "bu tton1 ' Me.button1.Location = New System.Drawing.Point ( 8 , 8 ) Me.button1.Name = "button1" Me.button1.Size = New System.Drawing.Size ( 75 , 75 ) Me.button1.TabIndex = 7 Me.button1.Text = "1" ' 'bu tton2 " Me. button2.Location = New System.Drawing.Point ( 88 , 8 ) Me.button2.Name = "button2" Me.button2.Size = New System.Drawing.Size ( 75 , 75 ) Me.button2.TabIndex = 6 Mine. button2.Text = "2" ' 'bu tton3 ' Me.button3.Location = New System.Drawing.Point ( 168 , 8 ) Me.button3.Name = "button3" Me.button3.Size = New System.Drawing.Size ( 75 , 75 ) Me.button3.TabIndex = 9 Me.button3.Text = "3" ' 'bu tton4 ' Me.button4.Location = New System.Drawing.Point ( 8 , 88 ) Me.button4.Name = " button4 " Me.button4.Size = New System.Drawing.Size ( 75 , 75 ) Me.button4.TabIndex = 8 Me.button4.Text = "4" " "bu tton5 ' Me.button5.Location = New System.Drawing . Punctul ( 88 , 88 ) Me.button5.Name = "button5"

Me.button5.Size = New System.Drawing.Size ( 75 , 75 ) Me.button5.TabIndex = 5 Me.button5.Text = "5" ' "bu tton6 ' Me.button6.Location = New System.Drawing.Point ( 168 , 88 ) Me.button6.Name = "button6" Me.button6.Size = New System.Drawing.Size ( 75 , 75 ) Me.button6 tabindex =. 2 Me.button6.Text = "6" " "bu tton7 ' Me.button7.Location = New System.Drawing.Point ( 8 , 168 ) Me.button7.Name = "button7" Me.button7.Size = New System.Drawing.Size ( 75 , 75 ) Me.button7.TabIndex = 1 Me.button7.Text = "7" " "bu tton8 ' Me.button8.Location = New System.Drawing.Point ( 88 , 168 ) Me . button8.Name = "button8" Me.button8.Size = New System.Drawing.Size ( 75 , 75 ) Me.button8.TabIndex = 4 Me.button8.Text = "8" " "bu tton9 " Me.button9. Locaie = New System.Drawing.Point ( 168 , 168 ) Me.button9.Name = "button9" Me.button9.Size = New System.Drawing.Size ( 75 , 75 ) Me.button9.TabIndex = 3 Me.button9. Text = "9" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 248 , 246 ) Me.Controls.AddRange ( New System.Windows . Forms.Control () { Me.button1, Me.bu Me.Name = "Form1 " Me.Text = "Grid Layout Exemplu" Me.ResumeLayout ( Fals ) End Sub # End Regiunea GridForm_Layout ( expeditor ByVal Ca obiect, e ByVal Ca

Sub privat

System.Windo

Dim butoane Ca Button () = nou buton () { button1, button2, button3, button4 Dim CX Ca Integer = ClientRectangle.Width / 3 Dim CY Ca Integer = ClientRectangle.Height / 3 Dim rnd Aa cum Integer = 0 Do n timp ce rndul < 3 Dim col Dup cum Integer = 0 Do n timp ce COL < 3 Dim b Dup cum Button = butoanele de ( COL * 3 + rnd ) b.Text = "Button" b.SetBounds ( CX * rnd, cy * col, CX, CY ),

col = col + Bucl rnd = rndul + Bucl

1 1 3 , cy * 3 )

SetClientSizeCore ( cx * End Sub End Clasa

Original

14.50.9.Form Layout event

Imports System.Windows.Forms public class FormLayoutEvent public Shared Sub Main Application.Run(New GridForm) End Sub End class Public Class GridForm Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents button1 As System.Windows.Forms.Button Friend WithEvents button2 As System.Windows.Forms.Button Friend WithEvents button3 As System.Windows.Forms.Button Friend WithEvents button4 As System.Windows.Forms.Button Friend WithEvents button5 As System.Windows.Forms.Button Friend WithEvents button6 As System.Windows.Forms.Button Friend WithEvents button7 As System.Windows.Forms.Button Friend WithEvents button8 As System.Windows.Forms.Button Friend WithEvents button9 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.button1 = New System.Windows.Forms.Button() Me.button2 = New System.Windows.Forms.Button() Me.button3 = New System.Windows.Forms.Button() Me.button4 = New System.Windows.Forms.Button() Me.button5 = New System.Windows.Forms.Button() Me.button6 = New System.Windows.Forms.Button() Me.button7 = New System.Windows.Forms.Button() Me.button8 = New System.Windows.Forms.Button() Me.button9 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'button1 ' Me.button1.Location = New System.Drawing.Point(8, 8) Me.button1.Name = "button1" Me.button1.Size = New System.Drawing.Size(75, 75) Me.button1.TabIndex = 7 Me.button1.Text = "1" ' 'button2 ' Me.button2.Location = New System.Drawing.Point(88, 8) Me.button2.Name = "button2" Me.button2.Size = New System.Drawing.Size(75, 75) Me.button2.TabIndex = 6 Me.button2.Text = "2" ' 'button3 ' Me.button3.Location = New System.Drawing.Point(168, 8) Me.button3.Name = "button3" Me.button3.Size = New System.Drawing.Size(75, 75) Me.button3.TabIndex = 9 Me.button3.Text = "3" ' 'button4

' Me.button4.Location = New System.Drawing.Point(8, 88) Me.button4.Name = "button4" Me.button4.Size = New System.Drawing.Size(75, 75) Me.button4.TabIndex = 8 Me.button4.Text = "4" ' 'button5 ' Me.button5.Location = New System.Drawing.Point(88, 88) Me.button5.Name = "button5" Me.button5.Size = New System.Drawing.Size(75, 75) Me.button5.TabIndex = 5 Me.button5.Text = "5" ' 'button6 ' Me.button6.Location = New System.Drawing.Point(168, 88) Me.button6.Name = "button6" Me.button6.Size = New System.Drawing.Size(75, 75) Me.button6.TabIndex = 2 Me.button6.Text = "6" ' 'button7 ' Me.button7.Location = New System.Drawing.Point(8, 168) Me.button7.Name = "button7" Me.button7.Size = New System.Drawing.Size(75, 75) Me.button7.TabIndex = 1 Me.button7.Text = "7" ' 'button8 ' Me.button8.Location = New System.Drawing.Point(88, 168) Me.button8.Name = "button8" Me.button8.Size = New System.Drawing.Size(75, 75) Me.button8.TabIndex = 4 Me.button8.Text = "8" ' 'button9 ' Me.button9.Location = New System.Drawing.Point(168, 168) Me.button9.Name = "button9" Me.button9.Size = New System.Drawing.Size(75, 75) Me.button9.TabIndex = 3 Me.button9.Text = "9" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(248, 246) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button1, Me.button2, Me.Name = "Form1" Me.Text = "Grid Layout Example" Me.ResumeLayout(False) End Sub #End Region

Private Sub GridForm_Layout(ByVal sender As Object, ByVal e As System.Windows.Forms.

Dim buttons As Button() = New Button() {button1, button2, button3, button4, butt Dim cx As Integer = ClientRectangle.Width / 3 Dim cy As Integer = ClientRectangle.Height / 3 Dim row As Integer = 0 Do While row < 3 Dim col As Integer = 0 Do While col < 3 Dim b As Button = buttons(col * 3 + row) b.Text = "Button" b.SetBounds(cx * row, cy * col, cx, cy) col = col + 1 Loop row = row + 1 Loop SetClientSizeCore(cx * 3, cy * 3) End Sub End Class

Overrides metoda OnNotifyMessage


Importurile Importurile System.Windows.Forms System.IO

Public class WndProcTextBox Motenete TextBox # Region "Component Designer codul generat" Ca System.ComponentModel.IContainer ) clasa Compoziie Designer suport

Public Sub New ( containere ByVal MyClass.New ()

"Re quired pentru Windows.Forms Container.Add ( Me ) End Sub Public Sub New () MyBase.New ()

"Th este apel este necesar de Designer Component. InitializeComponent () "Ad d orice iniializare dup InitializeComponent () de apel Me.SetStyle ( ControlStyles.EnableNotifyMessage, Adevrat ) End Sub "Co mponent prevaleaz dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac Ca

Bool

MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Component Designer Private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Designer Component "Acesta poate fi modificat cu ajutorul . Designer Componenta "Nu -l modificai folosind . editorul de cod <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () componentele = Nou System.ComponentModel.Container () End Sub # End Regiunea delegat Sub ShowEventInfo ( informaii ByVal Ca ShowEventInfoEvent Eveniment Ca ShowEventInfo String )

Public Public

Protejate nlocuiete Sub OnNotifyMessage ( ByVal m Ca System.Windows.Forms.Mes RaiseEvent ShowEventInfoEvent ( String.Format ( "Msg: HWND ({0}) LPARAM ({1}) wP MyBase.OnNotifyMessage ( m ) End Sub End Class

Original

Imports System.Windows.Forms Imports System.IO

Public Class WndProcTextBox Inherits TextBox #Region " Component Designer generated code " Public Sub New(ByVal Container As System.ComponentModel.IContainer) MyClass.New() 'Required for Windows.Forms Class Composition Designer support Container.Add(Me) End Sub Public Sub New() MyBase.New() 'This call is required by the Component Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call Me.SetStyle(ControlStyles.EnableNotifyMessage, True) End Sub

'Component overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Component Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Component Designer 'It can be modified using the Component Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() components = New System.ComponentModel.Container() End Sub #End Region Public Delegate Sub ShowEventInfo(ByVal info As String) Public Event ShowEventInfoEvent As ShowEventInfo

Protected Overrides Sub OnNotifyMessage(ByVal m As System.Windows.Forms.Message) RaiseEvent ShowEventInfoEvent(String.Format("Msg: HWND({0}) LPARAM({1}) WPARAM({ MyBase.OnNotifyMessage(m) End Sub End Class

Form eveniment de redimensionare

Importurile

System.Windows.Forms

public class FormResizeEvent public comun Sub principal

Application.Run ( New Form1 ) End Sub End clasa Clasa publice Form1 Ca System.Object, ByVal e ca

Sub privat Form1_Resize ( expeditor ByVal GroupBox1.Top = 0 GroupBox1.Left = 0 GroupBox1.Width = Me.Width GroupBox1.Height = Me.Height Label1.Left = GroupBox1.Top + = Label1.Top GroupBox1.Left + 10 20

System.E

TextBox1.Top = Label1.Top + 50 = TextBox1.Left Label1.Left TextBox1.Width = GroupBox1.Width -

20

End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = Nou

Boolean )

= New System.Drawing.Point ( 12 , 12 ) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size ( 392 , Me.GroupBox1.TabIndex = 0 Me.GroupBox1.TabStop = false Me.GroupBox1.Text = "GroupBox1" " "Te xtBox1 '

195 )

Me.TextBox1.Location = New System.Drawing.Point ( 32 , 62 ) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me . TextBox1.Size = New System.Drawing.Size ( 331 , 21 ) Me.TextBox1.TabIndex = 5 ' 'La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 30 , 30 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 41 , 12 ) Me.Label1.TabIndex = 4 Me.Label1.Text = "Label1" " "Fo RM1 " Me . AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 416 , 219 ) Me.Controls.Add ( Me.GroupBox1 ) Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout ( Fals ) Me.GroupBox1.PerformLayout () Me.ResumeLayout ( Fals ) End Sub prieten WithEvents GroupBox1 Ca System.Windows.Forms.GroupBox prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Label1 Ca System.Windows.Forms.Label End Class

12.0 ! )

Original

Imports System.Windows.Forms

public class FormResizeEvent public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) GroupBox1.Top = 0 GroupBox1.Left = 0 GroupBox1.Width = Me.Width GroupBox1.Height = Me.Height Label1.Left = GroupBox1.Top + 10 Label1.Top = GroupBox1.Left + 20 TextBox1.Top = Label1.Top + 50 TextBox1.Left = Label1.Left TextBox1.Width = GroupBox1.Width - 20 End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.TextBox1) Me.GroupBox1.Controls.Add(Me.Label1) Me.GroupBox1.Location = New System.Drawing.Point(12, 12) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(392, 195) Me.GroupBox1.TabIndex = 0 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "GroupBox1" '

'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(32, 62) Me.TextBox1.Multiline = True Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(331, 21) Me.TextBox1.TabIndex = 5 ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(30, 30) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(41, 12) Me.Label1.TabIndex = 4 Me.Label1.Text = "Label1" ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(416, 219) Me.Controls.Add(Me.GroupBox1) Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout(False) Me.GroupBox1.PerformLayout() Me.ResumeLayout(False) End Sub Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label End Class

MsgBox cu doar mesaj


Modulul Module1 Sub Main () MsgBox ( "Mesaj" ) End Sub End Module

Original

Module Module1 Sub Main()

MsgBox("Message") End Sub End Module

MsgBox cu titlul i va abandona Rencercare Ignore butoane


Modulul Module1 Sub Main () MsgBox ( "Message" , MsgBoxStyle.AbortRetryIgnore, "Titlu" ) End Sub End Module

Original

Module Module1 Sub Main() MsgBox("Message", MsgBoxStyle.AbortRetryIgnore,"Title") End Sub End Module

MsgBox i vbYes

Importurile

System.Windows.Forms

public class MsgBoxDemo public comun sub principal Dim exita Ca String exita = MsgBox ( "Exit?" , Microsoft.VisualBasic.MsgBoxStyle.Exclamation + Micro Daca exita = vbYes Apoi End End Dac Console.WriteLine ( Microsoft.VisualBasic.MsgBoxStyle.MsgBoxHelp )

End Sub clasa End

Originar

Imports System.Windows.Forms

public class MsgBoxDemo public Shared Sub Main Dim exita As String exita = MsgBox("Exit?", Microsoft.VisualBasic.MsgBoxStyle.Exclamation + Microsof If exita = vbYes Then End End If Console.WriteLine( Microsoft.VisualBasic.MsgBoxStyle.MsgBoxHelp) End Sub End class

Set combinaie buton MsgBox

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class MsgBoxButtonSetting public comun sub principal Dim Areturn Ca String Areturn = MsgBox ( "Message" , vbOKCancel + vbDefaultButton1 + vbQuestion, "Vb OKOnly + vbInformation + vbDefaultButton1 "vb OKOnly + vbExclamation + vbDefaultButton1 "vb OKOnly + vbDefaultButton1 + vbCritical Select Case Areturn

"Tit

caz vbOK Console. WriteLine ( "vbOK" ) Cauza vbCancel Console.WriteLine ( "vbCancel" ) Cauza vbAbort Console.WriteLine ( "vbAbort" ) Cauza vbRetry Console.WriteLine ( "vbRetry" ) Cauza vbIgnore Console.WriteLine ( "vbIgnore" ) Case Else Console. WriteLine ( "Else" ) End Select End Sub clasa End

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class MsgBoxButtonSetting public Shared Sub Main

Dim Areturn As String Areturn = MsgBox("Message", vbOKCancel + vbDefaultButton1 + vbQuestion, "Title") 'vbOKOnly + vbInformation + vbDefaultButton1 'vbOKOnly + vbExclamation + vbDefaultButton1 'vbOKOnly + vbDefaultButton1 + vbCritical Select Case Areturn Case vbOK Console.WriteLine("vbOK") Case vbCancel Console.WriteLine("vbCancel") Case vbAbort Console.WriteLine("vbAbort") Case vbRetry Console.WriteLine("vbRetry") Case vbIgnore Console.WriteLine("vbIgnore") Case Else Console.WriteLine("Else") End Select

End Sub End class

Valoarea 14.59.5.Return din MsgBox

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class MsgBoxReturnValue public comun sub principal Dim intReturnValue Ca Integer intReturnValue = MsgBox ( "Aceasta este o caset de mesaj" , MsgBoxStyle.OKCance Dac ( intReturnValue = MsgBoxResult.OK ) Apoi, Console.WriteLine ( "ai fcut clic pe butonul OK." ) End If End Sub clasa End

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms

public class MsgBoxReturnValue public Shared Sub Main Dim intReturnValue As Integer intReturnValue = MsgBox("This is a message box!",MsgBoxStyle.OKCancel + MsgBoxSt If (intReturnValue = MsgBoxResult.OK) Then Console.WriteLine("You clicked the OK button.") End If End Sub

End class

MessageBox doar cu mesaje

Importurile

System.Windows.Forms

public class MessageBoxWithMessageOnly public comun Sub Main MessageBox.Show ( "Mesaj" ) End Sub End clasa

Original

Imports System.Windows.Forms public class MessageBoxWithMessageOnly public Shared Sub Main MessageBox.Show("Message") End Sub End class

MessageBox cu mesaje i titlul

Importurile

System.Windows.Forms

public class MessageBoxWithMessageAndTile public comun Sub Main MessageBox.Show ( "Message" , "Titlu" ) End Sub End clasa

Original

Imports System.Windows.Forms public class MessageBoxWithMessageAndTile public Shared Sub Main MessageBox.Show("Message", "Title") End Sub End class

MessageBox cu OK, buton i informare Anulare

Importurile

System.Windows.Forms

public class MessageBoxOKCancelInformation public comun sub principal Dim rspuns Ca DialogResult answer = MessageBox.Show ( "A" , "B" , MessageBoxButtons.OKCancel, MessageBoxIcon. End Sub End clasa

Original

Imports System.Windows.Forms

public class MessageBoxOKCancelInformation public Shared Sub Main Dim answer As DialogResult answer = MessageBox.Show("A","B", MessageBoxButtons.OKCancel,MessageBoxIcon.Inform End Sub End class

MessageBox cu Da Nu buton i simbol ntrebare Anulare

Importurile

System.Windows.Forms

public class MessageBoxYesNoCancelQuestion public comun sub principal Dim rspuns Ca DialogResult answer = MessageBox.Show ( "A" , "B" , _ MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question ) End Sub End clasa

Original

Imports System.Windows.Forms public class MessageBoxYesNoCancelQuestion public Shared Sub Main

Dim answer As DialogResult answer = MessageBox.Show("A", "B", _ MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) End Sub End class

MessageBox OK i Cancel Button

Importurile

System.Windows.Forms

public class MessageBoxWithMessageAndTile public comun Sub Main MessageBox.Show ( "Message" , "Titlu" , MessageBoxButtons.OKCancel ) End Sub End clasa

Original

Imports System.Windows.Forms public class MessageBoxWithMessageAndTile public Shared Sub Main MessageBox.Show("Message", "Title", MessageBoxButtons.OKCancel) End Sub End class

Imports System.Windows.Forms public class MessageBoxWithMessageAndTile public Shared Sub Main MessageBox.Show("Message", "Title", MessageBoxButtons.OKCancel) End Sub End class

MessageBox: Abort, Retry, Ignore butoane i pictograma de averti

Importurile

System.Windows.Forms

public class MessageBoxWithMessageAndTile public comun Sub Main MessageBox.Show ( "Message" , "Titlu" , MessageBoxButtons.AbortRetryIgnore, Mes ING ) End Sub End clasa

Original

Imports System.Windows.Forms

public class MessageBoxWithMessageAndTile public Shared Sub Main MessageBox.Show("Message", "Title", MessageBoxButtons.AbortRetryIgnore, MessageB ing) End Sub End class

Butonul implicit 14.60.7.Set pentru MESSAGEBOX

Importurile

System.Windows.Forms

public class MessageBoxDefaultButtonDemo public comun sub principal Dim rspuns Ca DialogResult answer = MessageBox.Show ( "A" , "B" , MessageBoxButtons.YesNoCancel, MessageBoxI MessageBoxDefaultButton.Button2 ) End Sub End clasa

Original

14.60.7.Set default button for MessageBox

Imports System.Windows.Forms

public class MessageBoxDefaultButtonDemo public Shared Sub Main Dim answer As DialogResult answer = MessageBox.Show("A", "B",MessageBoxButtons.YesNoCancel, MessageBoxIcon.Qu MessageBoxDefaultButton.Button2) End Sub End class

Valoarea 14.60.9.Return de la MessageBox


Importurile Importurile Importurile System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class MessageBoxReturnValue public comun sub principal Dim intReturnValue Ca Integer intReturnValue = MessageBox.Show ( "Aceasta este, de asemenea, o caset de mesaj MessageBoxButtons.OKCancel, MessageBoxIcon.Information, _

MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly ) n cazul n care ( intReturnValue = DialogResult.OK ) Apoi Console.WriteLine ( "ai fcut clic pe butonul OK." ) End Dac End Sub clasa End

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms

public class MessageBoxReturnValue public Shared Sub Main Dim intReturnValue As Integer intReturnValue = MessageBox.Show("This is also a message box!", "Message Box", _ MessageBoxButtons.OKCancel, MessageBoxIcon.Information, _ MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) If (intReturnValue = DialogResult.OK) Then Console.WriteLine("You clicked the OK button.") End If End Sub End class

MessageBox Pictograma i Button

Importurile

System.Windows.Forms

public class RadioButtonAction public comun Sub principal Application.Run ( New FrmRadioButton ) End Sub End clasa Public class FrmRadioButton Motenete System.Windows.Forms.Form Privat iconType Ca MessageBoxIcon private buttonType Ca MessageBoxButtons # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub prieten WithEvents iconGroupBox Ca System.Windows.Forms.GroupBox prieten WithEvents buttonTypeGroupBox Ca System.Windows.Forms.GroupBox prieten WithEvents radRetryCancel Ca System.Windows.Forms.RadioButton prieten WithEvents radYesNo Ca System.Windows.Forms.RadioButton prieten WithEvents radAbortRetryIgnore Ca sistem . Windows.Forms.RadioButton prieten WithEvents Radok Ca System.Windows.Forms.RadioButton prieten WithEvents radWarning Ca System.Windows.Forms.RadioButton prieten WithEvents radStop Ca System.Windows.Forms.RadioButton prieten WithEvents radQuestion Ca System.Windows.Forms.RadioButton Prietenul WithEvents radInformation Ca System.Windows.Forms.RadioButton prieten WithEvents radHand Ca System.Windows.Forms.RadioButton prieten WithEvents radExclamation Ca System.Windows.Forms.RadioButton prieten WithEvents radError Ca System.Windows.Forms.RadioButton prieten WithEvents radAsterisk Ca sistem. Windows.Forms.RadioButton prieten WithEvents cmdDisplay Ca System.Windows.Forms.Button prieten WithEvents lblDisplay Ca System.Windows.Forms.Label prieten WithEvents radOkCancel Ca System.Windows.Forms.RadioButton prieten WithEvents radYesNoCancel Ca System.Windows.Forms.RadioButton "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () apel

Boole

Me . radAbortRetryIgnore = New System.Windows.Forms.RadioButton () Me.radStop = New System.Windows.Forms.RadioButton () Me.radYesNo = New System.Windows.Forms.RadioButton () Me.iconGroupBox = New System.Windows. Forms.GroupBox () Me.radWarning = New System.Windows.Forms.RadioButton () Me.radQuestion = New System.Windows.Forms.RadioButton () Me.radInformation = New System.Windows.Forms.RadioButton () Me.radHand = New System.Windows.Forms.RadioButton () Me.radExclamation = New System.Windows.Forms.RadioButton () Me.radError = New System.Windows.Forms.RadioButton () Me.radAsterisk = System.Windows.Forms noi. RadioButon () Me.radYesNoCancel = New System.Windows.Forms.RadioButton () Me.radOk = New System.Windows.Forms.RadioButton () Me.cmdDisplay = New System.Windows.Forms.Button () Me.lblDisplay = Nou System.Windows.Forms.Label () Me.buttonTypeGroupBox = New System.Windows.Forms.GroupBox () Me.radRetryCancel = New System.Windows.Forms.RadioButton () Me.radOkCancel = Nou

= New System.Drawing.Point ( 16 , 88 ) Me.radAbortRetryIgnore.Name = "radAbortRetryIgnore" Me.radAbortRetryIgnore.Size = New System.Drawing.Size ( 120 , 24 ) Me.radAbortRetryIgnore.TabIndex = 2 Me.radAbortRetryIgnore.Text = "AbortRetryIgnore" " "ra dStop ' Me.radStop.Location = New System.Drawing.Point ( 16 , 240 ) Me.radStop.Name = "radStop" Me.radStop.Size = New System.Drawing.Size ( 128 , 24 ) Me.radStop.TabIndex = 6 Me.radStop.Text = "Stop" " "ra dYesNo ' Me.radYesNo.Location = New System.Drawing.Point ( 16 , 160 ) Me.radYesNo.Name = "radYesNo" Me radYesNo.Size = New System.Drawing.Size. ( 120 , 16 ) Me.radYesNo.TabIndex = 4 Me.radYesNo.Text = "YesNo" " "IC onGroupBox " Me.iconGroupBox.Controls.AddRange ( New System.Windows. Forms.Control () { Me.radW Me.iconGroupBox.Location = New System.Drawing. punct ( 200 , 16 ) Me.iconGroupBox.Name = "iconGroupBox" Me.iconGroupBox.Size = New System.Drawing.Size ( 160 , 304 ) Me.iconGroupBox.TabIndex = 3 Me.iconGroupBox.TabStop = false Me.iconGroupBox. Text = "Icon" " "ra dWarning ' Me.radWarning.Location = New System.Drawing.Point ( 16 , 272 ) Me.radWarning.Name = "radWarning" Me.radWarning.Size = New System.Drawing.Size ( 128 , 24 )

Me.radWarning.TabIndex = 7 Me.radWarning.Text = "Avertisment" " "ra dQuestion ' Me.radQuestion.Location = New System.Drawing.Point ( 16 , 208 ) Me.radQuestion.Name = "radQuestion" Me.radQuestion.Size = New System.Drawing.Size ( 128 , 24 ) Me.radQuestion.TabIndex = 5 Me.radQuestion.Text = "ntrebare" " "ra dInformation ' Me.radInformation.Location = New System.Drawing.Point ( 16 , 168 ) Me.radInformation.Name = "radInformation" Me.radInformation.Size = New System.Drawing.Size ( 128 , 24 ) Me.radInformation.TabIndex = 4 Me.radInformation.Text = "Informaii" " "ra dHand ' Me.radHand.Location = New System.Drawing.Point ( 16 , 128 ) Me.radHand.Name = "radHand" Me.radHand.Size = New System.Drawing.Size ( 128 , 24 ) Me.radHand.TabIndex = 3 Me.radHand.Text = "Hand" " "ra dExclamation ' Me.radExclamation.Location = New System.Drawing.Point ( 16 , 88 ) Me.radExclamation.Name = "radExclamation" Me.radExclamation.Size = Sistem . Drawing.Size ( 136 , 24 ) Me.radExclamation.TabIndex = 2 Me.radExclamation.Text = "exclamare" " "ra dError ' Me.radError.Location = New System.Drawing.Point ( 16 , 48 ) Me.radError . Nume = "radError" Me.radError.Size = New System.Drawing.Size ( 136 , 24 ) Me.radError.TabIndex = 1 Me.radError.Text = "Eroare" " "ra dAsterisk ' Me.radAsterisk.Location = New System.Drawing.Point ( 16 , 16 ) Me.radAsterisk.Name = "radAsterisk" Me.radAsterisk.Size = New System.Drawing.Size ( 136 , 24 ) Me.radAsterisk.TabIndex = 0 Me.radAsterisk.Text = "Asterisk" " "ra dYesNoCancel ' Me.radYesNoCancel.Location = New System.Drawing.Point ( 16 , 120 ) Me.radYesNoCancel.Name = "radYesNoCancel" Me.radYesNoCancel.Size = New System.Drawing.Size ( 120 , 24 ) Me.radYesNoCancel.TabIndex = 3 Me.radYesNoCancel.Text = "YesNoCancel" " "ra DOK "

Me.radOk.Location = New System.Drawing.Point ( 16 , 24 ) Me.radOk.Name = "Radok" Me. radOk.Size = New System.Drawing.Size ( 112 , 16 ) Me.radOk.TabIndex = 0 Me.radOk.Text = "OK" " "cm dDisplay ' Me.cmdDisplay.Location = New System.Drawing.Point ( 32 , 240 ) Me.cmdDisplay.Name = "cmdDisplay" Me.cmdDisplay.Size = New System.Drawing.Size ( 112 , 40 ) Me.cmdDisplay.TabIndex = 1 Me.cmdDisplay.Text = "Display" " 'lb lDisplay " Me.lblDisplay.Location = New System.Drawing.Point ( 24 , 296 ) Me.lblDisplay.Name = "lblDisplay" Me.lblDisplay.Size = New System.Drawing.Size ( 144 , 24 ) Me.lblDisplay.TabIndex = 5 " "bu ttonTypeGroupBox " Me.buttonTypeGroupBox.Controls.AddRange ( New System.Windows.Forms.Control () { Me Me . buttonTypeGroupBox.Location = New System.Drawing.Point ( 16 , 16 ) Me.buttonTypeGroupBox.Name = "buttonTypeGroupBox" Me.buttonTypeGroupBox.Size = New System.Drawing.Size ( 144 , 216 ) Me.buttonTypeGroupBox.TabIndex = 2 Me buttonTypeGroupBox.TabStop = Fals. Me.buttonTypeGroupBox.Text = "Butonul de tip" " "ra dRetryCancel ' Me.radRetryCancel.Location = New System.Drawing.Point ( 16 , 192 ) Me.radRetryCancel.Name = "radRetryCancel" Me.radRetryCancel . Dimensiune = New System.Drawing.Size ( 104 , 16 ) Me.radRetryCancel.TabIndex = 5 Me.radRetryCancel.Text = "RetryCancel" " "ra dOkCancel ' Me.radOkCancel.Location = New System.Drawing.Point ( 16 , 56 ) Me.radOkCancel.Name = "radOkCancel" Me.radOkCancel.Size = New System.Drawing.Size ( 120 , 24 ) Me.radOkCancel.TabIndex = 1 Me.radOkCancel.Text = "OKCancel" ' "Parintele mRadioButton " Me . AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 384 , 333 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.lblDisplay, Me.ico Me.Name = "FrmRadioButton" Me.Text

End Sub # End Regiunea

Private Sub cmdDisplay_Click ( ByVal expeditor _ Ca System.Object, ByVal e ca System.EventArgs ) Manere cmdDisplay.Click Dim dialog Ca DialogResult = MessageBox.Show ( "Mesajul dvs." , "Titlu" , _ buttonType, iconType ) _

Selectai Case de dialog caz DialogResult.OK lblDisplay.Text = "OK a fost apsat" Cazul DialogResult.Cancel lblDisplay.Text = "Cancel a fost apsat" Cazul DialogResult.Abort lblDisplay.Text = "ntrerupe a fost apsat" Cazul DialogResult.Retry lblDisplay.Text = "Rencercai a fost apsat" Cazul DialogResult.Ignore lblDisplay.Text = "Ignor a fost apsat" Cazul DialogResult.Yes lblDisplay.Text = "Da a fost apsat" Cazul DialogResult.No lblDisplay.Text = "Nu a fost apsat" End Select End Sub 'c mdDisplay_Click _

Private Sub radOk_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) Manere radOk.CheckedChanged buttonType = MessageBoxButtons.OK End Sub

Private Sub radOkCancel_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radOkCancel.CheckedChanged buttonType = MessageBoxButtons.OKCancel End Sub Private Sub radAbortRetryIgnore_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radAbortRetryIgnore.CheckedChanged buttonType = MessageBoxButtons.AbortRetryIgnore End Sub Private Sub radYesNoCancel_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radYesNoCancel.CheckedChanged buttonType = MessageBoxButtons.YesNoCancel End Sub Private Sub radYesNo_CheckedChanged ( _ expeditor ByVal

Ca System.Object, ByVal e ca Manere radYesNo.CheckedChanged

System.EventArgs )

buttonType = MessageBoxButtons.YesNo End Sub Private Sub radRetryCancel_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radRetryCancel.CheckedChanged buttonType = MessageBoxButtons.RetryCancel End Sub Private Sub radAsterisk_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radAsterisk.CheckedChanged iconType = MessageBoxIcon.Asterisk End Sub Private Sub radError_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radError.CheckedChanged iconType = MessageBoxIcon.Error End Sub Private Sub radExclamation_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radExclamation.CheckedChanged iconType = MessageBoxIcon.Exclamation End Sub Private Sub radHand_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radHand.CheckedChanged iconType = MessageBoxIcon.Hand End Sub Private Sub radInformation_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radInformation.CheckedChanged iconType = MessageBoxIcon.Information End Sub Private Sub radQuestion_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radQuestion.CheckedChanged iconType = MessageBoxIcon.Question End Sub Private Sub radStop_CheckedChanged ( ByVal _ expeditor Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radStop.CheckedChanged iconType = MessageBoxIcon.Stop End Sub

Private Sub radWarning_CheckedChanged ( expeditor ByVal _ Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radWarning.CheckedChanged iconType = MessageBoxIcon.Warning End Sub End Class

Original

Imports System.Windows.Forms public class RadioButtonAction public Shared Sub Main Application.Run(New FrmRadioButton) End Sub End class Public Class FrmRadioButton Inherits System.Windows.Forms.Form Private iconType As MessageBoxIcon Private buttonType As MessageBoxButtons #Region " Windows Form Designer generated code " Public Sub New() MyBase.New()

'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents iconGroupBox As System.Windows.Forms.GroupBox Friend WithEvents buttonTypeGroupBox As System.Windows.Forms.GroupBox Friend WithEvents radRetryCancel As System.Windows.Forms.RadioButton Friend WithEvents radYesNo As System.Windows.Forms.RadioButton Friend WithEvents radAbortRetryIgnore As System.Windows.Forms.RadioButton Friend WithEvents radOk As System.Windows.Forms.RadioButton Friend WithEvents radWarning As System.Windows.Forms.RadioButton Friend WithEvents radStop As System.Windows.Forms.RadioButton Friend WithEvents radQuestion As System.Windows.Forms.RadioButton Friend WithEvents radInformation As System.Windows.Forms.RadioButton Friend WithEvents radHand As System.Windows.Forms.RadioButton Friend WithEvents radExclamation As System.Windows.Forms.RadioButton Friend WithEvents radError As System.Windows.Forms.RadioButton Friend WithEvents radAsterisk As System.Windows.Forms.RadioButton Friend WithEvents cmdDisplay As System.Windows.Forms.Button Friend WithEvents lblDisplay As System.Windows.Forms.Label Friend WithEvents radOkCancel As System.Windows.Forms.RadioButton Friend WithEvents radYesNoCancel As System.Windows.Forms.RadioButton 'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.radAbortRetryIgnore = New System.Windows.Forms.RadioButton() Me.radStop = New System.Windows.Forms.RadioButton() Me.radYesNo = New System.Windows.Forms.RadioButton() Me.iconGroupBox = New System.Windows.Forms.GroupBox() Me.radWarning = New System.Windows.Forms.RadioButton() Me.radQuestion = New System.Windows.Forms.RadioButton() Me.radInformation = New System.Windows.Forms.RadioButton() Me.radHand = New System.Windows.Forms.RadioButton() Me.radExclamation = New System.Windows.Forms.RadioButton() Me.radError = New System.Windows.Forms.RadioButton() Me.radAsterisk = New System.Windows.Forms.RadioButton() Me.radYesNoCancel = New System.Windows.Forms.RadioButton() Me.radOk = New System.Windows.Forms.RadioButton() Me.cmdDisplay = New System.Windows.Forms.Button() Me.lblDisplay = New System.Windows.Forms.Label() Me.buttonTypeGroupBox = New System.Windows.Forms.GroupBox() Me.radRetryCancel = New System.Windows.Forms.RadioButton() Me.radOkCancel = New System.Windows.Forms.RadioButton() Me.iconGroupBox.SuspendLayout()

Me.buttonTypeGroupBox.SuspendLayout() Me.SuspendLayout() ' 'radAbortRetryIgnore ' Me.radAbortRetryIgnore.Location = New System.Drawing.Point(16, 88) Me.radAbortRetryIgnore.Name = "radAbortRetryIgnore" Me.radAbortRetryIgnore.Size = New System.Drawing.Size(120, 24) Me.radAbortRetryIgnore.TabIndex = 2 Me.radAbortRetryIgnore.Text = "AbortRetryIgnore" ' 'radStop ' Me.radStop.Location = New System.Drawing.Point(16, 240) Me.radStop.Name = "radStop" Me.radStop.Size = New System.Drawing.Size(128, 24) Me.radStop.TabIndex = 6 Me.radStop.Text = "Stop" ' 'radYesNo ' Me.radYesNo.Location = New System.Drawing.Point(16, 160) Me.radYesNo.Name = "radYesNo" Me.radYesNo.Size = New System.Drawing.Size(120, 16) Me.radYesNo.TabIndex = 4 Me.radYesNo.Text = "YesNo" ' 'iconGroupBox ' Me.iconGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.radWarnin Me.iconGroupBox.Location = New System.Drawing.Point(200, 16) Me.iconGroupBox.Name = "iconGroupBox" Me.iconGroupBox.Size = New System.Drawing.Size(160, 304) Me.iconGroupBox.TabIndex = 3 Me.iconGroupBox.TabStop = False Me.iconGroupBox.Text = "Icon" ' 'radWarning ' Me.radWarning.Location = New System.Drawing.Point(16, 272) Me.radWarning.Name = "radWarning" Me.radWarning.Size = New System.Drawing.Size(128, 24) Me.radWarning.TabIndex = 7 Me.radWarning.Text = "Warning" ' 'radQuestion ' Me.radQuestion.Location = New System.Drawing.Point(16, 208) Me.radQuestion.Name = "radQuestion" Me.radQuestion.Size = New System.Drawing.Size(128, 24) Me.radQuestion.TabIndex = 5 Me.radQuestion.Text = "Question" ' 'radInformation ' Me.radInformation.Location = New System.Drawing.Point(16, 168) Me.radInformation.Name = "radInformation" Me.radInformation.Size = New System.Drawing.Size(128, 24) Me.radInformation.TabIndex = 4 Me.radInformation.Text = "Information" '

'radHand ' Me.radHand.Location = New System.Drawing.Point(16, 128) Me.radHand.Name = "radHand" Me.radHand.Size = New System.Drawing.Size(128, 24) Me.radHand.TabIndex = 3 Me.radHand.Text = "Hand" ' 'radExclamation ' Me.radExclamation.Location = New System.Drawing.Point(16, 88) Me.radExclamation.Name = "radExclamation" Me.radExclamation.Size = New System.Drawing.Size(136, 24) Me.radExclamation.TabIndex = 2 Me.radExclamation.Text = "Exclamation" ' 'radError ' Me.radError.Location = New System.Drawing.Point(16, 48) Me.radError.Name = "radError" Me.radError.Size = New System.Drawing.Size(136, 24) Me.radError.TabIndex = 1 Me.radError.Text = "Error" ' 'radAsterisk ' Me.radAsterisk.Location = New System.Drawing.Point(16, 16) Me.radAsterisk.Name = "radAsterisk" Me.radAsterisk.Size = New System.Drawing.Size(136, 24) Me.radAsterisk.TabIndex = 0 Me.radAsterisk.Text = "Asterisk" ' 'radYesNoCancel ' Me.radYesNoCancel.Location = New System.Drawing.Point(16, 120) Me.radYesNoCancel.Name = "radYesNoCancel" Me.radYesNoCancel.Size = New System.Drawing.Size(120, 24) Me.radYesNoCancel.TabIndex = 3 Me.radYesNoCancel.Text = "YesNoCancel" ' 'radOk ' Me.radOk.Location = New System.Drawing.Point(16, 24) Me.radOk.Name = "radOk" Me.radOk.Size = New System.Drawing.Size(112, 16) Me.radOk.TabIndex = 0 Me.radOk.Text = "OK" ' 'cmdDisplay ' Me.cmdDisplay.Location = New System.Drawing.Point(32, 240) Me.cmdDisplay.Name = "cmdDisplay" Me.cmdDisplay.Size = New System.Drawing.Size(112, 40) Me.cmdDisplay.TabIndex = 1 Me.cmdDisplay.Text = "Display" ' 'lblDisplay ' Me.lblDisplay.Location = New System.Drawing.Point(24, 296) Me.lblDisplay.Name = "lblDisplay" Me.lblDisplay.Size = New System.Drawing.Size(144, 24)

Me.lblDisplay.TabIndex = 5 ' 'buttonTypeGroupBox ' Me.buttonTypeGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.rad Me.buttonTypeGroupBox.Location = New System.Drawing.Point(16, 16) Me.buttonTypeGroupBox.Name = "buttonTypeGroupBox" Me.buttonTypeGroupBox.Size = New System.Drawing.Size(144, 216) Me.buttonTypeGroupBox.TabIndex = 2 Me.buttonTypeGroupBox.TabStop = False Me.buttonTypeGroupBox.Text = "Button Type" ' 'radRetryCancel ' Me.radRetryCancel.Location = New System.Drawing.Point(16, 192) Me.radRetryCancel.Name = "radRetryCancel" Me.radRetryCancel.Size = New System.Drawing.Size(104, 16) Me.radRetryCancel.TabIndex = 5 Me.radRetryCancel.Text = "RetryCancel" ' 'radOkCancel ' Me.radOkCancel.Location = New System.Drawing.Point(16, 56) Me.radOkCancel.Name = "radOkCancel" Me.radOkCancel.Size = New System.Drawing.Size(120, 24) Me.radOkCancel.TabIndex = 1 Me.radOkCancel.Text = "OKCancel" ' 'FrmRadioButton ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(384, 333) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblDisplay, Me.iconGro Me.Name = "FrmRadioButton" Me.Text = "RadioButtonTest" Me.iconGroupBox.ResumeLayout(False) Me.buttonTypeGroupBox.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub cmdDisplay_Click(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles cmdDisplay.Click Dim dialog As DialogResult = MessageBox.Show( _ "Your message", "Title", _ buttonType, iconType) Select Case dialog Case DialogResult.OK lblDisplay.Text = "OK was pressed" Case DialogResult.Cancel lblDisplay.Text = "Cancel was pressed" Case DialogResult.Abort lblDisplay.Text = "Abort was pressed" Case DialogResult.Retry lblDisplay.Text = "Retry was pressed"

Case DialogResult.Ignore lblDisplay.Text = "Ignore was pressed" Case DialogResult.Yes lblDisplay.Text = "Yes was pressed" Case DialogResult.No lblDisplay.Text = "No was pressed" End Select End Sub ' cmdDisplay_Click Private Sub radOk_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radOk.CheckedChanged buttonType = MessageBoxButtons.OK End Sub Private Sub radOkCancel_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radOkCancel.CheckedChanged buttonType = MessageBoxButtons.OKCancel End Sub Private Sub radAbortRetryIgnore_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radAbortRetryIgnore.CheckedChanged buttonType = MessageBoxButtons.AbortRetryIgnore End Sub Private Sub radYesNoCancel_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radYesNoCancel.CheckedChanged buttonType = MessageBoxButtons.YesNoCancel End Sub Private Sub radYesNo_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radYesNo.CheckedChanged buttonType = MessageBoxButtons.YesNo End Sub Private Sub radRetryCancel_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radRetryCancel.CheckedChanged buttonType = MessageBoxButtons.RetryCancel End Sub Private Sub radAsterisk_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radAsterisk.CheckedChanged iconType = MessageBoxIcon.Asterisk End Sub

Private Sub radError_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radError.CheckedChanged iconType = MessageBoxIcon.Error End Sub Private Sub radExclamation_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radExclamation.CheckedChanged iconType = MessageBoxIcon.Exclamation End Sub Private Sub radHand_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radHand.CheckedChanged iconType = MessageBoxIcon.Hand End Sub Private Sub radInformation_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radInformation.CheckedChanged iconType = MessageBoxIcon.Information End Sub Private Sub radQuestion_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radQuestion.CheckedChanged iconType = MessageBoxIcon.Question End Sub Private Sub radStop_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radStop.CheckedChanged iconType = MessageBoxIcon.Stop End Sub Private Sub radWarning_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radWarning.CheckedChanged iconType = MessageBoxIcon.Warning End Sub End Class

Custom MESSAGEBOX dvs.

Imports Imports Imports Imports Imports

System.IO System.Text.Encoding System.Drawing System.Drawing.Printing System.Windows.Forms

public class CustomMessageBox public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Private Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend componente WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents Ca System.ComponentModel.IContainer

Label1 As System.Windows.Forms.Label btnShow As System.Windows.Forms.Button txtMsg As System.Windows.Forms.TextBox txtCaption As System.Windows.Forms.TextBox Label2 As System.Windows.Forms.Label grpDefaultButton As System.Windows.Forms.GroupBox DefaultButton3 As System.Windows.Forms.RadioButton DefaultButton2 As System.Windows.Forms.RadioButton DefaultButton1 As System.Windows.Forms.RadioButton GroupBox2 As System.Windows.Forms.GroupBox Button6 As System.Windows.Forms.RadioButton

Friend WithEvents Button5 As System.Windows.Forms.RadioButton Friend WithEvents Button4 As System.Windows.Forms.RadioButton Friend WithEvents Button3 As System.Windows.Forms.RadioButton Friend WithEvents Button2 As System.Windows.Forms.RadioButton Friend WithEvents Button1 As System.Windows.Forms.RadioButton Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents txtResult As System.Windows.Forms.TextBox Friend WithEvents lblResult As System.Windows.Forms.Label Friend WithEvents Icon8 As System.Windows.Forms.RadioButton Friend WithEvents Icon7 As System.Windows.Forms.RadioButton Friend WithEvents Icon6 As System.Windows.Forms.RadioButton Friend WithEvents Icon5 As System.Windows.Forms.RadioButton Friend WithEvents Icon4 As System.Windows.Forms.RadioButton Friend WithEvents Icon3 As System.Windows.Forms.RadioButton Friend WithEvents Icon2 As System.Windows.Forms.RadioButton Friend WithEvents Icon1 As System.Windows.Forms.RadioButton <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.txtMsg = New System.Windows.Forms.TextBox() Me.Label1 = New System.Windows.Forms.Label() Me.btnShow = New System.Windows.Forms.Button() Me.txtCaption = New System.Windows.Forms.TextBox() Me.Label2 = New System.Windows.Forms.Label() Me.grpDefaultButton = New System.Windows.Forms.GroupBox() Me.DefaultButton3 = New System.Windows.Forms.RadioButton() Me.DefaultButton2 = New System.Windows.Forms.RadioButton() Me.DefaultButton1 = New System.Windows.Forms.RadioButton() Me.GroupBox2 = New System.Windows.Forms.GroupBox() Me.Button6 = New System.Windows.Forms.RadioButton() Me.Button5 = New System.Windows.Forms.RadioButton() Me.Button4 = New System.Windows.Forms.RadioButton() Me.Button3 = New System.Windows.Forms.RadioButton() Me.Button2 = New System.Windows.Forms.RadioButton() Me.Button1 = New System.Windows.Forms.RadioButton() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.Icon8 = New System.Windows.Forms.RadioButton() Me.Icon7 = New System.Windows.Forms.RadioButton() Me.Icon6 = New System.Windows.Forms.RadioButton() Me.Icon5 = New System.Windows.Forms.RadioButton() Me.Icon4 = New System.Windows.Forms.RadioButton() Me.Icon3 = New System.Windows.Forms.RadioButton() Me.Icon2 = New System.Windows.Forms.RadioButton() Me.Icon1 = New System.Windows.Forms.RadioButton() Me.txtResult = New System.Windows.Forms.TextBox() Me.lblResult = New System.Windows.Forms.Label() Me.grpDefaultButton.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'txtMsg ' Me.txtMsg.Location = New System.Drawing.Point(68, 8) Me.txtMsg.Name = "txtMsg" Me.txtMsg.Size = New System.Drawing.Size(200, 22) Me.txtMsg.TabIndex = 0 Me.txtMsg.Text = "" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(12, 12) Me.Label1.Name = "Label1"

Me.Label1.Size = New System.Drawing.Size(60, 16) Me.Label1.TabIndex = 13 Me.Label1.Text = "Message:" ' 'btnShow ' Me.btnShow.Location = New System.Drawing.Point(280, 8) Me.btnShow.Name = "btnShow" Me.btnShow.Size = New System.Drawing.Size(76, 24) Me.btnShow.TabIndex = 5 Me.btnShow.Text = "Show" ' 'txtCaption ' Me.txtCaption.Location = New System.Drawing.Point(68, 36) Me.txtCaption.Name = "txtCaption" Me.txtCaption.Size = New System.Drawing.Size(200, 22) Me.txtCaption.TabIndex = 1 Me.txtCaption.Text = "" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(12, 40) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(60, 16) Me.Label2.TabIndex = 16 Me.Label2.Text = "Caption:" ' 'grpDefaultButton ' Me.grpDefaultButton.Controls.AddRange(New System.Windows.Forms.Control() {Me.Default Me.grpDefaultButton.Location = New System.Drawing.Point(208, 72) Me.grpDefaultButton.Name = "grpDefaultButton" Me.grpDefaultButton.Size = New System.Drawing.Size(144, 124) Me.grpDefaultButton.TabIndex = 4 Me.grpDefaultButton.TabStop = False Me.grpDefaultButton.Text = "Default Button" ' 'DefaultButton3 ' Me.DefaultButton3.Location = New System.Drawing.Point(12, 68) Me.DefaultButton3.Name = "DefaultButton3" Me.DefaultButton3.Size = New System.Drawing.Size(100, 20) Me.DefaultButton3.TabIndex = 2 Me.DefaultButton3.Text = "DefaultButton3" ' 'DefaultButton2 ' Me.DefaultButton2.Location = New System.Drawing.Point(12, 44) Me.DefaultButton2.Name = "DefaultButton2" Me.DefaultButton2.Size = New System.Drawing.Size(100, 20) Me.DefaultButton2.TabIndex = 1 Me.DefaultButton2.Text = "DefaultButton2" ' 'DefaultButton1 ' Me.DefaultButton1.Checked = True Me.DefaultButton1.Location = New System.Drawing.Point(12, 20) Me.DefaultButton1.Name = "DefaultButton1" Me.DefaultButton1.Size = New System.Drawing.Size(100, 20) Me.DefaultButton1.TabIndex = 0

Me.DefaultButton1.TabStop = True Me.DefaultButton1.Text = "DefaultButton1" ' 'GroupBox2 ' Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button6, Me.Bu Me.GroupBox2.Location = New System.Drawing.Point(12, 200) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(188, 160) Me.GroupBox2.TabIndex = 3 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Buttons" ' 'Button6 ' Me.Button6.Location = New System.Drawing.Point(12, 133) Me.Button6.Name = "Button6" Me.Button6.Size = New System.Drawing.Size(100, 19) Me.Button6.TabIndex = 5 Me.Button6.Text = "YesNoCancel" ' 'Button5 ' Me.Button5.Checked = True Me.Button5.Location = New System.Drawing.Point(12, 110) Me.Button5.Name = "Button5" Me.Button5.Size = New System.Drawing.Size(100, 20) Me.Button5.TabIndex = 4 Me.Button5.TabStop = True Me.Button5.Text = "YesNo" ' 'Button4 ' Me.Button4.Location = New System.Drawing.Point(12, 86) Me.Button4.Name = "Button4" Me.Button4.Size = New System.Drawing.Size(100, 21) Me.Button4.TabIndex = 3 Me.Button4.Text = "RetryCancel" ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(12, 65) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(100, 18) Me.Button3.TabIndex = 2 Me.Button3.Text = "OKCancel" ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(12, 43) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(100, 19) Me.Button2.TabIndex = 1 Me.Button2.Text = "OK" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(12, 20) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(112, 20) Me.Button1.TabIndex = 0

Me.Button1.Text = "AbortRetryIgnore" ' 'GroupBox1 ' Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Icon8, Me.Icon Me.GroupBox1.Location = New System.Drawing.Point(12, 72) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(188, 124) Me.GroupBox1.TabIndex = 2 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Icon" ' 'Icon8 ' Me.Icon8.Location = New System.Drawing.Point(100, 92) Me.Icon8.Name = "Icon8" Me.Icon8.Size = New System.Drawing.Size(64, 20) Me.Icon8.TabIndex = 7 Me.Icon8.Text = "Warning" ' 'Icon7 ' Me.Icon7.Location = New System.Drawing.Point(12, 92) Me.Icon7.Name = "Icon7" Me.Icon7.Size = New System.Drawing.Size(84, 20) Me.Icon7.TabIndex = 6 Me.Icon7.Text = "Stop" ' 'Icon6 ' Me.Icon6.Location = New System.Drawing.Point(100, 68) Me.Icon6.Name = "Icon6" Me.Icon6.Size = New System.Drawing.Size(64, 20) Me.Icon6.TabIndex = 5 Me.Icon6.Text = "Question" ' 'Icon5 ' Me.Icon5.Checked = True Me.Icon5.Location = New System.Drawing.Point(12, 68) Me.Icon5.Name = "Icon5" Me.Icon5.Size = New System.Drawing.Size(84, 20) Me.Icon5.TabIndex = 4 Me.Icon5.TabStop = True Me.Icon5.Text = "Information" ' 'Icon4 ' Me.Icon4.Location = New System.Drawing.Point(100, 44) Me.Icon4.Name = "Icon4" Me.Icon4.Size = New System.Drawing.Size(64, 20) Me.Icon4.TabIndex = 3 Me.Icon4.Text = "Hand" ' 'Icon3 ' Me.Icon3.Location = New System.Drawing.Point(12, 44) Me.Icon3.Name = "Icon3" Me.Icon3.Size = New System.Drawing.Size(84, 20) Me.Icon3.TabIndex = 2 Me.Icon3.Text = "Exclamation"

' 'Icon2 ' Me.Icon2.Location = New System.Drawing.Point(100, 20) Me.Icon2.Name = "Icon2" Me.Icon2.Size = New System.Drawing.Size(64, 20) Me.Icon2.TabIndex = 1 Me.Icon2.Text = "Error" ' 'Icon1 ' Me.Icon1.Location = New System.Drawing.Point(12, 20) Me.Icon1.Name = "Icon1" Me.Icon1.Size = New System.Drawing.Size(84, 20) Me.Icon1.TabIndex = 0 Me.Icon1.Text = "Asterisk" ' 'txtResult ' Me.txtResult.Enabled = False Me.txtResult.Location = New System.Drawing.Point(212, 232) Me.txtResult.Name = "txtResult" Me.txtResult.Size = New System.Drawing.Size(136, 22) Me.txtResult.TabIndex = 18 Me.txtResult.Text = "" ' 'lblResult ' Me.lblResult.Location = New System.Drawing.Point(212, 208) Me.lblResult.Name = "lblResult" Me.lblResult.Size = New System.Drawing.Size(56, 20) Me.lblResult.TabIndex = 17 Me.lblResult.Text = "Result" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15) Me.ClientSize = New System.Drawing.Size(368, 369) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.grpDefaultButton, Me.Gro Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "MessageBox Application" Me.grpDefaultButton.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.GroupBox1.ResumeLayout(False) Me.ResumeLayout(False) End Sub Privat iIcon Ca Integer Private iButton Ca Integer Private iDefaultButton Ca Integer Private Sub btnShow_Click ( ByVal expeditor Dim iResult Ca Integer Ca System.Object, ByVal e ca

System.E

iResult = MessageBox.Show ( Me, txtMsg.Text, txtCaption.Text, iButton, iIcon, iDefau Selectai Case iResult caz DialogResult.Abort

txtResult.Text = "DialogResult.Abort" Cazul DialogResult.Retry txtResult.Text = "DialogResult.Retry" Cazul DialogResult.Ignore txtResult.Text = "DialogResult.Ignore" Cazul DialogResult.OK txtResult.Text = "DialogResult.OK" Cazul DialogResult.Cancel txtResult.Text = "DialogResult.Cancel" caz DialogResult.Yes txtResult.Text = "DialogResult.Yes" caz DialogResult.No txtResult.Text = "DialogResult.No" End Selectai End Sub Private Sub AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler Form1_Load ( Icon1.Click, Icon2.Click, Icon3.Click, Icon4.Click, Icon5.Click, Icon6.Click, Icon7.Click, Icon8.Click, ByVal expeditor Ca System.Object, ByVal e AddressOf Icon_Click AddressOf Icon_Click AddressOf Icon_Click AddressOf Icon_Click AddressOf Icon_Click AddressOf Icon_Click AddressOf Icon_Click AddressOf Icon_Click AddressOf AddressOf AddressOf AddressOf AddressOf AddressOf Button_Click Button_Click Button_Click Button_Click Button_Click Button_Click ca

System.Even

Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click,

AddHandler DefaultButton1.Click, AddressOf DefaultButton_Click AddHandler DefaultButton2.Click, AddressOf DefaultButton_Click AddHandler DefaultButton3.Click, AddressOf DefaultButton_Click iIcon = MessageBoxIcon.Information iButton = MessageBoxButtons.YesNo iDefaultButton = MessageBoxDefaultButton.Button1 End Sub Public Sub Icon_Click ( expeditor ByVal Selectati Cazul sender.Name Cazul "icon1" iIcon = MessageBoxIcon.Asterisk Cazul "icon2" iIcon = MessageBoxIcon.Error Cazul "icon3" iIcon = MessageBoxIcon.Exclamation Cazul " icon4 " iIcon = MessageBoxIcon.Hand Cazul "Icon5" iIcon = MessageBoxIcon.Information Cazul "Icon6" iIcon = MessageBoxIcon.Question Cazul "Icon7" iIcon = MessageBoxIcon.Stop Cazul "Icon8" iIcon = MessageBoxIcon.Warning End Select Ca obiect, ByVal e ca System.EventArgs )

End Sub Public Sub Button_Click ( expeditor ByVal Ca obiect, ByVal e Selectati Cazul sender.Name Cazul "Button1" iButton = MessageBoxButtons.AbortRetryIgnore Cazul "Button2" iButton = MessageBoxButtons.OK Cazul "button3" iButton = MessageBoxButtons.OKCancel Cazul " Button4 " iButton = MessageBoxButtons.RetryCancel Cazul "Button5" iButton = MessageBoxButtons.YesNo Cazul "Button6" iButton = MessageBoxButtons.YesNoCancel End Selectai End Sub ca System.EventArgs

Public Sub DefaultButton_Click ( expeditor ByVal Ca obiect, ByVal e Selectati Cazul sender.Name Cazul "DefaultButton1" iDefaultButton = MessageBoxDefaultButton.Button1 Cazul "DefaultButton2" iDefaultButton = MessageBoxDefaultButton.Button2 Cazul "DefaultButton3" iDefaultButton = MessageBoxDefaultButton.Button3 End Selectai End Sub End Class

ca

System.Eve

Original

Custom your MessageBox

Imports Imports Imports Imports Imports

System.IO System.Text.Encoding System.Drawing System.Drawing.Printing System.Windows.Forms

public class CustomMessageBox public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Private components As System.ComponentModel.IContainer Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents Label1 As System.Windows.Forms.Label btnShow As System.Windows.Forms.Button txtMsg As System.Windows.Forms.TextBox txtCaption As System.Windows.Forms.TextBox Label2 As System.Windows.Forms.Label grpDefaultButton As System.Windows.Forms.GroupBox DefaultButton3 As System.Windows.Forms.RadioButton DefaultButton2 As System.Windows.Forms.RadioButton DefaultButton1 As System.Windows.Forms.RadioButton GroupBox2 As System.Windows.Forms.GroupBox Button6 As System.Windows.Forms.RadioButton

Friend WithEvents Button5 As System.Windows.Forms.RadioButton Friend WithEvents Button4 As System.Windows.Forms.RadioButton Friend WithEvents Button3 As System.Windows.Forms.RadioButton Friend WithEvents Button2 As System.Windows.Forms.RadioButton Friend WithEvents Button1 As System.Windows.Forms.RadioButton Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents txtResult As System.Windows.Forms.TextBox Friend WithEvents lblResult As System.Windows.Forms.Label Friend WithEvents Icon8 As System.Windows.Forms.RadioButton Friend WithEvents Icon7 As System.Windows.Forms.RadioButton Friend WithEvents Icon6 As System.Windows.Forms.RadioButton Friend WithEvents Icon5 As System.Windows.Forms.RadioButton Friend WithEvents Icon4 As System.Windows.Forms.RadioButton Friend WithEvents Icon3 As System.Windows.Forms.RadioButton Friend WithEvents Icon2 As System.Windows.Forms.RadioButton Friend WithEvents Icon1 As System.Windows.Forms.RadioButton <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.txtMsg = New System.Windows.Forms.TextBox() Me.Label1 = New System.Windows.Forms.Label() Me.btnShow = New System.Windows.Forms.Button() Me.txtCaption = New System.Windows.Forms.TextBox() Me.Label2 = New System.Windows.Forms.Label() Me.grpDefaultButton = New System.Windows.Forms.GroupBox() Me.DefaultButton3 = New System.Windows.Forms.RadioButton() Me.DefaultButton2 = New System.Windows.Forms.RadioButton() Me.DefaultButton1 = New System.Windows.Forms.RadioButton() Me.GroupBox2 = New System.Windows.Forms.GroupBox() Me.Button6 = New System.Windows.Forms.RadioButton() Me.Button5 = New System.Windows.Forms.RadioButton() Me.Button4 = New System.Windows.Forms.RadioButton() Me.Button3 = New System.Windows.Forms.RadioButton() Me.Button2 = New System.Windows.Forms.RadioButton() Me.Button1 = New System.Windows.Forms.RadioButton() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.Icon8 = New System.Windows.Forms.RadioButton() Me.Icon7 = New System.Windows.Forms.RadioButton() Me.Icon6 = New System.Windows.Forms.RadioButton() Me.Icon5 = New System.Windows.Forms.RadioButton() Me.Icon4 = New System.Windows.Forms.RadioButton() Me.Icon3 = New System.Windows.Forms.RadioButton() Me.Icon2 = New System.Windows.Forms.RadioButton() Me.Icon1 = New System.Windows.Forms.RadioButton() Me.txtResult = New System.Windows.Forms.TextBox() Me.lblResult = New System.Windows.Forms.Label() Me.grpDefaultButton.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'txtMsg ' Me.txtMsg.Location = New System.Drawing.Point(68, 8) Me.txtMsg.Name = "txtMsg" Me.txtMsg.Size = New System.Drawing.Size(200, 22) Me.txtMsg.TabIndex = 0 Me.txtMsg.Text = "" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(12, 12) Me.Label1.Name = "Label1"

Me.Label1.Size = New System.Drawing.Size(60, 16) Me.Label1.TabIndex = 13 Me.Label1.Text = "Message:" ' 'btnShow ' Me.btnShow.Location = New System.Drawing.Point(280, 8) Me.btnShow.Name = "btnShow" Me.btnShow.Size = New System.Drawing.Size(76, 24) Me.btnShow.TabIndex = 5 Me.btnShow.Text = "Show" ' 'txtCaption ' Me.txtCaption.Location = New System.Drawing.Point(68, 36) Me.txtCaption.Name = "txtCaption" Me.txtCaption.Size = New System.Drawing.Size(200, 22) Me.txtCaption.TabIndex = 1 Me.txtCaption.Text = "" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(12, 40) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(60, 16) Me.Label2.TabIndex = 16 Me.Label2.Text = "Caption:" ' 'grpDefaultButton ' Me.grpDefaultButton.Controls.AddRange(New System.Windows.Forms.Control() {Me.Default Me.grpDefaultButton.Location = New System.Drawing.Point(208, 72) Me.grpDefaultButton.Name = "grpDefaultButton" Me.grpDefaultButton.Size = New System.Drawing.Size(144, 124) Me.grpDefaultButton.TabIndex = 4 Me.grpDefaultButton.TabStop = False Me.grpDefaultButton.Text = "Default Button" ' 'DefaultButton3 ' Me.DefaultButton3.Location = New System.Drawing.Point(12, 68) Me.DefaultButton3.Name = "DefaultButton3" Me.DefaultButton3.Size = New System.Drawing.Size(100, 20) Me.DefaultButton3.TabIndex = 2 Me.DefaultButton3.Text = "DefaultButton3" ' 'DefaultButton2 ' Me.DefaultButton2.Location = New System.Drawing.Point(12, 44) Me.DefaultButton2.Name = "DefaultButton2" Me.DefaultButton2.Size = New System.Drawing.Size(100, 20) Me.DefaultButton2.TabIndex = 1 Me.DefaultButton2.Text = "DefaultButton2" ' 'DefaultButton1 ' Me.DefaultButton1.Checked = True Me.DefaultButton1.Location = New System.Drawing.Point(12, 20) Me.DefaultButton1.Name = "DefaultButton1" Me.DefaultButton1.Size = New System.Drawing.Size(100, 20) Me.DefaultButton1.TabIndex = 0

Me.DefaultButton1.TabStop = True Me.DefaultButton1.Text = "DefaultButton1" ' 'GroupBox2 ' Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button6, Me.Bu Me.GroupBox2.Location = New System.Drawing.Point(12, 200) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(188, 160) Me.GroupBox2.TabIndex = 3 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Buttons" ' 'Button6 ' Me.Button6.Location = New System.Drawing.Point(12, 133) Me.Button6.Name = "Button6" Me.Button6.Size = New System.Drawing.Size(100, 19) Me.Button6.TabIndex = 5 Me.Button6.Text = "YesNoCancel" ' 'Button5 ' Me.Button5.Checked = True Me.Button5.Location = New System.Drawing.Point(12, 110) Me.Button5.Name = "Button5" Me.Button5.Size = New System.Drawing.Size(100, 20) Me.Button5.TabIndex = 4 Me.Button5.TabStop = True Me.Button5.Text = "YesNo" ' 'Button4 ' Me.Button4.Location = New System.Drawing.Point(12, 86) Me.Button4.Name = "Button4" Me.Button4.Size = New System.Drawing.Size(100, 21) Me.Button4.TabIndex = 3 Me.Button4.Text = "RetryCancel" ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(12, 65) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(100, 18) Me.Button3.TabIndex = 2 Me.Button3.Text = "OKCancel" ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(12, 43) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(100, 19) Me.Button2.TabIndex = 1 Me.Button2.Text = "OK" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(12, 20) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(112, 20) Me.Button1.TabIndex = 0

Me.Button1.Text = "AbortRetryIgnore" ' 'GroupBox1 ' Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Icon8, Me.Icon Me.GroupBox1.Location = New System.Drawing.Point(12, 72) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(188, 124) Me.GroupBox1.TabIndex = 2 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Icon" ' 'Icon8 ' Me.Icon8.Location = New System.Drawing.Point(100, 92) Me.Icon8.Name = "Icon8" Me.Icon8.Size = New System.Drawing.Size(64, 20) Me.Icon8.TabIndex = 7 Me.Icon8.Text = "Warning" ' 'Icon7 ' Me.Icon7.Location = New System.Drawing.Point(12, 92) Me.Icon7.Name = "Icon7" Me.Icon7.Size = New System.Drawing.Size(84, 20) Me.Icon7.TabIndex = 6 Me.Icon7.Text = "Stop" ' 'Icon6 ' Me.Icon6.Location = New System.Drawing.Point(100, 68) Me.Icon6.Name = "Icon6" Me.Icon6.Size = New System.Drawing.Size(64, 20) Me.Icon6.TabIndex = 5 Me.Icon6.Text = "Question" ' 'Icon5 ' Me.Icon5.Checked = True Me.Icon5.Location = New System.Drawing.Point(12, 68) Me.Icon5.Name = "Icon5" Me.Icon5.Size = New System.Drawing.Size(84, 20) Me.Icon5.TabIndex = 4 Me.Icon5.TabStop = True Me.Icon5.Text = "Information" ' 'Icon4 ' Me.Icon4.Location = New System.Drawing.Point(100, 44) Me.Icon4.Name = "Icon4" Me.Icon4.Size = New System.Drawing.Size(64, 20) Me.Icon4.TabIndex = 3 Me.Icon4.Text = "Hand" ' 'Icon3 ' Me.Icon3.Location = New System.Drawing.Point(12, 44) Me.Icon3.Name = "Icon3" Me.Icon3.Size = New System.Drawing.Size(84, 20) Me.Icon3.TabIndex = 2 Me.Icon3.Text = "Exclamation"

' 'Icon2 ' Me.Icon2.Location = New System.Drawing.Point(100, 20) Me.Icon2.Name = "Icon2" Me.Icon2.Size = New System.Drawing.Size(64, 20) Me.Icon2.TabIndex = 1 Me.Icon2.Text = "Error" ' 'Icon1 ' Me.Icon1.Location = New System.Drawing.Point(12, 20) Me.Icon1.Name = "Icon1" Me.Icon1.Size = New System.Drawing.Size(84, 20) Me.Icon1.TabIndex = 0 Me.Icon1.Text = "Asterisk" ' 'txtResult ' Me.txtResult.Enabled = False Me.txtResult.Location = New System.Drawing.Point(212, 232) Me.txtResult.Name = "txtResult" Me.txtResult.Size = New System.Drawing.Size(136, 22) Me.txtResult.TabIndex = 18 Me.txtResult.Text = "" ' 'lblResult ' Me.lblResult.Location = New System.Drawing.Point(212, 208) Me.lblResult.Name = "lblResult" Me.lblResult.Size = New System.Drawing.Size(56, 20) Me.lblResult.TabIndex = 17 Me.lblResult.Text = "Result" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15) Me.ClientSize = New System.Drawing.Size(368, 369) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.grpDefaultButton, Me.Gro Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "MessageBox Application" Me.grpDefaultButton.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.GroupBox1.ResumeLayout(False) Me.ResumeLayout(False) End Sub Private iIcon As Integer Private iButton As Integer Private iDefaultButton As Integer Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim iResult As Integer

iResult = MessageBox.Show(Me,txtMsg.Text, txtCaption.Text, iButton, iIcon, iDefaultB Select Case iResult Case DialogResult.Abort

txtResult.Text = "DialogResult.Abort" Case DialogResult.Retry txtResult.Text = "DialogResult.Retry" Case DialogResult.Ignore txtResult.Text = "DialogResult.Ignore" Case DialogResult.OK txtResult.Text = "DialogResult.OK" Case DialogResult.Cancel txtResult.Text = "DialogResult.Cancel" Case DialogResult.Yes txtResult.Text = "DialogResult.Yes" Case DialogResult.No txtResult.Text = "DialogResult.No" End Select End Sub Private Sub Form1_Load(ByVal sender AddHandler Icon1.Click, AddressOf AddHandler Icon2.Click, AddressOf AddHandler Icon3.Click, AddressOf AddHandler Icon4.Click, AddressOf AddHandler Icon5.Click, AddressOf AddHandler Icon6.Click, AddressOf AddHandler Icon7.Click, AddressOf AddHandler Icon8.Click, AddressOf AddHandler AddHandler AddHandler AddHandler AddHandler AddHandler Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click,

As System.Object, ByVal e As System.EventArgs) Han Icon_Click Icon_Click Icon_Click Icon_Click Icon_Click Icon_Click Icon_Click Icon_Click Button_Click Button_Click Button_Click Button_Click Button_Click Button_Click

AddressOf AddressOf AddressOf AddressOf AddressOf AddressOf

AddHandler DefaultButton1.Click, AddressOf DefaultButton_Click AddHandler DefaultButton2.Click, AddressOf DefaultButton_Click AddHandler DefaultButton3.Click, AddressOf DefaultButton_Click iIcon = MessageBoxIcon.Information iButton = MessageBoxButtons.YesNo iDefaultButton = MessageBoxDefaultButton.Button1 End Sub Public Sub Icon_Click(ByVal sender As Object, ByVal e As System.EventArgs) Select Case sender.Name Case "Icon1" iIcon = MessageBoxIcon.Asterisk Case "Icon2" iIcon = MessageBoxIcon.Error Case "Icon3" iIcon = MessageBoxIcon.Exclamation Case "Icon4" iIcon = MessageBoxIcon.Hand Case "Icon5" iIcon = MessageBoxIcon.Information Case "Icon6" iIcon = MessageBoxIcon.Question Case "Icon7" iIcon = MessageBoxIcon.Stop Case "Icon8" iIcon = MessageBoxIcon.Warning End Select

End Sub Public Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Select Case sender.Name Case "Button1" iButton = MessageBoxButtons.AbortRetryIgnore Case "Button2" iButton = MessageBoxButtons.OK Case "Button3" iButton = MessageBoxButtons.OKCancel Case "Button4" iButton = MessageBoxButtons.RetryCancel Case "Button5" iButton = MessageBoxButtons.YesNo Case "Button6" iButton = MessageBoxButtons.YesNoCancel End Select End Sub Public Sub DefaultButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Select Case sender.Name Case "DefaultButton1" iDefaultButton = MessageBoxDefaultButton.Button1 Case "DefaultButton2" iDefaultButton = MessageBoxDefaultButton.Button2 Case "DefaultButton3" iDefaultButton = MessageBoxDefaultButton.Button3 End Select End Sub End Class

Create MESSAGEBOX dinamic

Importurile

System.Windows.Forms

public class MessageBoxCreateDy public comun Sub principal Application.Run ( New frmMessageBox ) End Sub End clasa Public class frmMessageBox Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Ca apel

Boole

WithEvents prieten grpPromptandTitle Ca System.Windows.Forms.GroupBox prieten WithEvents GroupBox1 Ca System.Windows.Forms.GroupBox prieten WithEvents btnShow Ca System.Windows.Forms.Button prieten WithEvents PANOU1 Ca System.Windows.Forms.Panel prieten WithEvents Splitter1 Ca sistem . Windows.Forms.Splitter prieten WithEvents Panou2 Ca System.Windows.Forms.Panel prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents txtText Ca System.Windows.Forms.TextBox prieten WithEvents txtCaption Ca System.Windows.Forms.TextBox Prietenul WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents rdoOKOnly Ca System.Windows.Forms.RadioButton prieten WithEvents Label3 Ca System.Windows.Forms.Label prieten WithEvents rdoAbRetry Ca System.Windows.Forms.RadioButton prieten WithEvents rdoError Ca sistem. Windows.Forms.RadioButton prieten WithEvents rdoExclamation Ca System.Windows.Forms.RadioButton prieten WithEvents rdoRetryCancel Ca System.Windows.Forms.RadioButton prieten WithEvents rdoInformation Ca System.Windows.Forms.RadioButton prieten WithEvents rdoYesNo Ca System.Windows.Forms.RadioButton prieten WithEvents rdoYesNoCancel Ca System.Windows.Forms.RadioButton prieten WithEvents rdoOKCancel Ca System.Windows.Forms.RadioButton prieten WithEvents Label4 Ca System.Windows.Forms.Label prieten WithEvents rdoNoIcon Ca System.Windows.Forms.RadioButton prieten WithEvents rdoQuestion Ca System.Windows . Forms.RadioButton "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . grpPromptandTitle = New System.Windows.Forms.GroupBox () Me.GroupBox1 = New System.Windows.Forms.GroupBox () Me.btnShow = New System.Windows.Forms.Button () Me.Panel1 = New System.Windows. Forms.Panel () Me.Splitter1 = New System.Windows.Forms.Splitter () Me.Panel2 = New System.Windows.Forms.Panel () Me.Label1 = New System.Windows.Forms.Label () Me.txtText = New System.Windows.Forms.TextBox () Me.txtCaption = New System.Windows.Forms.TextBox () Me.Label2 = New System.Windows.Forms.Label () Me.rdoOKOnly = System.Windows.Forms noi. RadioButon () Me.Label3 = New System.Windows.Forms.Label () Me.rdoAbRetry = New System.Windows.Forms.RadioButton () Me.rdoError = New System.Windows.Forms.RadioButton () Me.rdoExclamation = Nou System.Windows.Forms.RadioButton () Me.rdoRetryCancel = New System.Windows.Forms.RadioButton () Me.rdoInformation = New System.Windows.Forms.RadioButton () Me.rdoYesNo = New System.Windows.Forms.RadioButton ( ) Me.rdoYesNoCancel = New System.Windows.Forms.RadioButton () Me.rdoOKCancel = New System.Windows.Forms.RadioButton () Me.Label4 = New System.Windows.Forms.Label () Me.rdoNoIcon = Sistem. Windows.Forms.RadioButton () Me.rdoQuestion = Nou

System.Windows.Forms.Control () { Me.txtCaption, Me.Label2, Me.txtText, Me.Label1 Me.grpPromptandTitle.Dock = System.Windows.Forms.DockStyle.Top Me.grpPromptandTitle.Name = "grpPromptandTitle " Me.grpPromptandTitle.Size = New System.Drawing.Size ( 456 , 112 ) Me.grpPromptandTitle.TabIndex = 0 Me.grpPromptandTitle.TabStop = false Me.grpPromptandTitle.Text = "Introducei textul i legenda:" " "Gr. oupBox1 " Me.GroupBox1.Controls.AddRange ( New System.Windows.Forms.Control () { Me.btnShow Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.Bottom Me.GroupBox1.Location = New System.Drawing . Punctul ( 0 , 350 ) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size ( 456 , 48 ) Me.GroupBox1.TabIndex = 3 Me.GroupBox1.TabStop = False ' 'bt nShow ' Me.btnShow.Location = New System.Drawing.Point ( 328 , 16 ) Me.btnShow.Name = "btnShow" Me.btnShow.Size = New System.Drawing.Size ( 96 , 24 ) Me.btnShow.TabIndex = 0 Me.btnShow.Text = "SHOW" " "Pa nel1 " Me.Panel1.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Label3, Me. Me.Panel1.Dock = System.Windows.Forms.DockStyle.Left Me.Panel1.Location = New System.Drawing.Point ( 0 , 112 ) Me.Panel1. name = "PANOU1" Me.Panel1.Size = New System.Drawing.Size ( 200 , 238 ) Me.Panel1.TabIndex = 1 ' 'Sp litter1 ' Me.Splitter1.Location = New System.Drawing.Point ( 200 , 112 ) Me.Splitter1.Name = "Splitter1" Me.Splitter1.Size = New System.Drawing.Size ( 3 , 238 ) Me.Splitter1.TabIndex = 3 Me.Splitter1.TabStop = False ' 'Pa NEL2 " Me.Panel2. Controls.AddRange ( New System.Windows.Forms.Control () { Me.Label4, Me Me.Panel2.Dock = System.Windows. Forms.DockStyle.Fill Me.Panel2.Location = New System.Drawing.Point ( 203 , 112 ) Me.Panel2.Name = "Panou2" Me.Panel2.Size = New System.Drawing.Size ( 253 , 238 ) Eu. Panel2.TabIndex = 2 ' 'La bel1 ' Me.Label1.Location = New System.Drawing.Point ( 16 , 24 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 64 , 24 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "text:" "

"TX tText ' Me.txtText.Location = New System.Drawing.Point ( 104 , 24 ) Me.txtText.Name = "txtText " Me.txtText.Size = New System.Drawing.Size ( 320 , 20 ) Me.txtText.TabIndex = 0 Me.txtText.Text = "" ' 'TX tCaption ' Me.txtCaption.Location = New System.Drawing.Point ( 104 , 64 ) Me.txtCaption.Name = "txtCaption" Me.txtCaption.Size = New System.Drawing.Size ( 320 , 20 ) Me.txtCaption.TabIndex = 1 Me.txtCaption.Text = "" " "La bel2 " Me.Label2.Location = New System.Drawing.Point ( 16 , 64 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 64 , 24 ) Me.Label2.TabIndex = 0 Me.Label2.Text = "Caption:" " "RD oOKOnly ' Me.rdoOKOnly.Checked = True Me.rdoOKOnly.Location = New System.Drawing.Point ( 8 , 40 ) Me.rdoOKOnly.Name = "rdoOKOnly" Me . rdoOKOnly.Size = New System.Drawing.Size ( 160 , 24 ) Me.rdoOKOnly.TabIndex = 2 Me.rdoOKOnly.TabStop = True Me.rdoOKOnly.Text = "Ok Numai" " "La bel3 " Me.Label3.Font = New System.Drawing.Font ( "Sans Serif Microsoft" , Me.Label3.Location = New System.Drawing . Punct ( 24 , 8 ) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size ( 104 , 24 ) Me.Label3.TabIndex = 0 Me.Label3.Text = "Butoane" " "RD oAbRetry ' Me.rdoAbRetry.Location = New System.Drawing.Point ( 8 , 104 ) Me.rdoAbRetry.Name = "rdoAbRetry" Me.rdoAbRetry.Size = New System.Drawing.Size ( 160 , 24 ) Me.rdoAbRetry tabindex =. 4 Me.rdoAbRetry.Text = "Abort, Retry, Ignore", " "RD oError ' Me.rdoError.Checked = True Me.rdoError.Location = New System.Drawing.Point ( 24 , 40 ) Me.rdoError. name = "rdoError" Me.rdoError.Size = New System.Drawing.Size ( 88 , 32 ) Me.rdoError.TabIndex = 1 Me.rdoError.TabStop = True Me.rdoError.Text = "Eroare" "

8,25 !, Syste

"RD oExclamation " Me.rdoExclamation.Location = New System.Drawing.Point ( 24 , 112 ) Me.rdoExclamation.Name = "rdoExclamation" Me.rdoExclamation.Size = New System.Drawing.Size ( 88 , 32 ) Me.rdoExclamation.TabIndex = 3 Me.rdoExclamation.Text = "exclamare" " "RD oRetryCancel ' Me.rdoRetryCancel.Location = New System.Drawing.Point ( 8 , 200 ) Me.rdoRetryCancel.Name = "rdoRetryCancel" Me.rdoRetryCancel.Size = New System.Drawing . Dimensiune ( 160 , 24 ) Me.rdoRetryCancel.TabIndex = 0 Me.rdoRetryCancel.Text = "Rencercare i Revocare" " "RD oInformation ' Me.rdoInformation.Location = New System.Drawing.Point ( 136 , 40 ) Me.rdoInformation . Nume = "rdoInformation" Me.rdoInformation.Size = New System.Drawing.Size ( 88 , 32 ) Me.rdoInformation.TabIndex = 4 Me.rdoInformation.Text = "Informaii" " "RD oYesNo ' Me.rdoYesNo.Location = New System.Drawing.Point ( 8 , 168 ) Me.rdoYesNo.Name = "rdoYesNo" Me.rdoYesNo.Size = New System.Drawing.Size ( 160 , 24 ) Me.rdoYesNo.TabIndex = 6 Me.rdoYesNo.Text = "Da i Nu" " "RD oYesNoCancel ' Me.rdoYesNoCancel.Location = New System.Drawing.Point ( 8 , 136 ) Me.rdoYesNoCancel.Name = "rdoYesNoCancel" Me.rdoYesNoCancel.Size = New System.Drawing.Size ( 160 , 24 ) Me.rdoYesNoCancel.TabIndex = 5 Me.rdoYesNoCancel.Text = "Da, Nu, Cancel" " "RD oOKCancel ' Me.rdoOKCancel.Location = New System.Drawing.Point ( 8 , 72 ) Me.rdoOKCancel.Name = "rdoOKCancel" Me.rdoOKCancel.Size = New System.Drawing.Size ( 160 , 24 ) Me.rdoOKCancel.TabIndex = 3 Me.rdoOKCancel.Text = "OK i Cancel" " "La bel4 ' Me.Label4.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 8,25 !, Syste Me.Label4.Location = New System.Drawing. punctul ( 24 , 8 ) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size ( 80 , 24 ) Me.Label4.TabIndex = 0 Me.Label4.Text = "Icon" " " RD oNoIcon ' Me.rdoNoIcon.Location = New System.Drawing.Point ( 136 , 80 ) Me.rdoNoIcon.Name = "rdoNoIcon"

Me.rdoNoIcon.Size = New System.Drawing.Size ( 88 , 32 ) Me.rdoNoIcon. tabindex = 5 Me.rdoNoIcon.Text = "Nu Icoana" " "RD oQuestion ' Me.rdoQuestion.Location = New System.Drawing.Point ( 24 , 80 ) Me.rdoQuestion.Name = "rdoQuestion" Me.rdoQuestion.Size = New System.Drawing.Size ( 88 , 32 ) Me.rdoQuestion.TabIndex = 2 Me.rdoQuestion.Text = "ntrebare" " "fr mMessageBox ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 456 , 398 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Panel2, Me.Splitte Me.Name = "frmMessageBox" Me.Text = "Nu Cutia de mesaje

End Sub # End Regiunea Sub btnShow_Click ( expeditor ByVal buttonchoice Ca MessageBoxButtons iconchoice Ca MessageBoxIcon rspuns Ca DialogResult Ca obiect, ByVal e ca

Private Dim Dim Dim

System.EventAr

Dac rdoOKOnly.Checked = True Apoi buttonchoice = MessageBoxButtons.OK elseif rdoOKCancel.Checked = True Apoi buttonchoice = MessageBoxButtons.OKCancel elseif rdoAbRetry.Checked = True Apoi buttonchoice = MessageBoxButtons.AbortRetryIgnore elseif rdoYesNoCancel.Checked = True Apoi buttonchoice = MessageBoxButtons.YesNoCancel elseif rdoYesNo . Bagajul = True Apoi buttonchoice = MessageBoxButtons.YesNo elseif rdoRetryCancel.Checked = True Apoi buttonchoice = MessageBoxButtons.RetryCancel Else MessageBox.Show ( "Eroare neateptat n butonul de selecie!" ) End If Dac rdoError.Checked = True Apoi iconchoice = MessageBoxIcon.Error elseif rdoQuestion.Checked = True Apoi iconchoice = MessageBoxIcon.Question elseif rdoExclamation.Checked = True Apoi iconchoice = MessageBoxIcon.Exclamation elseif rdoInformation.Checked = True Apoi iconchoice = MessageBoxIcon.Information elseif rdoNoIcon . Bagajul = True Apoi iconchoice = MessageBoxIcon.None

Else MessageBox.Show ( "Eroare neateptat n selectarea icoana!" ) End If answer = MessageBox.Show ( txtText.Text, txtCaption.Text, _ buttonchoice, iconchoice ) Dim evalua Ca String Dac answer = DialogResult.OK Apoi evalua = "Ai fcut clic pe OK!" elseif answer = DialogResult.Cancel Apoi evalua = "Ai fcut clic Cancel!" rspuns elseif = DialogResult.Abort Apoi evalua = "Ai fcut clic Abort!" elseif answer = DialogResult.Retry Apoi evalua = "Ai fcut clic Rencercai!" elseif answer = DialogResult.Ignore Apoi evalua = "Ai fcut clic ignora!" elseif answer = DialogResult.Yes Apoi evalua = "Ai fcut clic Da!" elseif answer = DialogResult.No Apoi evalua = "Ai fcut clic Nu!" Altfel evalua = "Nimic nu a fost fcut clic!" End If MessageBox.Show ( evalueze, "Message Box de evaluare" , _ MessageBoxButtons.OK, MessageBoxIcon.Information ) End Sub End Class

Original

Create MessageBox dynamically

Imports System.Windows.Forms public class MessageBoxCreateDy public Shared Sub Main Application.Run(New frmMessageBox) End Sub End class Public Class frmMessageBox Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend

WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents

grpPromptandTitle As System.Windows.Forms.GroupBox GroupBox1 As System.Windows.Forms.GroupBox btnShow As System.Windows.Forms.Button Panel1 As System.Windows.Forms.Panel Splitter1 As System.Windows.Forms.Splitter Panel2 As System.Windows.Forms.Panel Label1 As System.Windows.Forms.Label txtText As System.Windows.Forms.TextBox txtCaption As System.Windows.Forms.TextBox Label2 As System.Windows.Forms.Label rdoOKOnly As System.Windows.Forms.RadioButton Label3 As System.Windows.Forms.Label rdoAbRetry As System.Windows.Forms.RadioButton rdoError As System.Windows.Forms.RadioButton rdoExclamation As System.Windows.Forms.RadioButton rdoRetryCancel As System.Windows.Forms.RadioButton rdoInformation As System.Windows.Forms.RadioButton rdoYesNo As System.Windows.Forms.RadioButton rdoYesNoCancel As System.Windows.Forms.RadioButton rdoOKCancel As System.Windows.Forms.RadioButton Label4 As System.Windows.Forms.Label rdoNoIcon As System.Windows.Forms.RadioButton rdoQuestion As System.Windows.Forms.RadioButton

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.grpPromptandTitle = New System.Windows.Forms.GroupBox() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.btnShow = New System.Windows.Forms.Button() Me.Panel1 = New System.Windows.Forms.Panel() Me.Splitter1 = New System.Windows.Forms.Splitter() Me.Panel2 = New System.Windows.Forms.Panel() Me.Label1 = New System.Windows.Forms.Label() Me.txtText = New System.Windows.Forms.TextBox() Me.txtCaption = New System.Windows.Forms.TextBox() Me.Label2 = New System.Windows.Forms.Label() Me.rdoOKOnly = New System.Windows.Forms.RadioButton() Me.Label3 = New System.Windows.Forms.Label() Me.rdoAbRetry = New System.Windows.Forms.RadioButton() Me.rdoError = New System.Windows.Forms.RadioButton() Me.rdoExclamation = New System.Windows.Forms.RadioButton() Me.rdoRetryCancel = New System.Windows.Forms.RadioButton() Me.rdoInformation = New System.Windows.Forms.RadioButton() Me.rdoYesNo = New System.Windows.Forms.RadioButton() Me.rdoYesNoCancel = New System.Windows.Forms.RadioButton() Me.rdoOKCancel = New System.Windows.Forms.RadioButton() Me.Label4 = New System.Windows.Forms.Label() Me.rdoNoIcon = New System.Windows.Forms.RadioButton() Me.rdoQuestion = New System.Windows.Forms.RadioButton() Me.grpPromptandTitle.SuspendLayout() Me.GroupBox1.SuspendLayout() Me.Panel1.SuspendLayout() Me.Panel2.SuspendLayout() Me.SuspendLayout() ' 'grpPromptandTitle

' Me.grpPromptandTitle.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtC Me.grpPromptandTitle.Dock = System.Windows.Forms.DockStyle.Top Me.grpPromptandTitle.Name = "grpPromptandTitle" Me.grpPromptandTitle.Size = New System.Drawing.Size(456, 112) Me.grpPromptandTitle.TabIndex = 0 Me.grpPromptandTitle.TabStop = False Me.grpPromptandTitle.Text = "Enter your text and caption:" ' 'GroupBox1 ' Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnShow}) Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.Bottom Me.GroupBox1.Location = New System.Drawing.Point(0, 350) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(456, 48) Me.GroupBox1.TabIndex = 3 Me.GroupBox1.TabStop = False ' 'btnShow ' Me.btnShow.Location = New System.Drawing.Point(328, 16) Me.btnShow.Name = "btnShow" Me.btnShow.Size = New System.Drawing.Size(96, 24) Me.btnShow.TabIndex = 0 Me.btnShow.Text = "SHOW" ' 'Panel1 ' Me.Panel1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.rdoR Me.Panel1.Dock = System.Windows.Forms.DockStyle.Left Me.Panel1.Location = New System.Drawing.Point(0, 112) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(200, 238) Me.Panel1.TabIndex = 1 ' 'Splitter1 ' Me.Splitter1.Location = New System.Drawing.Point(200, 112) Me.Splitter1.Name = "Splitter1" Me.Splitter1.Size = New System.Drawing.Size(3, 238) Me.Splitter1.TabIndex = 3 Me.Splitter1.TabStop = False ' 'Panel2 ' Me.Panel2.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label4, Me.rdoE Me.Panel2.Dock = System.Windows.Forms.DockStyle.Fill Me.Panel2.Location = New System.Drawing.Point(203, 112) Me.Panel2.Name = "Panel2" Me.Panel2.Size = New System.Drawing.Size(253, 238) Me.Panel2.TabIndex = 2 ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(16, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(64, 24) Me.Label1.TabIndex = 0 Me.Label1.Text = "Text:" '

'txtText ' Me.txtText.Location = New System.Drawing.Point(104, 24) Me.txtText.Name = "txtText" Me.txtText.Size = New System.Drawing.Size(320, 20) Me.txtText.TabIndex = 0 Me.txtText.Text = "" ' 'txtCaption ' Me.txtCaption.Location = New System.Drawing.Point(104, 64) Me.txtCaption.Name = "txtCaption" Me.txtCaption.Size = New System.Drawing.Size(320, 20) Me.txtCaption.TabIndex = 1 Me.txtCaption.Text = "" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(16, 64) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(64, 24) Me.Label2.TabIndex = 0 Me.Label2.Text = "Caption:" ' 'rdoOKOnly ' Me.rdoOKOnly.Checked = True Me.rdoOKOnly.Location = New System.Drawing.Point(8, 40) Me.rdoOKOnly.Name = "rdoOKOnly" Me.rdoOKOnly.Size = New System.Drawing.Size(160, 24) Me.rdoOKOnly.TabIndex = 2 Me.rdoOKOnly.TabStop = True Me.rdoOKOnly.Text = "Ok Only" ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Dra Me.Label3.Location = New System.Drawing.Point(24, 8) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(104, 24) Me.Label3.TabIndex = 0 Me.Label3.Text = "Buttons" ' 'rdoAbRetry ' Me.rdoAbRetry.Location = New System.Drawing.Point(8, 104) Me.rdoAbRetry.Name = "rdoAbRetry" Me.rdoAbRetry.Size = New System.Drawing.Size(160, 24) Me.rdoAbRetry.TabIndex = 4 Me.rdoAbRetry.Text = "Abort, Retry, Ignore" ' 'rdoError ' Me.rdoError.Checked = True Me.rdoError.Location = New System.Drawing.Point(24, 40) Me.rdoError.Name = "rdoError" Me.rdoError.Size = New System.Drawing.Size(88, 32) Me.rdoError.TabIndex = 1 Me.rdoError.TabStop = True Me.rdoError.Text = "Error" '

'rdoExclamation ' Me.rdoExclamation.Location = New System.Drawing.Point(24, 112) Me.rdoExclamation.Name = "rdoExclamation" Me.rdoExclamation.Size = New System.Drawing.Size(88, 32) Me.rdoExclamation.TabIndex = 3 Me.rdoExclamation.Text = "Exclamation" ' 'rdoRetryCancel ' Me.rdoRetryCancel.Location = New System.Drawing.Point(8, 200) Me.rdoRetryCancel.Name = "rdoRetryCancel" Me.rdoRetryCancel.Size = New System.Drawing.Size(160, 24) Me.rdoRetryCancel.TabIndex = 0 Me.rdoRetryCancel.Text = "Retry and Cancel" ' 'rdoInformation ' Me.rdoInformation.Location = New System.Drawing.Point(136, 40) Me.rdoInformation.Name = "rdoInformation" Me.rdoInformation.Size = New System.Drawing.Size(88, 32) Me.rdoInformation.TabIndex = 4 Me.rdoInformation.Text = "Information" ' 'rdoYesNo ' Me.rdoYesNo.Location = New System.Drawing.Point(8, 168) Me.rdoYesNo.Name = "rdoYesNo" Me.rdoYesNo.Size = New System.Drawing.Size(160, 24) Me.rdoYesNo.TabIndex = 6 Me.rdoYesNo.Text = "Yes and No" ' 'rdoYesNoCancel ' Me.rdoYesNoCancel.Location = New System.Drawing.Point(8, 136) Me.rdoYesNoCancel.Name = "rdoYesNoCancel" Me.rdoYesNoCancel.Size = New System.Drawing.Size(160, 24) Me.rdoYesNoCancel.TabIndex = 5 Me.rdoYesNoCancel.Text = "Yes, No, Cancel" ' 'rdoOKCancel ' Me.rdoOKCancel.Location = New System.Drawing.Point(8, 72) Me.rdoOKCancel.Name = "rdoOKCancel" Me.rdoOKCancel.Size = New System.Drawing.Size(160, 24) Me.rdoOKCancel.TabIndex = 3 Me.rdoOKCancel.Text = "Ok and Cancel" ' 'Label4 ' Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Dra Me.Label4.Location = New System.Drawing.Point(24, 8) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(80, 24) Me.Label4.TabIndex = 0 Me.Label4.Text = "Icon" ' 'rdoNoIcon ' Me.rdoNoIcon.Location = New System.Drawing.Point(136, 80) Me.rdoNoIcon.Name = "rdoNoIcon"

Me.rdoNoIcon.Size = New System.Drawing.Size(88, 32) Me.rdoNoIcon.TabIndex = 5 Me.rdoNoIcon.Text = "No Icon" ' 'rdoQuestion ' Me.rdoQuestion.Location = New System.Drawing.Point(24, 80) Me.rdoQuestion.Name = "rdoQuestion" Me.rdoQuestion.Size = New System.Drawing.Size(88, 32) Me.rdoQuestion.TabIndex = 2 Me.rdoQuestion.Text = "Question" ' 'frmMessageBox ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(456, 398) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Panel2, Me.Splitter1, Me.Name = "frmMessageBox" Me.Text = "Do the Message Box thing!" Me.grpPromptandTitle.ResumeLayout(False) Me.GroupBox1.ResumeLayout(False) Me.Panel1.ResumeLayout(False) Me.Panel2.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region

Private Sub btnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handle Dim buttonchoice As MessageBoxButtons Dim iconchoice As MessageBoxIcon Dim answer As DialogResult If rdoOKOnly.Checked = True Then buttonchoice = MessageBoxButtons.OK ElseIf rdoOKCancel.Checked = True Then buttonchoice = MessageBoxButtons.OKCancel ElseIf rdoAbRetry.Checked = True Then buttonchoice = MessageBoxButtons.AbortRetryIgnore ElseIf rdoYesNoCancel.Checked = True Then buttonchoice = MessageBoxButtons.YesNoCancel ElseIf rdoYesNo.Checked = True Then buttonchoice = MessageBoxButtons.YesNo ElseIf rdoRetryCancel.Checked = True Then buttonchoice = MessageBoxButtons.RetryCancel Else MessageBox.Show("Unexpected error in button selection!") End If If rdoError.Checked = True Then iconchoice = MessageBoxIcon.Error ElseIf rdoQuestion.Checked = True Then iconchoice = MessageBoxIcon.Question ElseIf rdoExclamation.Checked = True Then iconchoice = MessageBoxIcon.Exclamation ElseIf rdoInformation.Checked = True Then iconchoice = MessageBoxIcon.Information ElseIf rdoNoIcon.Checked = True Then iconchoice = MessageBoxIcon.None

Else MessageBox.Show("Unexpected error in icon selection!") End If answer = MessageBox.Show(txtText.Text, txtCaption.Text, _ buttonchoice, iconchoice) Dim evaluate As String If answer = DialogResult.OK Then evaluate = "You clicked OK!" ElseIf answer = DialogResult.Cancel Then evaluate = "You clicked Cancel!" ElseIf answer = DialogResult.Abort Then evaluate = "You clicked Abort!" ElseIf answer = DialogResult.Retry Then evaluate = "You clicked Retry!" ElseIf answer = DialogResult.Ignore Then evaluate = "You clicked Ignore!" ElseIf answer = DialogResult.Yes Then evaluate = "You clicked Yes!" ElseIf answer = DialogResult.No Then evaluate = "You clicked No!" Else evaluate = "Nothing was clicked!" End If MessageBox.Show(evaluate, "Message Box Evaluation", _ MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub End Class

Get selectat RadioButon

Opiunea stricte cu privire la Importurile System.Windows.Forms

public class RadioButtonState public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Motenete # Region Form1 System.Windows.Forms.Form

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub prieten WithEvents GroupBox1 Ca System.Windows.Forms.GroupBox prieten WithEvents RadioButton1 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton2 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton3 Ca System.Windows.Forms.RadioButton prieten WithEvents Button1 Ca sistem . Windows.Forms.Button "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . GroupBox1 = New System.Windows.Forms.GroupBox () Me.RadioButton3 = New System.Windows.Forms.RadioButton () Me.RadioButton2 = New System.Windows.Forms.RadioButton () Me.RadioButton1 = New System.Windows. Forms.RadioButton () Me.Button1 = Nou Ca apel

Boole

System.Windows.Forms.Control () { Me.RadioButton3, Me.RadioButton2, Me.RadioButton Me.GroupBox1.Location = New System.Drawing.Point ( 40 , 32 ) Me.GroupBox1.Name = "GroupBox1" Me . GroupBox1.Size = New System.Drawing.Size ( 240 , 160 ) Me.GroupBox1.TabIndex = 0 Me.GroupBox1.TabStop = false Me.GroupBox1.Text = "Alege un buton:" "

"Ra dioButton3 " Me.RadioButton3 . Locaia = New System.Drawing.Point ( 40 , 104 ) Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.Size = New System.Drawing.Size ( 144 , 24 ) Me.RadioButton3.TabIndex = 2 Me.RadioButton3 . Text = "RadioButton3" " "Ra dioButton2 ' Me.RadioButton2.Location = New System.Drawing.Point ( 40 , 64 ) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.Size = New System.Drawing.Size ( 144 , 24 ) Me.RadioButton2.TabIndex = 1 Me.RadioButton2.Text = "RadioButton2" " "Ra dioButton1 ' Me.RadioButton1.Checked = True Me.RadioButton1.Location = New System.Drawing.Point ( 40 , 32 ) Me . RadioButton1.Name = "RadioButton1" Me.RadioButton1.Size = New System.Drawing.Size ( 144 , 24 ) Me.RadioButton1.TabIndex = 0 Me.RadioButton1.TabStop = True Me.RadioButton1.Text = "RadioButton1" " " bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 56 , 216 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 168 , 23 ) Me.Button1. tabindex = 1 = Me.Button1.Text ", care este selectata?" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 266 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.Button1, Me.GroupB Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout ( Fals ) Me. ResumeLayout ( Fals ) End Sub # End Regiunea

Private Sub RadioButton1_CheckedChanged ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere RadioButton1.CheckedChanged, _ RadioButton2.CheckedChanged, RadioButton3.CheckedChanged End Sub Private Sub Button1_Click ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere Button1.Click Dim c Ca obiect pentru fiecare c n Me.GroupBox1.Controls Dac typeof ( c ) Este RadioButon Apoi Dim rb Ca RadioButon = Ctype ( c , RadioButon ) Dac rb.Checked = True Apoi MsgBox ( CStr ( rb.Name ) i "selectat" )

Exit Pentru End Dac End Dac Urmtor End Sub End Class

Original

Option Strict On Imports System.Windows.Forms public class RadioButtonState public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton Friend WithEvents Button1 As System.Windows.Forms.Button 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.RadioButton3 = New System.Windows.Forms.RadioButton() Me.RadioButton2 = New System.Windows.Forms.RadioButton() Me.RadioButton1 = New System.Windows.Forms.RadioButton() Me.Button1 = New System.Windows.Forms.Button() Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'GroupBox1 ' Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.RadioButton3 Me.GroupBox1.Location = New System.Drawing.Point(40, 32) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(240, 160) Me.GroupBox1.TabIndex = 0 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Choose a button:" ' 'RadioButton3 ' Me.RadioButton3.Location = New System.Drawing.Point(40, 104) Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.Size = New System.Drawing.Size(144, 24) Me.RadioButton3.TabIndex = 2 Me.RadioButton3.Text = "RadioButton3" ' 'RadioButton2 ' Me.RadioButton2.Location = New System.Drawing.Point(40, 64) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.Size = New System.Drawing.Size(144, 24) Me.RadioButton2.TabIndex = 1 Me.RadioButton2.Text = "RadioButton2" ' 'RadioButton1 ' Me.RadioButton1.Checked = True Me.RadioButton1.Location = New System.Drawing.Point(40, 32) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.Size = New System.Drawing.Size(144, 24)

Me.RadioButton1.TabIndex = 0 Me.RadioButton1.TabStop = True Me.RadioButton1.Text = "RadioButton1" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(56, 216) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(168, 23) Me.Button1.TabIndex = 1 Me.Button1.Text = "Which is Selected?" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.GroupBox1} Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub RadioButton1_CheckedChanged(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged, _ RadioButton2.CheckedChanged, RadioButton3.CheckedChanged End Sub Private Sub Button1_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim c As Object For Each c In Me.GroupBox1.Controls If TypeOf (c) Is RadioButton Then Dim rb As RadioButton = CType(c, RadioButton) If rb.Checked = True Then MsgBox(CStr(rb.Name) & " is selected") Exit For End If End If Next End Sub End Class

Using RadioButtons pentru a seta opiunile de fereastra de mesaj.

Importurile

System.Windows.Forms

public class RadioButtonAction public comun Sub principal Application.Run ( New FrmRadioButton ) End Sub End clasa Public class FrmRadioButton Motenete System.Windows.Forms.Form Privat iconType Ca MessageBoxIcon private buttonType Ca MessageBoxButtons # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub prieten WithEvents iconGroupBox Ca System.Windows.Forms.GroupBox prieten WithEvents buttonTypeGroupBox Ca System.Windows.Forms.GroupBox Ca apel

Boole

prieten WithEvents radRetryCancel Ca System.Windows.Forms.RadioButton prieten WithEvents radYesNo Ca System.Windows.Forms.RadioButton prieten WithEvents radAbortRetryIgnore Ca sistem . Windows.Forms.RadioButton prieten WithEvents Radok Ca System.Windows.Forms.RadioButton prieten WithEvents radWarning Ca System.Windows.Forms.RadioButton prieten WithEvents radStop Ca System.Windows.Forms.RadioButton prieten WithEvents radQuestion Ca System.Windows.Forms.RadioButton Prietenul WithEvents radInformation Ca System.Windows.Forms.RadioButton prieten WithEvents radHand Ca System.Windows.Forms.RadioButton prieten WithEvents radExclamation Ca System.Windows.Forms.RadioButton prieten WithEvents radError Ca System.Windows.Forms.RadioButton prieten WithEvents radAsterisk Ca sistem. Windows.Forms.RadioButton prieten WithEvents cmdDisplay Ca System.Windows.Forms.Button prieten WithEvents lblDisplay Ca System.Windows.Forms.Label prieten WithEvents radOkCancel Ca System.Windows.Forms.RadioButton prieten WithEvents radYesNoCancel Ca System.Windows.Forms.RadioButton "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . radAbortRetryIgnore = New System.Windows.Forms.RadioButton () Me.radStop = New System.Windows.Forms.RadioButton () Me.radYesNo = New System.Windows.Forms.RadioButton () Me.iconGroupBox = New System.Windows. Forms.GroupBox () Me.radWarning = New System.Windows.Forms.RadioButton () Me.radQuestion = New System.Windows.Forms.RadioButton () Me.radInformation = New System.Windows.Forms.RadioButton () Me.radHand = New System.Windows.Forms.RadioButton () Me.radExclamation = New System.Windows.Forms.RadioButton () Me.radError = New System.Windows.Forms.RadioButton () Me.radAsterisk = System.Windows.Forms noi. RadioButon () Me.radYesNoCancel = New System.Windows.Forms.RadioButton () Me.radOk = New System.Windows.Forms.RadioButton () Me.cmdDisplay = New System.Windows.Forms.Button () Me.lblDisplay = Nou System.Windows.Forms.Label () Me.buttonTypeGroupBox = New System.Windows.Forms.GroupBox () Me.radRetryCancel = New System.Windows.Forms.RadioButton () Me.radOkCancel = Nou

= New System.Drawing.Point ( 16 , 88 ) Me.radAbortRetryIgnore.Name = "radAbortRetryIgnore" Me.radAbortRetryIgnore.Size = New System.Drawing.Size ( 120 , Me.radAbortRetryIgnore.TabIndex = 2 Me.radAbortRetryIgnore.Text = "AbortRetryIgnore" " "ra dStop ' Me.radStop.Location = New System.Drawing.Point ( 16 , 240 ) Me.radStop.Name = "radStop" Me.radStop.Size = New System.Drawing.Size ( 128 , 24 ) Me.radStop.TabIndex = 6 Me.radStop.Text = "Stop"

24 )

" "ra dYesNo ' Me.radYesNo.Location = New System.Drawing.Point ( 16 , 160 ) Me.radYesNo.Name = "radYesNo" Me radYesNo.Size = New System.Drawing.Size. ( 120 , 16 ) Me.radYesNo.TabIndex = 4 Me.radYesNo.Text = "YesNo" " "IC onGroupBox " Me.iconGroupBox.Controls.AddRange ( New System.Windows. Forms.Control () { Me.radW Me.iconGroupBox.Location = New System.Drawing. punct ( 200 , 16 ) Me.iconGroupBox.Name = "iconGroupBox" Me.iconGroupBox.Size = New System.Drawing.Size ( 160 , 304 ) Me.iconGroupBox.TabIndex = 3 Me.iconGroupBox.TabStop = false Me.iconGroupBox. Text = "Icon" " "ra dWarning ' Me.radWarning.Location = New System.Drawing.Point ( 16 , 272 ) Me.radWarning.Name = "radWarning" Me.radWarning.Size = New System.Drawing.Size ( 128 , 24 ) Me.radWarning.TabIndex = 7 Me.radWarning.Text = "Avertisment" " "ra dQuestion ' Me.radQuestion.Location = New System.Drawing.Point ( 16 , 208 ) Me.radQuestion.Name = "radQuestion" Me.radQuestion.Size = New System.Drawing.Size ( 128 , 24 ) Me.radQuestion.TabIndex = 5 Me.radQuestion.Text = "ntrebare" " "ra dInformation ' Me.radInformation.Location = New System.Drawing.Point ( 16 , 168 ) Me.radInformation.Name = "radInformation" Me.radInformation.Size = New System.Drawing.Size ( 128 , 24 ) Me.radInformation.TabIndex = 4 Me.radInformation.Text = "Informaii" " "ra dHand ' Me.radHand.Location = New System.Drawing.Point ( 16 , 128 ) Me.radHand.Name = "radHand" Me.radHand.Size = New System.Drawing.Size ( 128 , 24 ) Me.radHand.TabIndex = 3 Me.radHand.Text = "Hand" " "ra dExclamation ' Me.radExclamation.Location = New System.Drawing.Point ( 16 , 88 ) Me.radExclamation.Name = "radExclamation" Me.radExclamation.Size = Sistem . Drawing.Size ( 136 , 24 ) Me.radExclamation.TabIndex = 2 Me.radExclamation.Text = "exclamare" " "ra dError '

Me.radError.Location = New System.Drawing.Point ( 16 , 48 ) Me.radError . Nume = "radError" Me.radError.Size = New System.Drawing.Size ( 136 , 24 ) Me.radError.TabIndex = 1 Me.radError.Text = "Eroare" " "ra dAsterisk ' Me.radAsterisk.Location = New System.Drawing.Point ( 16 , 16 ) Me.radAsterisk.Name = "radAsterisk" Me.radAsterisk.Size = New System.Drawing.Size ( 136 , 24 ) Me.radAsterisk.TabIndex = 0 Me.radAsterisk.Text = "Asterisk" " "ra dYesNoCancel ' Me.radYesNoCancel.Location = New System.Drawing.Point ( 16 , 120 ) Me.radYesNoCancel.Name = "radYesNoCancel" Me.radYesNoCancel.Size = New System.Drawing.Size ( 120 , 24 ) Me.radYesNoCancel.TabIndex = 3 Me.radYesNoCancel.Text = "YesNoCancel" " "ra DOK " Me.radOk.Location = New System.Drawing.Point ( 16 , 24 ) Me.radOk.Name = "Radok" Me. radOk.Size = New System.Drawing.Size ( 112 , 16 ) Me.radOk.TabIndex = 0 Me.radOk.Text = "OK" " "cm dDisplay ' Me.cmdDisplay.Location = New System.Drawing.Point ( 32 , 240 ) Me.cmdDisplay.Name = "cmdDisplay" Me.cmdDisplay.Size = New System.Drawing.Size ( 112 , 40 ) Me.cmdDisplay.TabIndex = 1 Me.cmdDisplay.Text = "Display" " 'lb lDisplay " Me.lblDisplay.Location = New System.Drawing.Point ( 24 , 296 ) Me.lblDisplay.Name = "lblDisplay" Me.lblDisplay.Size = New System.Drawing.Size ( 144 , 24 ) Me.lblDisplay.TabIndex = 5 " "bu ttonTypeGroupBox " Me.buttonTypeGroupBox.Controls.AddRange ( New System.Windows.Forms.Control () { Me Me . buttonTypeGroupBox.Location = New System.Drawing.Point ( 16 , 16 ) Me.buttonTypeGroupBox.Name = "buttonTypeGroupBox" Me.buttonTypeGroupBox.Size = New System.Drawing.Size ( 144 , 216 ) Me.buttonTypeGroupBox.TabIndex = 2 Me buttonTypeGroupBox.TabStop = Fals. Me.buttonTypeGroupBox.Text = "Butonul de tip" " "ra dRetryCancel ' Me.radRetryCancel.Location = New System.Drawing.Point ( 16 , 192 ) Me.radRetryCancel.Name = "radRetryCancel" Me.radRetryCancel . Dimensiune = New System.Drawing.Size ( 104 , 16 ) Me.radRetryCancel.TabIndex = 5

Me.radRetryCancel.Text = "RetryCancel" " "ra dOkCancel ' Me.radOkCancel.Location = New System.Drawing.Point ( 16 , 56 ) Me.radOkCancel.Name = "radOkCancel" Me.radOkCancel.Size = New System.Drawing.Size ( 120 , 24 ) Me.radOkCancel.TabIndex = 1 Me.radOkCancel.Text = "OKCancel" ' "Parintele mRadioButton " Me . AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 384 , 333 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.lblDisplay, Me.ico Me.Name = "FrmRadioButton" Me.Text

End Sub # End Regiunea _ _

Private Sub cmdDisplay_Click ( ByVal expeditor _ Ca System.Object, ByVal e ca System.EventArgs ) Manere cmdDisplay.Click Dim dialog Ca DialogResult = MessageBox.Show ( "Mesajul dvs." , "Titlu" , _ buttonType, iconType )

Selectai Case de dialog caz DialogResult.OK lblDisplay.Text = "OK a fost apsat" Cazul DialogResult.Cancel lblDisplay.Text = "Cancel a fost apsat" Cazul DialogResult.Abort lblDisplay.Text = "ntrerupe a fost apsat" Cazul DialogResult.Retry lblDisplay.Text = "Rencercai a fost apsat" Cazul DialogResult.Ignore lblDisplay.Text = "Ignor a fost apsat" Cazul DialogResult.Yes lblDisplay.Text = "Da a fost apsat" Cazul DialogResult.No lblDisplay.Text = "Nu a fost apsat" End Select End Sub 'c mdDisplay_Click _

Private Sub radOk_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) Manere radOk.CheckedChanged buttonType = MessageBoxButtons.OK

End Sub Private Sub radOkCancel_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radOkCancel.CheckedChanged buttonType = MessageBoxButtons.OKCancel End Sub Private Sub radAbortRetryIgnore_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radAbortRetryIgnore.CheckedChanged buttonType = MessageBoxButtons.AbortRetryIgnore End Sub Private Sub radYesNoCancel_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radYesNoCancel.CheckedChanged buttonType = MessageBoxButtons.YesNoCancel End Sub Private Sub radYesNo_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radYesNo.CheckedChanged buttonType = MessageBoxButtons.YesNo End Sub Private Sub radRetryCancel_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radRetryCancel.CheckedChanged buttonType = MessageBoxButtons.RetryCancel End Sub Private Sub radAsterisk_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radAsterisk.CheckedChanged iconType = MessageBoxIcon.Asterisk End Sub Private Sub radError_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radError.CheckedChanged iconType = MessageBoxIcon.Error End Sub Private Sub radExclamation_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radExclamation.CheckedChanged iconType = MessageBoxIcon.Exclamation End Sub Private Sub radHand_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radHand.CheckedChanged

iconType = MessageBoxIcon.Hand End Sub Private Sub radInformation_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radInformation.CheckedChanged iconType = MessageBoxIcon.Information End Sub Private Sub radQuestion_CheckedChanged ( _ expeditor ByVal Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radQuestion.CheckedChanged iconType = MessageBoxIcon.Question End Sub Private Sub radStop_CheckedChanged ( ByVal _ expeditor Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radStop.CheckedChanged iconType = MessageBoxIcon.Stop End Sub Private Sub radWarning_CheckedChanged ( expeditor ByVal _ Ca System.Object, ByVal e ca System.EventArgs ) _ Manere radWarning.CheckedChanged iconType = MessageBoxIcon.Warning End Sub End Class

Original

Imports System.Windows.Forms public class RadioButtonAction public Shared Sub Main Application.Run(New FrmRadioButton) End Sub End class Public Class FrmRadioButton Inherits System.Windows.Forms.Form Private iconType As MessageBoxIcon Private buttonType As MessageBoxButtons #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents iconGroupBox As System.Windows.Forms.GroupBox Friend WithEvents buttonTypeGroupBox As System.Windows.Forms.GroupBox

Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend Friend

WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents

radRetryCancel As System.Windows.Forms.RadioButton radYesNo As System.Windows.Forms.RadioButton radAbortRetryIgnore As System.Windows.Forms.RadioButton radOk As System.Windows.Forms.RadioButton radWarning As System.Windows.Forms.RadioButton radStop As System.Windows.Forms.RadioButton radQuestion As System.Windows.Forms.RadioButton radInformation As System.Windows.Forms.RadioButton radHand As System.Windows.Forms.RadioButton radExclamation As System.Windows.Forms.RadioButton radError As System.Windows.Forms.RadioButton radAsterisk As System.Windows.Forms.RadioButton cmdDisplay As System.Windows.Forms.Button lblDisplay As System.Windows.Forms.Label radOkCancel As System.Windows.Forms.RadioButton radYesNoCancel As System.Windows.Forms.RadioButton

'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.radAbortRetryIgnore = New System.Windows.Forms.RadioButton() Me.radStop = New System.Windows.Forms.RadioButton() Me.radYesNo = New System.Windows.Forms.RadioButton() Me.iconGroupBox = New System.Windows.Forms.GroupBox() Me.radWarning = New System.Windows.Forms.RadioButton() Me.radQuestion = New System.Windows.Forms.RadioButton() Me.radInformation = New System.Windows.Forms.RadioButton() Me.radHand = New System.Windows.Forms.RadioButton() Me.radExclamation = New System.Windows.Forms.RadioButton() Me.radError = New System.Windows.Forms.RadioButton() Me.radAsterisk = New System.Windows.Forms.RadioButton() Me.radYesNoCancel = New System.Windows.Forms.RadioButton() Me.radOk = New System.Windows.Forms.RadioButton() Me.cmdDisplay = New System.Windows.Forms.Button() Me.lblDisplay = New System.Windows.Forms.Label() Me.buttonTypeGroupBox = New System.Windows.Forms.GroupBox() Me.radRetryCancel = New System.Windows.Forms.RadioButton() Me.radOkCancel = New System.Windows.Forms.RadioButton() Me.iconGroupBox.SuspendLayout() Me.buttonTypeGroupBox.SuspendLayout() Me.SuspendLayout() ' 'radAbortRetryIgnore ' Me.radAbortRetryIgnore.Location = New System.Drawing.Point(16, 88) Me.radAbortRetryIgnore.Name = "radAbortRetryIgnore" Me.radAbortRetryIgnore.Size = New System.Drawing.Size(120, 24) Me.radAbortRetryIgnore.TabIndex = 2 Me.radAbortRetryIgnore.Text = "AbortRetryIgnore" ' 'radStop ' Me.radStop.Location = New System.Drawing.Point(16, 240) Me.radStop.Name = "radStop" Me.radStop.Size = New System.Drawing.Size(128, 24) Me.radStop.TabIndex = 6 Me.radStop.Text = "Stop"

' 'radYesNo ' Me.radYesNo.Location = New System.Drawing.Point(16, 160) Me.radYesNo.Name = "radYesNo" Me.radYesNo.Size = New System.Drawing.Size(120, 16) Me.radYesNo.TabIndex = 4 Me.radYesNo.Text = "YesNo" ' 'iconGroupBox ' Me.iconGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.radWarnin Me.iconGroupBox.Location = New System.Drawing.Point(200, 16) Me.iconGroupBox.Name = "iconGroupBox" Me.iconGroupBox.Size = New System.Drawing.Size(160, 304) Me.iconGroupBox.TabIndex = 3 Me.iconGroupBox.TabStop = False Me.iconGroupBox.Text = "Icon" ' 'radWarning ' Me.radWarning.Location = New System.Drawing.Point(16, 272) Me.radWarning.Name = "radWarning" Me.radWarning.Size = New System.Drawing.Size(128, 24) Me.radWarning.TabIndex = 7 Me.radWarning.Text = "Warning" ' 'radQuestion ' Me.radQuestion.Location = New System.Drawing.Point(16, 208) Me.radQuestion.Name = "radQuestion" Me.radQuestion.Size = New System.Drawing.Size(128, 24) Me.radQuestion.TabIndex = 5 Me.radQuestion.Text = "Question" ' 'radInformation ' Me.radInformation.Location = New System.Drawing.Point(16, 168) Me.radInformation.Name = "radInformation" Me.radInformation.Size = New System.Drawing.Size(128, 24) Me.radInformation.TabIndex = 4 Me.radInformation.Text = "Information" ' 'radHand ' Me.radHand.Location = New System.Drawing.Point(16, 128) Me.radHand.Name = "radHand" Me.radHand.Size = New System.Drawing.Size(128, 24) Me.radHand.TabIndex = 3 Me.radHand.Text = "Hand" ' 'radExclamation ' Me.radExclamation.Location = New System.Drawing.Point(16, 88) Me.radExclamation.Name = "radExclamation" Me.radExclamation.Size = New System.Drawing.Size(136, 24) Me.radExclamation.TabIndex = 2 Me.radExclamation.Text = "Exclamation" ' 'radError '

Me.radError.Location = New System.Drawing.Point(16, 48) Me.radError.Name = "radError" Me.radError.Size = New System.Drawing.Size(136, 24) Me.radError.TabIndex = 1 Me.radError.Text = "Error" ' 'radAsterisk ' Me.radAsterisk.Location = New System.Drawing.Point(16, 16) Me.radAsterisk.Name = "radAsterisk" Me.radAsterisk.Size = New System.Drawing.Size(136, 24) Me.radAsterisk.TabIndex = 0 Me.radAsterisk.Text = "Asterisk" ' 'radYesNoCancel ' Me.radYesNoCancel.Location = New System.Drawing.Point(16, 120) Me.radYesNoCancel.Name = "radYesNoCancel" Me.radYesNoCancel.Size = New System.Drawing.Size(120, 24) Me.radYesNoCancel.TabIndex = 3 Me.radYesNoCancel.Text = "YesNoCancel" ' 'radOk ' Me.radOk.Location = New System.Drawing.Point(16, 24) Me.radOk.Name = "radOk" Me.radOk.Size = New System.Drawing.Size(112, 16) Me.radOk.TabIndex = 0 Me.radOk.Text = "OK" ' 'cmdDisplay ' Me.cmdDisplay.Location = New System.Drawing.Point(32, 240) Me.cmdDisplay.Name = "cmdDisplay" Me.cmdDisplay.Size = New System.Drawing.Size(112, 40) Me.cmdDisplay.TabIndex = 1 Me.cmdDisplay.Text = "Display" ' 'lblDisplay ' Me.lblDisplay.Location = New System.Drawing.Point(24, 296) Me.lblDisplay.Name = "lblDisplay" Me.lblDisplay.Size = New System.Drawing.Size(144, 24) Me.lblDisplay.TabIndex = 5 ' 'buttonTypeGroupBox ' Me.buttonTypeGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.rad Me.buttonTypeGroupBox.Location = New System.Drawing.Point(16, 16) Me.buttonTypeGroupBox.Name = "buttonTypeGroupBox" Me.buttonTypeGroupBox.Size = New System.Drawing.Size(144, 216) Me.buttonTypeGroupBox.TabIndex = 2 Me.buttonTypeGroupBox.TabStop = False Me.buttonTypeGroupBox.Text = "Button Type" ' 'radRetryCancel ' Me.radRetryCancel.Location = New System.Drawing.Point(16, 192) Me.radRetryCancel.Name = "radRetryCancel" Me.radRetryCancel.Size = New System.Drawing.Size(104, 16) Me.radRetryCancel.TabIndex = 5

Me.radRetryCancel.Text = "RetryCancel" ' 'radOkCancel ' Me.radOkCancel.Location = New System.Drawing.Point(16, 56) Me.radOkCancel.Name = "radOkCancel" Me.radOkCancel.Size = New System.Drawing.Size(120, 24) Me.radOkCancel.TabIndex = 1 Me.radOkCancel.Text = "OKCancel" ' 'FrmRadioButton ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(384, 333) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblDisplay, Me.iconGro Me.Name = "FrmRadioButton" Me.Text = "RadioButtonTest" Me.iconGroupBox.ResumeLayout(False) Me.buttonTypeGroupBox.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub cmdDisplay_Click(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles cmdDisplay.Click Dim dialog As DialogResult = MessageBox.Show( _ "Your message", "Title", _ buttonType, iconType) Select Case dialog Case DialogResult.OK lblDisplay.Text = "OK was pressed" Case DialogResult.Cancel lblDisplay.Text = "Cancel was pressed" Case DialogResult.Abort lblDisplay.Text = "Abort was pressed" Case DialogResult.Retry lblDisplay.Text = "Retry was pressed" Case DialogResult.Ignore lblDisplay.Text = "Ignore was pressed" Case DialogResult.Yes lblDisplay.Text = "Yes was pressed" Case DialogResult.No lblDisplay.Text = "No was pressed" End Select End Sub ' cmdDisplay_Click Private Sub radOk_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radOk.CheckedChanged buttonType = MessageBoxButtons.OK

End Sub Private Sub radOkCancel_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radOkCancel.CheckedChanged buttonType = MessageBoxButtons.OKCancel End Sub Private Sub radAbortRetryIgnore_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radAbortRetryIgnore.CheckedChanged buttonType = MessageBoxButtons.AbortRetryIgnore End Sub Private Sub radYesNoCancel_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radYesNoCancel.CheckedChanged buttonType = MessageBoxButtons.YesNoCancel End Sub Private Sub radYesNo_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radYesNo.CheckedChanged buttonType = MessageBoxButtons.YesNo End Sub Private Sub radRetryCancel_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radRetryCancel.CheckedChanged buttonType = MessageBoxButtons.RetryCancel End Sub Private Sub radAsterisk_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radAsterisk.CheckedChanged iconType = MessageBoxIcon.Asterisk End Sub Private Sub radError_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radError.CheckedChanged iconType = MessageBoxIcon.Error End Sub Private Sub radExclamation_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radExclamation.CheckedChanged iconType = MessageBoxIcon.Exclamation End Sub Private Sub radHand_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radHand.CheckedChanged

iconType = MessageBoxIcon.Hand End Sub Private Sub radInformation_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radInformation.CheckedChanged iconType = MessageBoxIcon.Information End Sub Private Sub radQuestion_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radQuestion.CheckedChanged iconType = MessageBoxIcon.Question End Sub Private Sub radStop_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radStop.CheckedChanged iconType = MessageBoxIcon.Stop End Sub Private Sub radWarning_CheckedChanged(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles radWarning.CheckedChanged iconType = MessageBoxIcon.Warning End Sub End Class

Use RadioButon pentru a seta fontul

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class UseCheckBoxRadioButtonSetFont public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form privare de LabelStyle Ca FontStyle Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents GroupBox1 Ca System.Windows.Forms.GroupBox prieten WithEvents RadioButton1 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton2 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton3 Ca sistem. Windows.Forms.RadioButton prieten WithEvents GroupBox2 Ca System.Windows.Forms.GroupBox prieten WithEvents RadioButton4 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton5 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton6 Ca System.Windows.Forms.RadioButton prieten WithEvents GroupBox3 Ca System.Windows.Forms.GroupBox prieten WithEvents CheckBox1 Ca System.Windows.Forms.CheckBox prieten WithEvents CheckBox2 Ca System.Windows.Forms.CheckBox prieten WithEvents CheckBox3 Ca System.Windows.Forms.CheckBox <System.Diagnostics.DebuggerStepThrough ( ) > Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = Sistem. Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.GroupBox2 = New System.Windows.Forms.GroupBox Me.RadioButton4 = New System.Windows.Forms.RadioButton Me.RadioButton5 = New System.Windows. Forms.RadioButton Me.RadioButton6 = New System.Windows.Forms.RadioButton Me.GroupBox3 = New System.Windows.Forms.GroupBox Me.CheckBox1 = New System.Windows.Forms.CheckBox Me.CheckBox2 = System.Windows.Forms noi. CheckBox Me.CheckBox3 = Nou

= New System.Drawing.Font ( "Sans Serif Microsoft" , 14.25 !, System.Drawing.Fo Me.Label1.Location = New System.Drawing . Punctul ( 24 , 16 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 288 , 88 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "Visual

= New System.Drawing.Point ( 32 , 136 ) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size ( 72 , Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = false Me.GroupBox1.Text = "color" " "Ra dioButton1 ' Me.RadioButton1.Location = New System.Drawing.Point Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.Size = Sistem . Drawing.Size ( 56 , Me.RadioButton1.TabIndex = 0 Me.RadioButton1.Text = "Red" " "Ra dioButton2 ' Me.RadioButton2.Location = New System.Drawing.Point Me.RadioButton2 . Nume = "RadioButton2" Me.RadioButton2.Size = New System.Drawing.Size ( 56 Me.RadioButton2.TabIndex = 1 Me.RadioButton2.Text = "galben" ' 'Ra dioButton3 ' Me.RadioButton3.Location = New System.Drawing.Point Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.Size = New System.Drawing.Size ( 56 Me.RadioButton3.TabIndex = 2 Me.RadioButton3.Text

120 )

( 8 , 16 )

24 )

( 8 , , 16 )

48 )

( 8 , , 24 )

72 )

= New System.Drawing.Point ( 128 , 136 ) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size ( 80 , Me.GroupBox2.TabIndex = 2 Me.GroupBox2.TabStop = false Me.GroupBox2.Text = "Font Size" " "Ra dioButton4

120 )

' Me.RadioButton4.Location = New System.Drawing.Point Me.RadioButton4.Name = "RadioButton4" Me.RadioButton4.Size = Nou System.Drawing.Size ( 48 Me.RadioButton4.TabIndex = 0 Me.RadioButton4.Text = "10" " "Ra dioButton5 ' Me.RadioButton5.Location = New System.Drawing.Point Me. RadioButton5.Name = "RadioButton5" Me.RadioButton5.Size = New System.Drawing.Size ( 56 Me.RadioButton5.TabIndex = 1 Me.RadioButton5.Text = "20" " "Ra dioButton6 " Me.RadioButton6.Location = New System.Drawing.Point Me.RadioButton6.Name = "RadioButton6" Me.RadioButton6.Size = New System.Drawing.Size ( 56 Me.RadioButton6.TabIndex = 2 Me.RadioButton6.Text

( 16 , , 16 )

24 )

( 16 , , 24 )

48 )

( 16 , , 24 )

80 )

= New System.Drawing.Point ( 224 , 144 ) Me.GroupBox3.Name = "GroupBox3" Me.GroupBox3.Size = New System.Drawing.Size ( 88 Me.GroupBox3.TabIndex = 3 Me.GroupBox3.TabStop = false Me.GroupBox3.Text = "Altele" " "Ch eckBox1 ' Me.CheckBox1.Location = New System.Drawing.Point Me.CheckBox1.Name = "CheckBox1" Me.CheckBox1.Size = Sistem . Drawing.Size ( 64 , Me.CheckBox1.TabIndex = 0 Me.CheckBox1.Text = "Italic" " "Ch eckBox2 ' Me.CheckBox2.Location = New System.Drawing.Point Me.CheckBox2 . Nume = "CheckBox2" Me.CheckBox2.Size = New System.Drawing.Size ( 48 Me.CheckBox2.TabIndex = 1 Me.CheckBox2.Text = "Bold" " "Ch eckBox3 ' Me.CheckBox3.Location = New System.Drawing.Point Me.CheckBox3.Name = "CheckBox3" Me.CheckBox3.Size = New System.Drawing.Size ( 64 Me.CheckBox3.TabIndex = 2 Me.CheckBox3.Text = "Subliniat" " "Fo RM1 '

120 )

( 16 , 24 )

16 )

( 16 , , 24 )

48 )

( 16 , , 24 )

80 )

Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , Me.ClientSize = Nou

13 )

= "Form1" Me.Text = "font

End Sub Private Sub RadioButton1_CheckedChanged ( expeditor ByVal Label1.ForeColor = Color.Red End Sub Private Sub RadioButton2_CheckedChanged ( expeditor ByVal Label1.ForeColor = Color.Yellow End Sub Private Sub RadioButton3_CheckedChanged ( expeditor ByVal Label1.ForeColor = Color.Green End Sub Private Sub RadioButton4_CheckedChanged ( expeditor ByVal Label1.Font = New Font ( Label1.Font.FontFamily, 10 ) End Sub Private Sub RadioButton5_CheckedChanged ( expeditor ByVal Label1.Font = New Font ( Label1.Font.FontFamily, 20 ) End Sub Private Sub RadioButton6_CheckedChanged ( expeditor ByVal Label1.Font = New Font ( Label1.Font.FontFamily, 30 ) End Sub Private Sub CheckBox1_CheckedChanged ( expeditor ByVal LabelStyle = LabelStyle XOR FontStyle.Italic Label1.Font = font nou ( Label1.Font, LabelStyle ) End Sub Private Sub CheckBox2_CheckedChanged ( expeditor ByVal LabelStyle = LabelStyle XOR FontStyle.Bold Label1.Font = font nou ( Label1.Font, LabelStyle ) End Sub Private Sub CheckBox3_CheckedChanged ( expeditor ByVal LabelStyle = LabelStyle XOR FontStyle.Underline Label1.Font = New Font ( Label1.Font, LabelStyle ) End Sub End Class Ca Ca

System.Object, ByVal

Ca

System.Object, ByVal

Ca

System.Object, ByVal

Ca

System.Object, ByVal

Ca

System.Object, ByVal

Ca

System.Object, ByVal

System.Object, ByVal e

Ca

System.Object, ByVal e

Ca

System.Object, ByVal e

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class UseCheckBoxRadioButtonSetFont public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Private LabelStyle As FontStyle Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer Friend Friend Friend Friend Friend Friend WithEvents WithEvents WithEvents WithEvents WithEvents WithEvents Label1 As System.Windows.Forms.Label GroupBox1 As System.Windows.Forms.GroupBox RadioButton1 As System.Windows.Forms.RadioButton RadioButton2 As System.Windows.Forms.RadioButton RadioButton3 As System.Windows.Forms.RadioButton GroupBox2 As System.Windows.Forms.GroupBox

Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton5 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton6 As System.Windows.Forms.RadioButton Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox Friend WithEvents CheckBox2 As System.Windows.Forms.CheckBox Friend WithEvents CheckBox3 As System.Windows.Forms.CheckBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.GroupBox2 = New System.Windows.Forms.GroupBox Me.RadioButton4 = New System.Windows.Forms.RadioButton Me.RadioButton5 = New System.Windows.Forms.RadioButton Me.RadioButton6 = New System.Windows.Forms.RadioButton Me.GroupBox3 = New System.Windows.Forms.GroupBox Me.CheckBox1 = New System.Windows.Forms.CheckBox Me.CheckBox2 = New System.Windows.Forms.CheckBox Me.CheckBox3 = New System.Windows.Forms.CheckBox Me.GroupBox1.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.GroupBox3.SuspendLayout() Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System. Me.Label1.Location = New System.Drawing.Point(24, 16) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(288, 88) Me.Label1.TabIndex = 0 Me.Label1.Text = "Visual Basic.NET" ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.RadioButton3) Me.GroupBox1.Controls.Add(Me.RadioButton2) Me.GroupBox1.Controls.Add(Me.RadioButton1) Me.GroupBox1.Location = New System.Drawing.Point(32, 136) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(72, 120) Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Color" ' 'RadioButton1 ' Me.RadioButton1.Location = New System.Drawing.Point(8, 24) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.Size = New System.Drawing.Size(56, 16) Me.RadioButton1.TabIndex = 0 Me.RadioButton1.Text = "Red" ' 'RadioButton2 ' Me.RadioButton2.Location = New System.Drawing.Point(8, 48) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.Size = New System.Drawing.Size(56, 16) Me.RadioButton2.TabIndex = 1

Me.RadioButton2.Text = "Yellow" ' 'RadioButton3 ' Me.RadioButton3.Location = New System.Drawing.Point(8, 72) Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.Size = New System.Drawing.Size(56, 24) Me.RadioButton3.TabIndex = 2 Me.RadioButton3.Text = "Green" ' 'GroupBox2 ' Me.GroupBox2.Controls.Add(Me.RadioButton6) Me.GroupBox2.Controls.Add(Me.RadioButton5) Me.GroupBox2.Controls.Add(Me.RadioButton4) Me.GroupBox2.Location = New System.Drawing.Point(128, 136) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(80, 120) Me.GroupBox2.TabIndex = 2 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Font Size" ' 'RadioButton4 ' Me.RadioButton4.Location = New System.Drawing.Point(16, 24) Me.RadioButton4.Name = "RadioButton4" Me.RadioButton4.Size = New System.Drawing.Size(48, 16) Me.RadioButton4.TabIndex = 0 Me.RadioButton4.Text = "10" ' 'RadioButton5 ' Me.RadioButton5.Location = New System.Drawing.Point(16, 48) Me.RadioButton5.Name = "RadioButton5" Me.RadioButton5.Size = New System.Drawing.Size(56, 24) Me.RadioButton5.TabIndex = 1 Me.RadioButton5.Text = "20" ' 'RadioButton6 ' Me.RadioButton6.Location = New System.Drawing.Point(16, 80) Me.RadioButton6.Name = "RadioButton6" Me.RadioButton6.Size = New System.Drawing.Size(56, 24) Me.RadioButton6.TabIndex = 2 Me.RadioButton6.Text = "30" ' 'GroupBox3 ' Me.GroupBox3.Controls.Add(Me.CheckBox3) Me.GroupBox3.Controls.Add(Me.CheckBox2) Me.GroupBox3.Controls.Add(Me.CheckBox1) Me.GroupBox3.Location = New System.Drawing.Point(224, 144) Me.GroupBox3.Name = "GroupBox3" Me.GroupBox3.Size = New System.Drawing.Size(88, 120) Me.GroupBox3.TabIndex = 3 Me.GroupBox3.TabStop = False Me.GroupBox3.Text = "Other" ' 'CheckBox1 ' Me.CheckBox1.Location = New System.Drawing.Point(16, 16)

Me.CheckBox1.Name = "CheckBox1" Me.CheckBox1.Size = New System.Drawing.Size(64, 24) Me.CheckBox1.TabIndex = 0 Me.CheckBox1.Text = "Italic" ' 'CheckBox2 ' Me.CheckBox2.Location = New System.Drawing.Point(16, 48) Me.CheckBox2.Name = "CheckBox2" Me.CheckBox2.Size = New System.Drawing.Size(48, 24) Me.CheckBox2.TabIndex = 1 Me.CheckBox2.Text = "Bold" ' 'CheckBox3 ' Me.CheckBox3.Location = New System.Drawing.Point(16, 80) Me.CheckBox3.Name = "CheckBox3" Me.CheckBox3.Size = New System.Drawing.Size(64, 24) Me.CheckBox3.TabIndex = 2 Me.CheckBox3.Text = "Underline" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(328, 278) Me.Controls.Add(Me.GroupBox3) Me.Controls.Add(Me.GroupBox2) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Font Setting" Me.GroupBox1.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.GroupBox3.ResumeLayout(False) Me.ResumeLayout(False) End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy Label1.ForeColor = Color.Red End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy Label1.ForeColor = Color.Yellow End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy Label1.ForeColor = Color.Green End Sub

Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy Label1.Font = New Font(Label1.Font.FontFamily, 10) End Sub

Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy Label1.Font = New Font(Label1.Font.FontFamily, 20) End Sub

Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy Label1.Font = New Font(Label1.Font.FontFamily, 30) End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste LabelStyle = LabelStyle Xor FontStyle.Italic Label1.Font = New Font(Label1.Font, LabelStyle) End Sub

Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste LabelStyle = LabelStyle Xor FontStyle.Bold Label1.Font = New Font(Label1.Font, LabelStyle) End Sub

Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As Syste LabelStyle = LabelStyle Xor FontStyle.Underline Label1.Font = New Font(Label1.Font, LabelStyle) End Sub End Class

RadioButtons ntr-o GROUPBOX

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class RadioButtonInGroupBox public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New ()

"Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents GroupBox1 Ca System.Windows.Forms.GroupBox prieten WithEvents GroupBox2 Ca System.Windows.Forms.GroupBox prieten WithEvents RadioButton1 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton2 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton3 Ca System.Windows.Forms. RadioButon prieten WithEvents RadioButton4 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton5 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton6 Ca System.Windows.Forms.RadioButton prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics. DebuggerStepThrough () > Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.GroupBox2 = New System.Windows.Forms.GroupBox Me.RadioButton1 = Nou System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.RadioButton4 = New System.Windows.Forms.RadioButton Me.RadioButton5 = Sistem. Windows.Forms.RadioButton Me.RadioButton6 = New System.Windows.Forms.RadioButton Me.TextBox1 = Nou Ca apel

Bool

= New System.Drawing.Font ( "Sans Serif Microsoft" , 14.0 !, System.Drawing.Fon Me.Label1.Location = New System.Drawing . Punctul ( 0 , 0 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 208 , 40 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "Grup

= New System.Drawing.Point ( 8 , 48 ) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size ( 136 , Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = false Me.GroupBox1.Text

176 )

= New System.Drawing.Point ( 152 , 48 ) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size ( 136 , Me.GroupBox2.TabIndex = 2 Me.GroupBox2.TabStop = false Me.GroupBox2.Text = "GroupBox2" " "Ra dioButton1 ' Me.RadioButton1.Location = New System.Drawing.Point Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.TabIndex = 0 Me RadioButton1.Text =. "RadioButton1" " "Ra dioButton2 ' Me.RadioButton2.Location = New System.Drawing.Point Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.TabIndex = 1 Me.RadioButton2. Text = "RadioButton2" " "Ra dioButton3 ' Me.RadioButton3.Location = New System.Drawing.Point Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.TabIndex = 2 Me.RadioButton3.Text = " RadioButton3 " " "Ra dioButton4 ' Me.RadioButton4.Location = New System.Drawing.Point Me.RadioButton4.Name = "RadioButton4" Me.RadioButton4.TabIndex = 0 Me.RadioButton4.Text = "RadioButton4" " "Ra dioButton5 ' Me.RadioButton5.Location = New System.Drawing.Point Me.RadioButton5.Name = "RadioButton5" Me.RadioButton5.TabIndex = 1 Me.RadioButton5.Text = "RadioButton5" " "Ra dioButton6 " Me.RadioButton6.Location = New System.Drawing.Point Me.RadioButton6.Name = "RadioButton6" Me.RadioButton6.TabIndex = 2

176 )

( 16 ,

32 )

( 16 ,

72 )

( 16 ,

112 )

( 16 ,

32 )

( 16 ,

72 )

( 16 ,

112 )

Me.RadioButton6.Text = "RadioButton6" " "Te xtBox1 " Me. TextBox1.Location = New System.Drawing.Point ( 8 , 240 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 280 , 20 ) Me.TextBox1.TabIndex = 3 Mine. TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout ( Fals ) Me.GroupBox2.ResumeLayout ( False ) Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca

Private Sub RadioButton1_CheckedChanged ( expeditor ByVal TextBox1.Text = "ai fcut clic pe butonul radio 1." End Sub Private Sub RadioButton2_CheckedChanged ( expeditor ByVal TextBox1.Text = "ai fcut clic pe butonul radio 2." End Sub Private Sub RadioButton3_CheckedChanged ( expeditor ByVal TextBox1.Text = "ai fcut clic pe butonul radio 3." End Sub Private Sub RadioButton4_CheckedChanged ( expeditor ByVal TextBox1.Text = "ai fcut clic pe butonul radio 4." End Sub Private Sub RadioButton5_CheckedChanged ( expeditor ByVal TextBox1.Text = "ai fcut clic pe butonul radio 5." End Sub Private Sub RadioButton6_CheckedChanged ( expeditor ByVal TextBox1.Text = "Ai apasat butonul radio 6." End Sub End Class

System.Object, ByVal

Ca

System.Object, ByVal

Ca

System.Object, ByVal

Ca

System.Object, ByVal

Ca

System.Object, ByVal

Ca

System.Object, ByVal

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class RadioButtonInGroupBox public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.

Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton5 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton6 As System.Windows.Forms.RadioButton Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.GroupBox2 = New System.Windows.Forms.GroupBox Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.RadioButton4 = New System.Windows.Forms.RadioButton Me.RadioButton5 = New System.Windows.Forms.RadioButton Me.RadioButton6 = New System.Windows.Forms.RadioButton Me.TextBox1 = New System.Windows.Forms.TextBox Me.GroupBox1.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.SuspendLayout() ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.D Me.Label1.Location = New System.Drawing.Point(0, 0) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(208, 40) Me.Label1.TabIndex = 0 Me.Label1.Text = "Group Boxes" ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.RadioButton3) Me.GroupBox1.Controls.Add(Me.RadioButton2) Me.GroupBox1.Controls.Add(Me.RadioButton1) Me.GroupBox1.Location = New System.Drawing.Point(8, 48) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(136, 176) Me.GroupBox1.TabIndex = 1 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "GroupBox1" ' 'GroupBox2 ' Me.GroupBox2.Controls.Add(Me.RadioButton6) Me.GroupBox2.Controls.Add(Me.RadioButton5) Me.GroupBox2.Controls.Add(Me.RadioButton4) Me.GroupBox2.Location = New System.Drawing.Point(152, 48) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(136, 176) Me.GroupBox2.TabIndex = 2 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "GroupBox2" ' 'RadioButton1 ' Me.RadioButton1.Location = New System.Drawing.Point(16, 32)

Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.TabIndex = 0 Me.RadioButton1.Text = "RadioButton1" ' 'RadioButton2 ' Me.RadioButton2.Location = New System.Drawing.Point(16, Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.TabIndex = 1 Me.RadioButton2.Text = "RadioButton2" ' 'RadioButton3 ' Me.RadioButton3.Location = New System.Drawing.Point(16, Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.TabIndex = 2 Me.RadioButton3.Text = "RadioButton3" ' 'RadioButton4 ' Me.RadioButton4.Location = New System.Drawing.Point(16, Me.RadioButton4.Name = "RadioButton4" Me.RadioButton4.TabIndex = 0 Me.RadioButton4.Text = "RadioButton4" ' 'RadioButton5 ' Me.RadioButton5.Location = New System.Drawing.Point(16, Me.RadioButton5.Name = "RadioButton5" Me.RadioButton5.TabIndex = 1 Me.RadioButton5.Text = "RadioButton5" ' 'RadioButton6 ' Me.RadioButton6.Location = New System.Drawing.Point(16, Me.RadioButton6.Name = "RadioButton6" Me.RadioButton6.TabIndex = 2 Me.RadioButton6.Text = "RadioButton6" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(8, 240) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(280, 20) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.GroupBox2) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox1) Me.Name = "Form1" Me.Text = "Form1" Me.GroupBox1.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.ResumeLayout(False)

72)

112)

32)

72)

112)

End Sub #End Region

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy TextBox1.Text = "You clicked radio button 1." End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy TextBox1.Text = "You clicked radio button 2." End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy TextBox1.Text = "You clicked radio button 3." End Sub

Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy TextBox1.Text = "You clicked radio button 4." End Sub

Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy TextBox1.Text = "You clicked radio button 5." End Sub

Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy TextBox1.Text = "You clicked radio button 6." End Sub End Class

Butoane 14.5.5.Toggle

Importurile Importurile Importurile public class

System.Drawing System.Drawing.Drawing2D System.Windows.Forms RadioButtonToggleButton

public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents RadioButton1 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton2 Ca System.Windows.Forms.RadioButton prieten WithEvents RadioButton3 Ca System.Windows.Forms.RadioButton prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Label1 Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > privat Sub InitializeComponent () Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.TextBox1 = System.Windows.Forms noi . TextBox Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout () " "Ra dioButton1 ' Me.RadioButton1.Appearance = System.Windows.Forms.Appearance.Button Me.RadioButton1.Location = New System.Drawing. punctul ( 96 , 64 ) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.TabIndex = 0 Me.RadioButton1.Text = "Radio Button 1" " "Ra dioButton2 ' Me.RadioButton2.Appearance = System.Windows.Forms. Appearance.Button Me.RadioButton2.Location = New System.Drawing.Point ( 96 , 112 ) Ca apel

Bool

Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.TabIndex = 1 Me.RadioButton2.Text = "Buton Radio 2" ' 'Ra dioButton3 ' Me.RadioButton3.Appearance = System.Windows.Forms.Appearance.Button Me.RadioButton3.Location = New System.Drawing.Point ( 96 , 160 ) Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.TabIndex = 2 Me.RadioButton3.Text = "Radio Button 3" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 40 , 216 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = Sistem . Drawing.Size ( 200 , 20 ) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

End Sub # End Regiunea Ca

Private Sub RadioButton1_CheckedChanged ( expeditor ByVal TextBox1.Text = "ai fcut clic pe butonul 1." End Sub Private Sub RadioButton2_CheckedChanged ( expeditor ByVal TextBox1.Text = "ai fcut clic pe butonul 2." End Sub Private Sub RadioButton3_CheckedChanged ( expeditor ByVal TextBox1.Text = "Ai fcut clic pe butonul 3." End Sub End Class

System.Object, ByVal

Ca

System.Object, ByVal

Ca

System.Object, ByVal

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class RadioButtonToggleButton public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.

Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'RadioButton1 ' Me.RadioButton1.Appearance = System.Windows.Forms.Appearance.Button Me.RadioButton1.Location = New System.Drawing.Point(96, 64) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.TabIndex = 0 Me.RadioButton1.Text = "Radio Button 1" ' 'RadioButton2 ' Me.RadioButton2.Appearance = System.Windows.Forms.Appearance.Button Me.RadioButton2.Location = New System.Drawing.Point(96, 112) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.TabIndex = 1 Me.RadioButton2.Text = "Radio Button 2" ' 'RadioButton3 ' Me.RadioButton3.Appearance = System.Windows.Forms.Appearance.Button Me.RadioButton3.Location = New System.Drawing.Point(96, 160) Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.TabIndex = 2 Me.RadioButton3.Text = "Radio Button 3" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(40, 216) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(200, 20) Me.TextBox1.TabIndex = 3 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.RadioButton3) Me.Controls.Add(Me.RadioButton2) Me.Controls.Add(Me.RadioButton1) Me.ResumeLayout(False) End Sub #End Region

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy

TextBox1.Text = "You clicked button 1." End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy TextBox1.Text = "You clicked button 2." End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As Sy TextBox1.Text = "You clicked button 3." End Sub End Class

Use RadioButon pentru a controla LineCap

Imports Imports Imports Imports Imports Imports Imports

System System.Drawing System.Collections System.ComponentModel System.Windows.Forms System.Data System.Drawing.Drawing2D

public class LineJoinRadioButton public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New ()

"Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents groupBox1 Ca System.Windows.Forms.GroupBox prieten WithEvents MiterClippedRadBtn Ca System.Windows.Forms.RadioButton prieten WithEvents RoundRadBtn Ca System.Windows.Forms.RadioButton prieten WithEvents MiterRadBtn Ca System.Windows.Forms.RadioButton prieten WithEvents BevelRadBtn Ca System.Windows.Forms.RadioButton prieten WithEvents ApplyJoin Ca System.Windows.Forms. Butonul <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.groupBox1 = New System.Windows.Forms.GroupBox Me.MiterClippedRadBtn = New System.Windows.Forms.RadioButton Me.RoundRadBtn = New System.Windows.Forms. RadioButon Me.MiterRadBtn = New System.Windows.Forms.RadioButton Me.BevelRadBtn = New System.Windows.Forms.RadioButton Me.ApplyJoin = Nou Ca apel

Bool

= New System.Drawing.Point ( 320 , 18 ) Me.groupBox1.Name = "groupBox1" Me.groupBox1.Size = New System.Drawing.Size ( 152 , 152 ) Me.groupBox1.TabIndex = 3 Me.groupBox1.TabStop = false Me.groupBox1.Text = "linie de asociere" " "Mi terClippedRadBtn ' Me.MiterClippedRadBtn.Location = New System.Drawing.Point ( 16 , 88 ) Me.MiterClippedRadBtn.Name = "MiterClippedRadBtn" Me.MiterClippedRadBtn.Size = Nou System.Drawing.Size ( 120 , 24 ) Me.MiterClippedRadBtn.TabIndex = 3 Me.MiterClippedRadBtn.Text = "Miter Prins" "

"Ro undRadBtn ' Me.RoundRadBtn.Location = New System.Drawing.Point ( 16 , 120 ) Me . RoundRadBtn.Name = "RoundRadBtn" Me.RoundRadBtn.Size = New System.Drawing.Size ( 112 , 24 ) Me.RoundRadBtn.TabIndex = 2 Me.RoundRadBtn.Text = "Round" " "Mi terRadBtn " Me.MiterRadBtn. Locaie = New System.Drawing.Point ( 16 , 56 ) Me.MiterRadBtn.Name = "MiterRadBtn" Me.MiterRadBtn.Size = New System.Drawing.Size ( 120 , 24 ) Me.MiterRadBtn.TabIndex = 1 Me.MiterRadBtn. Text = "Miter" " "Fii velRadBtn ' Me.BevelRadBtn.Checked = True Me.BevelRadBtn.Location = New System.Drawing.Point ( 16 , 24 ) Me.BevelRadBtn.Name = "BevelRadBtn" Me.BevelRadBtn.Size = Nou System.Drawing.Size ( 112 , 24 ) Me.BevelRadBtn.TabIndex = 0 Me.BevelRadBtn.TabStop = True Me.BevelRadBtn.Text = "Bevel" " "Ap. plyJoin ' Me.ApplyJoin.Location = New System.Drawing.Point ( 344 , 194 ) Me.ApplyJoin.Name = "ApplyJoin" Me.ApplyJoin.Size = New System.Drawing.Size ( 112 , 32 ) Me.ApplyJoin.TabIndex = 2 Me.ApplyJoin.Text = "Aplic LineJoin" " " Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 488 , 245 ) Me.Controls.Add ( Me.groupBox1 ) Me.Controls.Add ( Me . ApplyJoin ) Me.Name = "Form1" Me.Text = "Form1" Me.groupBox1.ResumeLayout ( Fals ) Me.ResumeLayout ( Fals ) End Sub # End Regiunea ca

Private Sub ApplyJoin_Click ( ByVal expeditor Ca System.Object, ByVal e Dim g Ca Graphics = Me.CreateGraphics () g.Clear ( Me.BackColor ) n cazul n care BevelRadBtn.Checked Apoi DrawJoinedLines ( g, LineJoin . Bevel ) Dac End Dac MiterRadBtn.Checked Apoi DrawJoinedLines ( g, LineJoin.Miter ) Dac End Dac MiterClippedRadBtn.Checked Apoi DrawJoinedLines ( g, LineJoin.MiterClipped ) Dac End

Syst

Dac

RoundRadBtn.Checked Apoi DrawJoinedLines ( g, LineJoin.Round ) End If g.Dispose () End Sub

Private Sub DrawJoinedLines ( ByVal g Ca Graphics, ByVal joinType Ca LineJoin ) g.SmoothingMode = SmoothingMode.AntiAlias Dim redPen Ca New Pen ( Color.Red, 20 ) redPen.LineJoin = joinType Dim pct. Ca Punctul () = { New Punctul ( 10 , 20 ) , nou punct ( 50 , 20 Dim pts1 Ca Punctul () = { New Punctul ( 20 , 20 ) , nou punct ( 300 , 20 g.DrawLines ( redPen, puncte ) g.DrawLines ( redPen, pts1 ) redPen.Dispose () End Sub "Dr. awJoinedLines End Class

Original

Imports Imports Imports Imports Imports Imports Imports

System System.Drawing System.Collections System.ComponentModel System.Windows.Forms System.Data System.Drawing.Drawing2D

public class LineJoinRadioButton public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents groupBox1 As System.Windows.Forms.GroupBox Friend WithEvents MiterClippedRadBtn As System.Windows.Forms.RadioButton Friend WithEvents RoundRadBtn As System.Windows.Forms.RadioButton Friend WithEvents MiterRadBtn As System.Windows.Forms.RadioButton Friend WithEvents BevelRadBtn As System.Windows.Forms.RadioButton Friend WithEvents ApplyJoin As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.groupBox1 = New System.Windows.Forms.GroupBox Me.MiterClippedRadBtn = New System.Windows.Forms.RadioButton Me.RoundRadBtn = New System.Windows.Forms.RadioButton Me.MiterRadBtn = New System.Windows.Forms.RadioButton Me.BevelRadBtn = New System.Windows.Forms.RadioButton Me.ApplyJoin = New System.Windows.Forms.Button Me.groupBox1.SuspendLayout() Me.SuspendLayout() ' 'groupBox1 ' Me.groupBox1.Controls.Add(Me.MiterClippedRadBtn) Me.groupBox1.Controls.Add(Me.RoundRadBtn) Me.groupBox1.Controls.Add(Me.MiterRadBtn) Me.groupBox1.Controls.Add(Me.BevelRadBtn) Me.groupBox1.Location = New System.Drawing.Point(320, 18) Me.groupBox1.Name = "groupBox1" Me.groupBox1.Size = New System.Drawing.Size(152, 152) Me.groupBox1.TabIndex = 3 Me.groupBox1.TabStop = False Me.groupBox1.Text = "Line Join" '

'MiterClippedRadBtn ' Me.MiterClippedRadBtn.Location = New System.Drawing.Point(16, 88) Me.MiterClippedRadBtn.Name = "MiterClippedRadBtn" Me.MiterClippedRadBtn.Size = New System.Drawing.Size(120, 24) Me.MiterClippedRadBtn.TabIndex = 3 Me.MiterClippedRadBtn.Text = "Miter Clipped" ' 'RoundRadBtn ' Me.RoundRadBtn.Location = New System.Drawing.Point(16, 120) Me.RoundRadBtn.Name = "RoundRadBtn" Me.RoundRadBtn.Size = New System.Drawing.Size(112, 24) Me.RoundRadBtn.TabIndex = 2 Me.RoundRadBtn.Text = "Round" ' 'MiterRadBtn ' Me.MiterRadBtn.Location = New System.Drawing.Point(16, 56) Me.MiterRadBtn.Name = "MiterRadBtn" Me.MiterRadBtn.Size = New System.Drawing.Size(120, 24) Me.MiterRadBtn.TabIndex = 1 Me.MiterRadBtn.Text = "Miter" ' 'BevelRadBtn ' Me.BevelRadBtn.Checked = True Me.BevelRadBtn.Location = New System.Drawing.Point(16, 24) Me.BevelRadBtn.Name = "BevelRadBtn" Me.BevelRadBtn.Size = New System.Drawing.Size(112, 24) Me.BevelRadBtn.TabIndex = 0 Me.BevelRadBtn.TabStop = True Me.BevelRadBtn.Text = "Bevel" ' 'ApplyJoin ' Me.ApplyJoin.Location = New System.Drawing.Point(344, 194) Me.ApplyJoin.Name = "ApplyJoin" Me.ApplyJoin.Size = New System.Drawing.Size(112, 32) Me.ApplyJoin.TabIndex = 2 Me.ApplyJoin.Text = "Apply LineJoin" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(488, 245) Me.Controls.Add(Me.groupBox1) Me.Controls.Add(Me.ApplyJoin) Me.Name = "Form1" Me.Text = "Form1" Me.groupBox1.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region

Private Sub ApplyJoin_Click(ByVal sender As System.Object, ByVal e As System.EventAr Dim g As Graphics = Me.CreateGraphics() g.Clear(Me.BackColor) If BevelRadBtn.Checked Then

DrawJoinedLines(g, LineJoin.Bevel) End If If MiterRadBtn.Checked Then DrawJoinedLines(g, LineJoin.Miter) End If If MiterClippedRadBtn.Checked Then DrawJoinedLines(g, LineJoin.MiterClipped) End If If RoundRadBtn.Checked Then DrawJoinedLines(g, LineJoin.Round) End If g.Dispose() End Sub

Private Sub DrawJoinedLines(ByVal g As Graphics, ByVal joinType As LineJoin) g.SmoothingMode = SmoothingMode.AntiAlias Dim redPen As New Pen(Color.Red, 20) redPen.LineJoin = joinType Dim pts As Point() = {New Point(10, 20), New Point(50, 20), New Point(80, 60), N Dim pts1 As Point() = {New Point(20, 20), New Point(300, 20), New Point(30, 120) g.DrawLines(redPen, pts) g.DrawLines(redPen, pts1) redPen.Dispose() End Sub 'DrawJoinedLines End Class

Create Dialog din formular

Importurile Importurile Importurile public class

System.Windows.Forms System.Drawing System.Drawing.Drawing2D CreateDialogBaseOnForm

public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Public class DlgTest Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents btnOK Ca System.Windows.Forms.Button prieten WithEvents btnCancel Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.btnOK = New System.Windows.Forms.Button () Me.btnCancel = New System.Windows.Forms.Button () Me . SuspendLayout () " "bt NOK ' Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnOK.Location = New System.Drawing.Point ( 48 , 152 ) Me.btnOK.Name = "btnOK" Me.btnOK.TabIndex = 0 Me.btnOK.Text = "Do It!" " "bt nCancel ' Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnCancel.Location = New System.Drawing.Point ( 152 , 152 ) Me.btnCancel.Name = "btnCancel" Me.btnCancel.TabIndex = 1 Me.btnCancel.Text = "Cancel" " "Dl gTest ' Ca apel

Bool

Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.btnCancel, Me.btnOK }) Me.Name = "DlgTest" Me. Text = "DLG" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub btnOK_Click ( ByVal expeditor DialogResult = DialogResult.OK End Sub

System.Eve

Private Sub btnCancel_Click ( ByVal expeditor DialogResult = DialogResult.Cancel End Sub End Class Publice clasa Form1 Motenete System.Windows.Forms.Form # Region

Ca

System.Object, ByVal e

ca

System

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. WithEvents prieten btnCreate Ca System.Windows.Forms.Button prieten WithEvents lblReturn Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.btnCreate = New System.Windows.Forms.Button () Me.lblReturn = New System.Windows.Forms.Label () Me . SuspendLayout () " "bt nCreate ' Ca apel

Bool

Me.btnCreate.Location = New System.Drawing.Point ( 96 , 152 ) Me.btnCreate.Name = "btnCreate" Me.btnCreate.Size = New System.Drawing.Size ( 120 , 23 ) Me.btnCreate.TabIndex = 0 Me.btnCreate.Text = "Creaza Caseta de dialog" " 'lb lReturn ' Me.lblReturn.Location = New System.Drawing.Point ( 96 , 96 ) Me.lblReturn.Name = "lblReturn " Me.lblReturn.TabIndex = 1 ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.lblReturn, Me.btnCreate Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea ca

Private Sub btnCreate_Click ( ByVal expeditor Ca System.Object, ByVal e dim DLG ca New DlgTest dlg.Text = "Dialog Test" dlg.FormBorderStyle = FormBorderStyle.FixedDialog dlg.BackColor = Color.Azure DLG . ControlBox = true dlg.MaximizeBox = false dlg.MinimizeBox = false dlg.ShowInTaskbar = false 'dl g.Icon = new Icon ( f.GetType () , "YourFile.ICO" )

System

dlg.Size = new Dimensiune ( 300 , 300 ) dlg.StartPosition = FormStartPosition.CenterScreen selectai cazul dlg.ShowDialog (), caz DialogResult.Abort lblReturn.Text = "Abort, Abort" caz DialogResult.Cancel lblReturn.Text = "Ai anulat . " cazul DialogResult.OK lblReturn.Text = "Eu sunt OK, Tu esti OK" caz mai lblReturn.Text = "Oricare ar fi ..." sfritul selecta End Sub End Class

Original

Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D public class CreateDialogBaseOnForm public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class DlgTest Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.

Friend WithEvents btnOK As System.Windows.Forms.Button Friend WithEvents btnCancel As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.btnOK = New System.Windows.Forms.Button() Me.btnCancel = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'btnOK ' Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnOK.Location = New System.Drawing.Point(48, 152) Me.btnOK.Name = "btnOK" Me.btnOK.TabIndex = 0 Me.btnOK.Text = "Do It!" ' 'btnCancel ' Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnCancel.Location = New System.Drawing.Point(152, 152) Me.btnCancel.Name = "btnCancel" Me.btnCancel.TabIndex = 1 Me.btnCancel.Text = "Cancel" ' 'DlgTest ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnCancel, Me.btnOK}) Me.Name = "DlgTest" Me.Text = "dlg" Me.ResumeLayout(False) End Sub #End Region

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Ha DialogResult = DialogResult.OK End Sub

Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs DialogResult = DialogResult.Cancel End Sub End Class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub

'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents btnCreate As System.Windows.Forms.Button Friend WithEvents lblReturn As System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.btnCreate = New System.Windows.Forms.Button() Me.lblReturn = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'btnCreate ' Me.btnCreate.Location = New System.Drawing.Point(96, 152) Me.btnCreate.Name = "btnCreate" Me.btnCreate.Size = New System.Drawing.Size(120, 23) Me.btnCreate.TabIndex = 0 Me.btnCreate.Text = "Create Dialog Box" ' 'lblReturn ' Me.lblReturn.Location = New System.Drawing.Point(96, 96) Me.lblReturn.Name = "lblReturn" Me.lblReturn.TabIndex = 1 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblReturn, Me.btnCreate}) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs dim dlg as New DlgTest dlg.Text = "Dialog Test" dlg.FormBorderStyle = FormBorderStyle.FixedDialog dlg.BackColor = Color.Azure dlg.ControlBox = true dlg.MaximizeBox = false dlg.MinimizeBox = false dlg.ShowInTaskbar = false 'dlg.Icon = new Icon(f.GetType(),"YourFile.ICO")

dlg.Size = new Size(300,300) dlg.StartPosition = FormStartPosition.CenterScreen select case dlg.ShowDialog() case DialogResult.Abort lblReturn.Text = "Abort, Abort" case DialogResult.Cancel lblReturn.Text = "You have cancelled." case DialogResult.OK lblReturn.Text = "I'm OK, You're OK" case else lblReturn.Text = "Whatever..." end select End Sub End Class

User Dialog definit

Importurile

System.Windows.Forms

public class UseDefineDialog public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New ()

"Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac Aruncarea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( Aruncarea ) End Sub Private WithEvents btnNewCaption Ca System.Windows.Forms.Button "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container Ca apel

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . btnNewCaption = New System.Windows.Forms.Button () Me.SuspendLayout () " "bt nNewCaption ' Me.btnNewCaption.Location = New System.Drawing.Point ( 106 , 120 ) Me.btnNewCaption.Name = "btnNewCaption" Me . btnNewCaption.Size = New System.Drawing.Size ( 80 , 32 ) Me.btnNewCaption.TabIndex = 0 Me.btnNewCaption.Text = "Legend nou" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.btnNewCaption }) Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea ca

Private Sub btnNewCaption_Click ( ByVal expeditor Ca System.Object, ByVal e Dim frmCaption Ca New form2 () frmCaption.ShowDialog () Dac frmCaption.DialogResult = DialogResult.OK Apoi Me.Text = frmCaption.Caption End If End Sub Private Sub End Sub Form1_Load ( ByVal expeditor Ca System.Object, ByVal e ca

System.Ev

End Class

Public class form2 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac Aruncarea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( Aruncarea ) End Sub Private WithEvents btnOK Ca System.Windows.Forms.Button private WithEvents btnCancel Ca System.Windows.Forms.Button private WithEvents txtNewCaption Ca System.Windows.Forms.TextBox "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container Ca apel

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThroughAttribute () > Private Sub InitializeCompon Me . btnCancel = New System.Windows.Forms.Button () Me.txtNewCaption = New System.Windows.Forms.TextBox () Me.btnOK = New System.Windows.Forms.Button () Me.SuspendLayout () " "bt nCancel " Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnCancel.Location = New System.Drawing.Point ( 141 , 80 ) Me.btnCancel.Name = "btnCancel" Me.btnCancel.Size = Sistem . Drawing.Size ( 72 , 32 ) Me.btnCancel.TabIndex = 2 Me.btnCancel.Text = "Cancel" " "TX tNewCaption ' Me.txtNewCaption.Location = New System.Drawing.Point ( 73 , 32 ) Me.txtNewCaption . Nume = "txtNewCaption" Me.txtNewCaption.Size = New System.Drawing.Size ( 120 , 20 ) Me.txtNewCaption.TabIndex = 1 Me.txtNewCaption.Text = ""

" "bt NOK ' Me.btnOK.DialogResult = sistem . Windows.Forms.DialogResult.OK Me.btnOK.Location = New System.Drawing.Point ( 53 , 80 ) Me.btnOK.Name = "btnOK" Me.btnOK.Size = New System.Drawing.Size ( 72 , 32 ) Me.btnOK.TabIndex = 0 Me.btnOK.Text = "OK" " "Fo RM2 ' Me.AcceptButton = Me.btnOK Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.CancelButton = Me. btnCancel Me.ClientSize = New System.Drawing.Size ( 266 , 154 ) Me.ControlBox = false Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.btnCancel, Me.tx Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.Name = "form2" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "Dialog" Me.ResumeLayout ( Fals ) End Sub # End Regiunea String

Public Caption de proprietate () Ca Obine Caption = txtNewCaption.Text End Get Set ( Value ByVal Ca String ) End End Set proprietate

End Class

Original

Imports System.Windows.Forms public class UseDefineDialog public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If Disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(Disposing) End Sub Private WithEvents btnNewCaption As System.Windows.Forms.Button 'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.btnNewCaption = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'btnNewCaption ' Me.btnNewCaption.Location = New System.Drawing.Point(106, 120) Me.btnNewCaption.Name = "btnNewCaption" Me.btnNewCaption.Size = New System.Drawing.Size(80, 32) Me.btnNewCaption.TabIndex = 0 Me.btnNewCaption.Text = "New Caption" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnNewCaption}) Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub btnNewCaption_Click(ByVal sender As System.Object, ByVal e As System.Eve Dim frmCaption As New Form2() frmCaption.ShowDialog() If frmCaption.DialogResult = DialogResult.OK Then Me.Text = frmCaption.Caption End If End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H End Sub End Class

Public Class Form2 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If Disposing Then If Not (components Is Nothing) Then components.Dispose()

End If End If MyBase.Dispose(Disposing) End Sub Private WithEvents btnOK As System.Windows.Forms.Button Private WithEvents btnCancel As System.Windows.Forms.Button Private WithEvents txtNewCaption As System.Windows.Forms.TextBox 'Required by the Windows Form Designer Private components As System.ComponentModel.Container

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThroughAttribute()> Private Sub InitializeComponent( Me.btnCancel = New System.Windows.Forms.Button() Me.txtNewCaption = New System.Windows.Forms.TextBox() Me.btnOK = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'btnCancel ' Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnCancel.Location = New System.Drawing.Point(141, 80) Me.btnCancel.Name = "btnCancel" Me.btnCancel.Size = New System.Drawing.Size(72, 32) Me.btnCancel.TabIndex = 2 Me.btnCancel.Text = "Cancel" ' 'txtNewCaption ' Me.txtNewCaption.Location = New System.Drawing.Point(73, 32) Me.txtNewCaption.Name = "txtNewCaption" Me.txtNewCaption.Size = New System.Drawing.Size(120, 20) Me.txtNewCaption.TabIndex = 1 Me.txtNewCaption.Text = "" ' 'btnOK ' Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnOK.Location = New System.Drawing.Point(53, 80) Me.btnOK.Name = "btnOK" Me.btnOK.Size = New System.Drawing.Size(72, 32) Me.btnOK.TabIndex = 0 Me.btnOK.Text = "OK" ' 'Form2 ' Me.AcceptButton = Me.btnOK Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.CancelButton = Me.btnCancel Me.ClientSize = New System.Drawing.Size(266, 154) Me.ControlBox = False Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnCancel, Me.txtNew Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.Name = "Form2" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "Dialog" Me.ResumeLayout(False) End Sub

#End Region Public Property Caption() As String Get Caption = txtNewCaption.Text End Get Set(ByVal Value As String) End Set End Property End Class

Get personalizat valoare revenirea dialog

Importurile Importurile

System.ComponentModel System.Windows.Forms

public class CustomDialogEmployee public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Private Sub btnShowDialog_Click ( ByVal expeditor Dim DLG Ca New dlgEmployee Dac Ca System.Object, ByVal e ca

dlg.ShowDialog () = Windows.Forms.DialogResult.OK Apoi MessageBox.Show ( _ dlg.txtFirstName . Text & "" & _ dlg.txtLastName.Text )

Else MessageBox.Show ( "Anulat" ) End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows . Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac

Boolean )

MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.btnShowDialog = New System.Windows.Forms.Button Me.SuspendLayout () " "bt nShowDialog ' Me.btnShowDialog.Location = New System.Drawing.Point ( 56 , 32 ) Me.btnShowDialog.Name = "btnShowDialog" Me. btnShowDialog.Size = New System.Drawing.Size ( 80 , 23 ) Me.btnShowDialog.TabIndex = 1 Me.btnShowDialog.Text = "Arata fereastra de dialog" " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 ! , 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 199 , 93 ) Me.Controls.Add ( Me.btnShowDialog ) Me.Name = "Form1" Me . Text = "CustomDialog" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents btnShowDialog End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial public class dlgEmployee Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.txtLastName = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.btnCancel = New System.Windows.Forms.Button Ca System.Windows.Forms.Button

Boolean )

Me.btnOk = New System.Windows.Forms.Button mine. txtFirstName = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout () " "TX tLastName ' Me.txtLastName.Location = New System.Drawing.Point ( 72 , 33 ) Me . txtLastName.Name = "txtLastName" Me.txtLastName.Size = New System.Drawing.Size ( 168 , 20 ) Me.txtLastName.TabIndex = 7 " 'La bel2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point ( 8 , 33 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 58 , 13 ) Me.Label2.TabIndex = 10 Me.Label2.Text = "Nume" " "bt nCancel ' Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnCancel.Location = New System.Drawing.Point ( 256 , 49 ) Me.btnCancel.Name = "btnCancel" Me.btnCancel.Size = New System.Drawing.Size ( 56 , 24 ) Me.btnCancel.TabIndex = 9 Me.btnCancel.Text = "Cancel" " "bt NOK ' Me.btnOk.DialogResult = System.Windows.Forms. DialogResult.OK Me.btnOk.Location = New System.Drawing.Point ( 256 , 9 ) Me.btnOk.Name = "btnOk" Me.btnOk.Size = New System.Drawing.Size ( 56 , 24 ) Me.btnOk. tabindex = 8 Me.btnOk.Text = "OK" " "TX tFirstName ' Me.txtFirstName.Location = New System.Drawing.Point ( 72 , 9 ) Me.txtFirstName.Name = "txtFirstName" Me.txtFirstName.Size = Nou System.Drawing.Size ( 168 , 20 ) Me.txtFirstName.TabIndex = 5 ' 'La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 8 , 9 ) Me.Label1. name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 57 , 13 ) Me.Label1.TabIndex = 6 Me.Label1.Text = "Nume" " "dl gEmployee ' Me.AcceptButton = Me. btnOk Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.btnOk

Me.ClientSize = Nou

= "dlgEmployee" Me.Text = "Introducei valoarea" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents txtLastName Ca System.Windows.Forms.TextBox prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents btnCancel Ca System.Windows.Forms.Button prieten WithEvents btnOk Ca System.Windows.Forms.Button prieten WithEvents txtFirstName Ca System.Windows.Forms.TextBox prieten WithEvents Label1 Ca System.Windows.Forms.Label End Class

Original

Imports System.ComponentModel Imports System.Windows.Forms public class CustomDialogEmployee public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub btnShowDialog_Click(ByVal sender As System.Object, ByVal e As System.Eve Dim dlg As New dlgEmployee If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then MessageBox.Show( _ dlg.txtFirstName.Text & " " & _ dlg.txtLastName.Text) Else MessageBox.Show("Canceled") End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.btnShowDialog = New System.Windows.Forms.Button Me.SuspendLayout() ' 'btnShowDialog ' Me.btnShowDialog.Location = New System.Drawing.Point(56, 32) Me.btnShowDialog.Name = "btnShowDialog" Me.btnShowDialog.Size = New System.Drawing.Size(80, 23) Me.btnShowDialog.TabIndex = 1 Me.btnShowDialog.Text = "Show Dialog" ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(199, 93) Me.Controls.Add(Me.btnShowDialog) Me.Name = "Form1" Me.Text = "CustomDialog" Me.ResumeLayout(False) End Sub Friend WithEvents btnShowDialog As System.Windows.Forms.Button End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class dlgEmployee Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.txtLastName = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.btnCancel = New System.Windows.Forms.Button Me.btnOk = New System.Windows.Forms.Button Me.txtFirstName = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'txtLastName ' Me.txtLastName.Location = New System.Drawing.Point(72, 33) Me.txtLastName.Name = "txtLastName" Me.txtLastName.Size = New System.Drawing.Size(168, 20) Me.txtLastName.TabIndex = 7 ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(8, 33) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(58, 13) Me.Label2.TabIndex = 10 Me.Label2.Text = "Last Name" ' 'btnCancel ' Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnCancel.Location = New System.Drawing.Point(256, 49) Me.btnCancel.Name = "btnCancel" Me.btnCancel.Size = New System.Drawing.Size(56, 24) Me.btnCancel.TabIndex = 9 Me.btnCancel.Text = "Cancel" ' 'btnOk ' Me.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnOk.Location = New System.Drawing.Point(256, 9) Me.btnOk.Name = "btnOk" Me.btnOk.Size = New System.Drawing.Size(56, 24) Me.btnOk.TabIndex = 8 Me.btnOk.Text = "OK" ' 'txtFirstName ' Me.txtFirstName.Location = New System.Drawing.Point(72, 9) Me.txtFirstName.Name = "txtFirstName" Me.txtFirstName.Size = New System.Drawing.Size(168, 20) Me.txtFirstName.TabIndex = 5 ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(8, 9) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(57, 13) Me.Label1.TabIndex = 6 Me.Label1.Text = "First Name"

' 'dlgEmployee ' Me.AcceptButton = Me.btnOk Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.CancelButton = Me.btnOk Me.ClientSize = New System.Drawing.Size(320, 82) Me.Controls.Add(Me.txtLastName) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.btnCancel) Me.Controls.Add(Me.btnOk) Me.Controls.Add(Me.txtFirstName) Me.Controls.Add(Me.Label1) Me.Name = "dlgEmployee" Me.Text = "Enter Value" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class txtLastName As System.Windows.Forms.TextBox Label2 As System.Windows.Forms.Label btnCancel As System.Windows.Forms.Button btnOk As System.Windows.Forms.Button txtFirstName As System.Windows.Forms.TextBox Label1 As System.Windows.Forms.Label

Dialog 14.69.4.Login

Importurile

System.Windows.Forms

public class LoginDialog public comun Sub principal Application.Run ( New Form1 ) End Sub Clasa final Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows.

InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () componentele = New System.ComponentModel.Container () Me.Text = "Form1" End Sub # End Regiunea Ca obiect, ByVal e ca Ca apel

Bool

Private Sub Form1_Load ( expeditor ByVal Dim frmLogon Ca New LogonDialog () Dim succes Ca Boolean = false Dim ErrorMessage Ca String

System.EventArgs )

Dac frmLogon.ShowDialog () = DialogResult.OK Apoi Daca frmLogon.txtUserid.Text = "Joe" Atunci Daca frmLogon.txtPassword.Text = "parola" Atunci, succes = True Altele ErrorMessage = "Parola invalida!" End Dac Altfel ErrorMessage = " ID utilizator! "invalid End Dac Altfel ErrorMessage = "ncercare Logon ANULAT" Dac End Dac nu succesului Apoi MessageBox.Show ( ErrorMessage, Me.Close () End Dac End Sub End Class

"Logon Failed" , MessageBoxButtons.OK, MessageBox

Public class LogonDialog Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat" New ()

Public Sub

MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub prieten WithEvents btnOK Ca System.Windows.Forms.Button prieten WithEvents btnCancel Ca System.Windows.Forms.Button prieten WithEvents lblUserid Ca System.Windows.Forms.Label prieten WithEvents lblPassword Ca System.Windows.Forms.Label prieten WithEvents txtUserid Ca sistem . Windows.Forms.TextBox prieten WithEvents txtPassword Ca System.Windows.Forms.TextBox "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . btnOK = New System.Windows.Forms.Button () Me.btnCancel = New System.Windows.Forms.Button () Me.txtUserid = New System.Windows.Forms.TextBox () Me.txtPassword = New System.Windows. Forms.TextBox () Me.lblUserid = New System.Windows.Forms.Label () Me.lblPassword = New System.Windows.Forms.Label () Me.SuspendLayout () " "bt NOK ' Me.btnOK.Location = Nou System.Drawing.Point ( 128 , 64 ) Me.btnOK.Name = "btnOK" Me.btnOK.TabIndex = 0 Me.btnOK.Text = "OK" " "bt nCancel ' Me.btnCancel.DialogResult = System.Windows. Forms.DialogResult.Cancel Me.btnCancel.Location = New System.Drawing.Point ( 205 , 64 ) Me.btnCancel.Name = "btnCancel" Me.btnCancel.TabIndex = 1 Me.btnCancel.Text = "Cancel" " "TX tUserid ' Me.txtUserid.Location = New System.Drawing.Point ( 72 , 8 ) Me.txtUserid.Name = "txtUserid" Me.txtUserid.Size = New System.Drawing.Size ( 208 , 20 ) Me.txtUserid.TabIndex = 2 Ca apel

Bool

Me.txtUserid.Text = "Joe" " "TX tPassword ' Me.txtPassword.Location = New System.Drawing.Point ( 72 , 32 ) Me.txtPassword.Name = "txtPassword" Me.txtPassword.PasswordChar = ChrW ( 42 ) Me.txtPassword.Size = New System.Drawing.Size ( 208 , 20 ) Me.txtPassword.TabIndex = 3 Me.txtPassword.Text = "parola" " 'lb lUserid ' Me.lblUserid.AutoSize = True Me.lblUserid . Locaia = New System.Drawing.Point ( 8 , 12 ) Me.lblUserid.Name = "lblUserid" Me.lblUserid.Size = New System.Drawing.Size ( 43 , 13 ) Me.lblUserid.TabIndex = 4 Me.lblUserid . Text = "nume de utilizator:" " 'lb lPassword ' Me.lblPassword.AutoSize = True Me.lblPassword.Location = New System.Drawing.Point ( 8 , 36 ) Me.lblPassword.Name = "lblPassword" Me.lblPassword.Size = New System.Drawing.Size ( 57 , 13 ) Me.lblPassword.TabIndex = 5 Me.lblPassword.Text = "Parola:" " "Lo gonDialog ' Me.AcceptButton = Me.btnOK Me.AutoScaleBaseSize = New System.Drawing. dimensiunea ( 5 , 13 ) Me.CancelButton = Me.btnCancel Me.ClientSize = New System.Drawing.Size ( 290 , 95 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.lblPassword, Me . lb Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.MaximizeBox = Fals Me.MinimizeBox = false Me.Name = "LogonDialog" Me.Text = "Logon" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub btnOK_Click ( ByVal expeditor Dim sUserID Ca String Dim sPassword Ca String sUserID = txtUserid.Text sPassword = txtPassword.Text

System.Eve

Dac sUserID.Trim () = "" Atunci, MessageBox.Show ( "nume de utilizator nu poate fi gol." , "Eroare" , MessageBoxBu txtUserid.Select () Altfel Dac sPassword.Trim () = "" Atunci, MessageBox.Show ( "Parola nu poate fi gol." , "Eroare" , MessageBoxButtons.OK, txtPassword.Select ()

Altfel Me.DialogResult = DialogResult.OK End Dac End Dac End Sub End Class

Original

Imports System.Windows.Forms public class LoginDialog public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() components = New System.ComponentModel.Container() Me.Text = "Form1" End Sub #End Region

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles My Dim frmLogon As New LogonDialog() Dim success As Boolean = False Dim errorMessage As String If frmLogon.ShowDialog() = DialogResult.OK Then If frmLogon.txtUserid.Text = "Joe" Then If frmLogon.txtPassword.Text = "password" Then success = True Else errorMessage = "Invalid Password!" End If Else errorMessage = "Invalid User ID!" End If Else errorMessage = "Logon Attempt Cancelled" End If

If Not success Then MessageBox.Show(errorMessage, "Logon Failed", MessageBoxButtons.OK, MessageBoxIcon Me.Close() End If End Sub End Class Public Class LogonDialog Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents btnOK As System.Windows.Forms.Button Friend WithEvents btnCancel As System.Windows.Forms.Button

Friend Friend Friend Friend

WithEvents WithEvents WithEvents WithEvents

lblUserid As System.Windows.Forms.Label lblPassword As System.Windows.Forms.Label txtUserid As System.Windows.Forms.TextBox txtPassword As System.Windows.Forms.TextBox

'Required by the Windows Form Designer Private components As System.ComponentModel.Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.btnOK = New System.Windows.Forms.Button() Me.btnCancel = New System.Windows.Forms.Button() Me.txtUserid = New System.Windows.Forms.TextBox() Me.txtPassword = New System.Windows.Forms.TextBox() Me.lblUserid = New System.Windows.Forms.Label() Me.lblPassword = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'btnOK ' Me.btnOK.Location = New System.Drawing.Point(128, 64) Me.btnOK.Name = "btnOK" Me.btnOK.TabIndex = 0 Me.btnOK.Text = "OK" ' 'btnCancel ' Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnCancel.Location = New System.Drawing.Point(205, 64) Me.btnCancel.Name = "btnCancel" Me.btnCancel.TabIndex = 1 Me.btnCancel.Text = "Cancel" ' 'txtUserid ' Me.txtUserid.Location = New System.Drawing.Point(72, 8) Me.txtUserid.Name = "txtUserid" Me.txtUserid.Size = New System.Drawing.Size(208, 20) Me.txtUserid.TabIndex = 2 Me.txtUserid.Text = "Joe" ' 'txtPassword ' Me.txtPassword.Location = New System.Drawing.Point(72, 32) Me.txtPassword.Name = "txtPassword" Me.txtPassword.PasswordChar = ChrW(42) Me.txtPassword.Size = New System.Drawing.Size(208, 20) Me.txtPassword.TabIndex = 3 Me.txtPassword.Text = "password" ' 'lblUserid ' Me.lblUserid.AutoSize = True Me.lblUserid.Location = New System.Drawing.Point(8, 12) Me.lblUserid.Name = "lblUserid" Me.lblUserid.Size = New System.Drawing.Size(43, 13) Me.lblUserid.TabIndex = 4 Me.lblUserid.Text = "UserID:" '

'lblPassword ' Me.lblPassword.AutoSize = True Me.lblPassword.Location = New System.Drawing.Point(8, 36) Me.lblPassword.Name = "lblPassword" Me.lblPassword.Size = New System.Drawing.Size(57, 13) Me.lblPassword.TabIndex = 5 Me.lblPassword.Text = "Password:" ' 'LogonDialog ' Me.AcceptButton = Me.btnOK Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.CancelButton = Me.btnCancel Me.ClientSize = New System.Drawing.Size(290, 95) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblPassword, Me.lblUseri Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "LogonDialog" Me.Text = "Logon" Me.ResumeLayout(False) End Sub #End Region

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Ha Dim sUserID As String Dim sPassword As String sUserID = txtUserid.Text sPassword = txtPassword.Text

If sUserID.Trim() = "" Then MessageBox.Show("UserID cannot be blank.", "Error", MessageBoxButtons.OK, MessageB txtUserid.Select() Else If sPassword.Trim() = "" Then MessageBox.Show("Password cannot be blank.", "Error", MessageBoxButtons.OK, Mess txtPassword.Select() Else Me.DialogResult = DialogResult.OK End If End If End Sub End Class

Dialog 14.69.5.About

Importurile

System.Windows.Forms

public class AboutDialog public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents Button1 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout () " "Bu tton1 " Me.Button1 . Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, Me.Button1.Location = Sistem . Drawing.Point ( 160 , 168 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 80 , 32 ) Me.Button1.TabIndex = 0 Me.Button1.Text = "Despre " "

"Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 266 ) Me.Controls.Add ( Me.Button1 ) Me.ResumeLayout ( fals ) End Sub Private Sub showaboutBox () Dim aboutbox Ca noi Despre aboutbox.ShowDialog ( mine ) End Sub Private Sub Button1_Click ( ByVal expeditor ShowAboutBox () End Sub End Class Public class Despre Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Ca

System.Object, ByVal e

ca

System

Bool

System.ComponentModel.IContainer

Prietenul WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents LinkLabel1 Ca System.Windows.Forms.LinkLabel prieten WithEvents Button1 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.LinkLabel1 = New System.Windows.Forms.LinkLabel Me.Button1 = Sistem . Windows.Forms.Button Me.SuspendLayout () " "La bel1 ' Me.Label1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 15.75 !, Sy Me.Label1.Location = New System.Drawing.Point ( 32 , 24 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 152 , 32 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "java2s.com" " "La bel2

' Me.Label2.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 12.0 !, sis Me.Label2.Location = New System.Drawing.Point ( 32 , 80 ) Me.Label2.Name = "Label2" Me. Label2.Size = New System.Drawing.Size ( 144 , 24 ) Me.Label2.TabIndex = 1 Me.Label2.Text = "versiune: 7.1.0391" " "Li nkLabel1 ' Me.LinkLabel1.Font = New System.Drawing . Font ( "Microsoft Sans Serif" , 12.0 Me.LinkLabel1.Location = New System.Drawing.Point ( 32 , 128 ) Me.LinkLabel1.Name = "LinkLabel1" Me.LinkLabel1.Size = New System.Drawing.Size ( 160 , 32 ) Me.LinkLabel1.TabIndex = 2 Me.LinkLabel1.TabStop = True Me.LinkLabel1.Text = "www . java2s.com " " "Bu tton1 ' Me.Button1.DialogResult = System.Windows.Forms.DialogResult.OK Me.Button1.Location = New System.Drawing.Point ( 176 , 176 ) Me.Button1.Name = "Button1 " Me.Button1.Size = New System.Drawing.Size ( 80 , 32 ) Me.Button1.TabIndex = 3 Me.Button1.Text = "OK" " "Ab de ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= System.Windows.Forms.FormBorderStyle.FixedDialog Me.MaximizeBox = Fals Me.MinimizeBox = false Me.Name = "Despre" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "Despre" Me.ResumeLayout ( Fals ) End Sub

Sub Private LinkLabel1_LinkClicked ( expeditor ByVal Ca System.Object, ByVal e System.Diagnostics.Process.Start ( "http://www.java2s.com" ) End Sub End Class

Original

Dialog 14.69.5.About

Importurile

System.Windows.Forms

public class AboutDialog public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Prietenul WithEvents Button1 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout () " "Bu tton1 " Me.Button1 . Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 9.75 !, Me.Button1.Location = Sistem . Drawing.Point ( 160 , 168 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 80 , 32 ) Me.Button1.TabIndex = 0 Me.Button1.Text = "Despre " "

"Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 266 ) Me.Controls.Add ( Me.Button1 ) Me.ResumeLayout ( fals ) End Sub Private Sub showaboutBox () Dim aboutbox Ca noi Despre aboutbox.ShowDialog ( mine ) End Sub Private Sub Button1_Click ( ByVal expeditor ShowAboutBox () End Sub End Class Public class Despre Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Ca

System.Object, ByVal e

ca

System

Bool

System.ComponentModel.IContainer

Prietenul WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents LinkLabel1 Ca System.Windows.Forms.LinkLabel prieten WithEvents Button1 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.LinkLabel1 = New System.Windows.Forms.LinkLabel Me.Button1 = Sistem . Windows.Forms.Button Me.SuspendLayout () " "La bel1 ' Me.Label1.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 15.75 !, Sy Me.Label1.Location = New System.Drawing.Point ( 32 , 24 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 152 , 32 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "java2s.com" " "La bel2

' Me.Label2.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 12.0 !, sis Me.Label2.Location = New System.Drawing.Point ( 32 , 80 ) Me.Label2.Name = "Label2" Me. Label2.Size = New System.Drawing.Size ( 144 , 24 ) Me.Label2.TabIndex = 1 Me.Label2.Text = "versiune: 7.1.0391" " "Li nkLabel1 ' Me.LinkLabel1.Font = New System.Drawing . Font ( "Microsoft Sans Serif" , 12.0 Me.LinkLabel1.Location = New System.Drawing.Point ( 32 , 128 ) Me.LinkLabel1.Name = "LinkLabel1" Me.LinkLabel1.Size = New System.Drawing.Size ( 160 , 32 ) Me.LinkLabel1.TabIndex = 2 Me.LinkLabel1.TabStop = True Me.LinkLabel1.Text = "www . java2s.com " " "Bu tton1 ' Me.Button1.DialogResult = System.Windows.Forms.DialogResult.OK Me.Button1.Location = New System.Drawing.Point ( 176 , 176 ) Me.Button1.Name = "Button1 " Me.Button1.Size = New System.Drawing.Size ( 80 , 32 ) Me.Button1.TabIndex = 3 Me.Button1.Text = "OK" " "Ab de ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Nou

= System.Windows.Forms.FormBorderStyle.FixedDialog Me.MaximizeBox = Fals Me.MinimizeBox = false Me.Name = "Despre" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent Me.Text = "Despre" Me.ResumeLayout ( Fals ) End Sub

Sub Private LinkLabel1_LinkClicked ( expeditor ByVal Ca System.Object, ByVal e System.Diagnostics.Process.Start ( "http://www.java2s.com" ) End Sub End Class

Dialog se aplic metoda

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class DialogApplyMethod public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. WithEvents prieten btnCreate Ca System.Windows.Forms.Button prieten WithEvents lblReturn Ca System.Windows.Forms.Label <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.btnCreate = New System.Windows.Forms.Button () Me.lblReturn = New System.Windows.Forms.Label () Ca apel

Bool

Me . SuspendLayout () " "bt nCreate ' Me.btnCreate.Location = New System.Drawing.Point ( 72 , 144 ) Me.btnCreate.Name = "btnCreate" Me.btnCreate.Size = New System.Drawing.Size ( 152 , 23 ) Me.btnCreate.TabIndex = 0 Me.btnCreate.Text = "Creaza Caseta de dialog" " 'lb lReturn ' Me.lblReturn.Location = New System.Drawing.Point ( 88 , 72 ) Me.lblReturn.Name = "lblReturn " Me.lblReturn.TabIndex = 1 ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.lblReturn, Me.btnCreate Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

publice sub UpdateLabel ( str. ca ir ) lblReturn.Text = str finali sub Private Sub btnCreate_Click ( ByVal expeditor dim DLG ca noi DialogDemo ( mine ) dlg.EnableApplyButton = false dlg.ShowDialog () n cazul n care dlg.DialogResult = DialogResult.OK apoi lblReturn.Text = dlg.TextOut altceva lblReturn.Text = dlg.DialogResult.ToString () final, dac End Sub End Class public class DialogDemo motenete formular btnApply dim ca Button dim txt ca TextBox f dim ca Form1 publice sub noi ( f ca Form1 ) myBase.New me.f = f FormBorderStyle = FormBorderStyle.FixedDialog ControlBox = false MaximizeBox = false MinimizeBox = false ShowInTaskbar = false Ca System.Object, ByVal e ca

System

size = new Dimensiune ( 400 , 200 ) StartPosition = FormStartPosition.CenterScreen btnOK dim ca New Button btnOK.Text = "OK" btnOK.DialogResult = DialogResult.OK btnOK.Location = new Punct ( 50 , 50 ) Controls.Add ( btnOK ) btnApply = new Button () btnApply.Text = "Aplic" btnApply . Locaia = new Punct ( 150 , 50 ) btnApply.Enabled = false AddHandler btnApply.Click, AddressOf ApplyOnClick Controls.Add ( btnApply ) btnCancel dim ca noi Button () btnCancel.Text = "Cancel" btnCancel.DialogResult = DialogResult.Cancel btnCancel . Locaia = new Punct ( 250 , 50 ) Controls.Add ( btnCancel ) txt = new caseta () txt.Size = new Dimensiune ( 100 , 15 ) txt.Location = new Punct ( 150 , 15 ) AddHandler txt.TextChanged, AddressOf TextBoxChanged Controls.Add ( txt ) finali sub

privat sub ApplyOnClick ( expeditor ca obiect, e ca EventArgs ) f.UpdateLabel ( txt.Text ) EnableApplyButton = false sfritul sub privai sub TextBoxChanged ( expeditor ca obiect, e ca EventArgs ) dim txt ca TextBox = Ctype ( expeditor, TextBox ) dim DLG ca DialogDemo = Ctype ( txt.Parent, DialogDemo ) dlg.EnableApplyButton = true end sub publice EnableApplyButton proprietate ca Boolean obine ntoarcerea btnApply.Enabled final se stabili btnApply.Enabled = valoarea sfritul set sfritul proprietate public Readonly proprietate TextOut ca ir se ntoarc txt.Text sfritul lua sfrit proprietate clasa final

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DialogApplyMethod public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents btnCreate As System.Windows.Forms.Button Friend WithEvents lblReturn As System.Windows.Forms.Label

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.btnCreate = New System.Windows.Forms.Button() Me.lblReturn = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'btnCreate ' Me.btnCreate.Location = New System.Drawing.Point(72, 144) Me.btnCreate.Name = "btnCreate" Me.btnCreate.Size = New System.Drawing.Size(152, 23) Me.btnCreate.TabIndex = 0 Me.btnCreate.Text = "Create Dialog Box" ' 'lblReturn ' Me.lblReturn.Location = New System.Drawing.Point(88, 72) Me.lblReturn.Name = "lblReturn" Me.lblReturn.TabIndex = 1 ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblReturn, Me.btnCreate}) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region public sub UpdateLabel(str as String) lblReturn.Text = str end sub

Private Sub btnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs dim dlg as new DialogDemo( me ) dlg.EnableApplyButton = false dlg.ShowDialog() if dlg.DialogResult = DialogResult.OK then lblReturn.Text = dlg.TextOut else lblReturn.Text = dlg.DialogResult.ToString() end if End Sub End Class public class DialogDemo inherits Form dim btnApply as Button dim txt as TextBox dim f as Form1 public sub new (f as Form1) myBase.New me.f = f FormBorderStyle = FormBorderStyle.FixedDialog ControlBox = false

MaximizeBox = false MinimizeBox = false ShowInTaskbar = false Size = new Size(400,200) StartPosition = FormStartPosition.CenterScreen dim btnOK as New Button btnOK.Text = "OK" btnOK.DialogResult = DialogResult.OK btnOK.Location = new Point(50,50) Controls.Add(btnOK) btnApply = new Button() btnApply.Text = "Apply" btnApply.Location = new Point(150,50) btnApply.Enabled = false AddHandler btnApply.Click, AddressOf ApplyOnClick Controls.Add(btnApply) dim btnCancel as new Button() btnCancel.Text = "Cancel" btnCancel.DialogResult = DialogResult.Cancel btnCancel.Location = new Point(250,50) Controls.Add(btnCancel) txt = new TextBox() txt.Size = new Size(100,15) txt.Location = new Point(150,15) AddHandler txt.TextChanged, AddressOf TextBoxChanged Controls.Add(txt) end sub private sub ApplyOnClick(sender as Object, e as EventArgs) f.UpdateLabel(txt.Text) EnableApplyButton = false end sub private sub TextBoxChanged(sender as Object, e as EventArgs) dim txt as TextBox = CType(sender,TextBox) dim dlg as DialogDemo = CType(txt.Parent,DialogDemo) dlg.EnableApplyButton = true end sub public property EnableApplyButton as Boolean get return btnApply.Enabled end get set btnApply.Enabled = value end set end property public ReadOnly property TextOut as string get return txt.Text end get end property end class

Custom dialog cu clasa personalizat

Importurile

System.Windows.Forms

public class CustomDialogWithCustomClass public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows Ca apel

Bool

"Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button <System.Diagnostics . DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 104 , 88 ) Me . Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Sistem . Drawing.Size ( 292 , 266 ) Me.Controls.Add ( Me.Button1 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

Private Sub Button1_Click ( _ expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) _ Manere Button1.Click Dim Dim Dim Dim Dim Dim adr Ca Noua adresa adresa Ca New addressDialog Street Ca String = "124" Oraul Ca String = "R" ar Ca String = "VA" PostalCode Ca String = "11111"

addr.Street = Street addr.City = City addr.Country = ara addr.PostalCode = PostalCode address.Address = adr Dac address.ShowDialog = DialogResult.OK Apoi, adr = address.Address End Dac End Sub End Class Public class adresa Dim m_Street Ca String Dim m_City Ca String Dim m_PostalCode Ca String Dim m_Country Ca String Public Property Street () Obine Revenire m_Street Ca String

End Get Set ( Value ByVal Ca String ) m_Street = Valoare End Set End proprietate Publice de proprietate Oraul () Ca Obine Revenire m_City End Get Set ( Value ByVal Ca String ) m_City = Valoare End Set End proprietate Public PostalCode Proprietatea () Ca Obine Revenire m_PostalCode End Get Set ( Value ByVal Ca String ) m_PostalCode = Valoare End Set End proprietate Public Property Tara () Ca String Obine Revenire m_Country End Get Set ( Value ByVal Ca String ) m_Country = Valoare End Set End proprietate End Class Public class addressDialog Motenete System.Windows.Forms.Form Public Address Proprietatea () Ca adresa Ia Dim newAddress Ca o adres New newAddress.City = txtCity.Text newAddress.Country = txtCountry.Text newAddress.PostalCode = txtPostalCode.Text newAddress.Street = txtStreet . Textul newAddress napoi End Get Set ( Value ByVal Ca Adresa ) txtCity.Text = Value.City txtCountry.Text = Value.Country txtPostalCode.Text = Value.PostalCode txtStreet.Text = Value.Street End Set End proprietate # Region "cod pentru Windows Form Designer generat" String

String

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows.

InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. WithEvents prieten saveAddress Ca System.Windows.Forms.Button prieten WithEvents cancelAddress Ca System.Windows.Forms.Button prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents Label3 Ca System.Windows.Forms.Label prieten WithEvents Label4 Ca System.Windows.Forms. Eticheta prieten WithEvents txtStreet Ca System.Windows.Forms.TextBox prieten WithEvents txtCity Ca System.Windows.Forms.TextBox prieten WithEvents txtPostalCode Ca System.Windows.Forms.TextBox prieten WithEvents txtCountry Ca System.Windows.Forms.TextBox <System.Diagnostics. DebuggerStepThrough () > Private Sub InitializeComponent () Me.saveAddress = New System.Windows.Forms.Button Me.cancelAddress = New System.Windows.Forms.Button Me.txtStreet = New System.Windows.Forms.TextBox Me.txtCity = Nou System.Windows.Forms.TextBox Me.txtPostalCode = New System.Windows.Forms.TextBox Me.txtCountry = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = Sistem. Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.SuspendLayout () " "sa veAddress ' Me.saveAddress.Anchor = Ctype (( System. Windows.Forms.AnchorStyles.Bottom Sau S Me.saveAddress.DialogResult = System.Windows.Forms.DialogResult.OK Me.saveAddress.FlatStyle = sistem. Windows.Forms.FlatStyle.System Me.saveAddress.Location = New System.Drawing.Point ( 128 , 120 ) Me.saveAddress.Name = "saveAddress" Me.saveAddress.TabIndex = 0 Me.saveAddress.Text = "OK" ' "CA ncelAddress ' Me.cancelAddress.Anchor = Ctype (( System.Windows.Forms.AnchorStyles.Bottom sau Me.cancelAddress.DialogResult = sistem. Windows.Forms.DialogResult.Cancel Me.cancelAddress.FlatStyle = System.Windows.Forms.FlatStyle.System Me.cancelAddress.Location = New System.Drawing.Point ( 208 , 120 )

Me.cancelAddress.Name = "cancelAddress" Me. cancelAddress.TabIndex = 1 Me.cancelAddress.Text = "Cancel" " "TX tStreet ' Me.txtStreet.Location = New System.Drawing.Point ( 80 , 16 ) Me.txtStreet.Name = "txtStreet" Me.txtStreet.Size = New System.Drawing.Size ( 200 , 20 ) Me.txtStreet.TabIndex = 2 Me.txtStreet.Text = "txtStreet" " "TX tCity ' Me.txtCity.Location = New System.Drawing.Point ( 80 , 40 ) Me.txtCity.Name = "txtCity" Me.txtCity.Size = New System.Drawing.Size ( 200 , 20 ) Me.txtCity.TabIndex = 3 Me.txtCity.Text = "txtCity" " "TX tPostalCode " Me.txtPostalCode . Locaia = New System.Drawing.Point ( 80 , 64 ) Me.txtPostalCode.Name = "txtPostalCode" Me.txtPostalCode.Size = New System.Drawing.Size ( 112 , 20 ) Me.txtPostalCode.TabIndex = 4 Me.txtPostalCode . Text = "txtPostalCode" " "TX tCountry ' Me.txtCountry.Location = New System.Drawing.Point ( 80 , 88 ) Me.txtCountry.Name = "txtCountry" Me.txtCountry.Size = New System.Drawing.Size ( 200 , 20 ) Me.txtCountry.TabIndex = 5 Me.txtCountry.Text = "txtCountry" " "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 39 , 18 ) Me . Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 38 , 16 ) Me.Label1.TabIndex = 6 Me.Label1.Text = "Street:" " "La bel2 " Me.Label2 . AutoSize = True Me.Label2.Location = New System.Drawing.Point ( 50 , 42 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 27 , 16 ) Me.Label2 . tabindex = 7 Me.Label2.Text = "Oraul:" " "La bel3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point ( 8 , 66 ) Me.Label3.Name = " Label3 " Me.Label3.Size = New System.Drawing.Size ( 69 , 16 ) Me.Label3.TabIndex = 8

Me.Label3.Text = "Cod postal:" " "La bel4 ' Me.Label4.AutoSize = True Me . Label4.Location = New System.Drawing.Point ( 33 , 90 ) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size ( 44 , 16 ) Me.Label4.TabIndex = 9 Me . Label4.Text = "Tara" " "ad dressDialog ' Me.AcceptButton = Me.saveAddress Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.CancelButton = Me.cancelAddress Me.ClientSize = Nou

= System.Windows.Forms.FormBorderStyle.FixedDialog Me.MaximizeBox = Fals Me.MinimizeBox = false Me.Name = "addressDialog" Me.Text = "Adresa Dialog" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub saveAddress_Click ( ByVal expeditor Me.Close () End Sub Private Sub cancelAddress_Click ( ByVal expeditor Me.Close () End Sub End Class

Sy

Ca

System.Object, ByVal e

ca

Original

Imports System.Windows.Forms public class CustomDialogWithCustomClass public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(104, 88) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click Dim addr As New address Dim address As New addressDialog Dim Dim Dim Dim Street As String = "124 " City As String = "R" Country As String = "VA" PostalCode As String = "11111"

addr.Street = Street addr.City = City addr.Country = Country addr.PostalCode = PostalCode address.Address = addr If address.ShowDialog = DialogResult.OK Then addr = address.Address End If End Sub End Class Public Class address Dim m_Street As String Dim m_City As String Dim m_PostalCode As String Dim m_Country As String Public Property Street() As String Get Return m_Street End Get Set(ByVal Value As String) m_Street = Value End Set

End Property Public Property City() As String Get Return m_City End Get Set(ByVal Value As String) m_City = Value End Set End Property Public Property PostalCode() As String Get Return m_PostalCode End Get Set(ByVal Value As String) m_PostalCode = Value End Set End Property Public Property Country() As String Get Return m_Country End Get Set(ByVal Value As String) m_Country = Value End Set End Property End Class Public Class addressDialog Inherits System.Windows.Forms.Form Public Property Address() As address Get Dim newAddress As New address newAddress.City = txtCity.Text newAddress.Country = txtCountry.Text newAddress.PostalCode = txtPostalCode.Text newAddress.Street = txtStreet.Text Return newAddress End Get Set(ByVal Value As Address) txtCity.Text = Value.City txtCountry.Text = Value.Country txtPostalCode.Text = Value.PostalCode txtStreet.Text = Value.Street End Set End Property #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call

End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents saveAddress As System.Windows.Forms.Button Friend WithEvents cancelAddress As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents txtStreet As System.Windows.Forms.TextBox Friend WithEvents txtCity As System.Windows.Forms.TextBox Friend WithEvents txtPostalCode As System.Windows.Forms.TextBox Friend WithEvents txtCountry As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.saveAddress = New System.Windows.Forms.Button Me.cancelAddress = New System.Windows.Forms.Button Me.txtStreet = New System.Windows.Forms.TextBox Me.txtCity = New System.Windows.Forms.TextBox Me.txtPostalCode = New System.Windows.Forms.TextBox Me.txtCountry = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'saveAddress ' Me.saveAddress.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or Syste Me.saveAddress.DialogResult = System.Windows.Forms.DialogResult.OK Me.saveAddress.FlatStyle = System.Windows.Forms.FlatStyle.System Me.saveAddress.Location = New System.Drawing.Point(128, 120) Me.saveAddress.Name = "saveAddress" Me.saveAddress.TabIndex = 0 Me.saveAddress.Text = "OK" ' 'cancelAddress ' Me.cancelAddress.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or Sys Me.cancelAddress.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.cancelAddress.FlatStyle = System.Windows.Forms.FlatStyle.System Me.cancelAddress.Location = New System.Drawing.Point(208, 120) Me.cancelAddress.Name = "cancelAddress" Me.cancelAddress.TabIndex = 1 Me.cancelAddress.Text = "Cancel" '

'txtStreet ' Me.txtStreet.Location = New System.Drawing.Point(80, 16) Me.txtStreet.Name = "txtStreet" Me.txtStreet.Size = New System.Drawing.Size(200, 20) Me.txtStreet.TabIndex = 2 Me.txtStreet.Text = "txtStreet" ' 'txtCity ' Me.txtCity.Location = New System.Drawing.Point(80, 40) Me.txtCity.Name = "txtCity" Me.txtCity.Size = New System.Drawing.Size(200, 20) Me.txtCity.TabIndex = 3 Me.txtCity.Text = "txtCity" ' 'txtPostalCode ' Me.txtPostalCode.Location = New System.Drawing.Point(80, 64) Me.txtPostalCode.Name = "txtPostalCode" Me.txtPostalCode.Size = New System.Drawing.Size(112, 20) Me.txtPostalCode.TabIndex = 4 Me.txtPostalCode.Text = "txtPostalCode" ' 'txtCountry ' Me.txtCountry.Location = New System.Drawing.Point(80, 88) Me.txtCountry.Name = "txtCountry" Me.txtCountry.Size = New System.Drawing.Size(200, 20) Me.txtCountry.TabIndex = 5 Me.txtCountry.Text = "txtCountry" ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(39, 18) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(38, 16) Me.Label1.TabIndex = 6 Me.Label1.Text = "Street:" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(50, 42) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(27, 16) Me.Label2.TabIndex = 7 Me.Label2.Text = "City:" ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(8, 66) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(69, 16) Me.Label3.TabIndex = 8 Me.Label3.Text = "Postal Code:" ' 'Label4 '

Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(33, 90) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(44, 16) Me.Label4.TabIndex = 9 Me.Label4.Text = "Country" ' 'addressDialog ' Me.AcceptButton = Me.saveAddress Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.CancelButton = Me.cancelAddress Me.ClientSize = New System.Drawing.Size(292, 152) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.txtCountry) Me.Controls.Add(Me.txtPostalCode) Me.Controls.Add(Me.txtCity) Me.Controls.Add(Me.txtStreet) Me.Controls.Add(Me.cancelAddress) Me.Controls.Add(Me.saveAddress) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "addressDialog" Me.Text = "Address Dialog" Me.ResumeLayout(False) End Sub #End Region

Private Sub saveAddress_Click(ByVal sender As System.Object, ByVal e As System.Event Me.Close() End Sub

Private Sub cancelAddress_Click(ByVal sender As System.Object, ByVal e As System.Eve Me.Close() End Sub End Class

Dialog cu proprieti

Importurile

System.Windows.Forms

public class DialogWithProperties public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button <System.Diagnostics . DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 104 , 88 ) Me . Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Sistem . Drawing.Size ( 292 , 266 ) Me.Controls.Add ( Me.Button1 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub Ca apel

Bool

# End

Regiunea

Private Sub Button1_Click ( _ expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) _ Manere Button1.Click Dim Dim Dim Dim Dim adresa Ca New addressDialog

Street Ca String = "aaaa" Oraul Ca String = "wwww" ar Ca String = "QQQQ" PostalCode Ca String = "93333"

address.Street = Street address.City = City address.Country = ara address.PostalCode = PostalCode address.ShowDialog = DialogResult.OK Apoi Street = address.Street Oraul = address.City ar = address.Country PostalCode = address.PostalCode End Dac End Sub End Class public class addressDialog Motenete System.Windows.Forms.Form Public Property Street ( ) Ca String Obine Revenire Me.txtStreet.Text End Get Set ( Value ByVal Ca String ) Me.txtStreet.Text = Valoare End Set End proprietate Publice de proprietate Oraul () Ca Obine Revenire Me.txtCity.Text End Get Set ( Value ByVal Ca String ) Me.txtCity.Text = Valoare End Set End proprietate String Dac

Public PostalCode Proprietatea () Ca String Obine Revenire Me.txtPostalCode.Text End Get Set ( Value ByVal Ca String ) Me.txtPostalCode.Text = Valoare End Set End proprietate Public Property Tara () Ca String Obine Revenire Me.txtCountry.Text End Get

Set ( Value ByVal Ca String ) Me.txtCountry.Text = Valoare End Set End proprietate # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer Ca apel

Bool

"NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. WithEvents prieten saveAddress Ca System.Windows.Forms.Button prieten WithEvents cancelAddress Ca System.Windows.Forms.Button prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents Label3 Ca System.Windows.Forms.Label prieten WithEvents Label4 Ca System.Windows.Forms. Eticheta prieten WithEvents txtStreet Ca System.Windows.Forms.TextBox prieten WithEvents txtCity Ca System.Windows.Forms.TextBox prieten WithEvents txtPostalCode Ca System.Windows.Forms.TextBox prieten WithEvents txtCountry Ca System.Windows.Forms.TextBox <System.Diagnostics. DebuggerStepThrough () > Private Sub InitializeComponent () Me.saveAddress = New System.Windows.Forms.Button Me.cancelAddress = New System.Windows.Forms.Button Me.txtStreet = New System.Windows.Forms.TextBox Me.txtCity = Nou System.Windows.Forms.TextBox Me.txtPostalCode = New System.Windows.Forms.TextBox Me.txtCountry = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = Sistem. Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.SuspendLayout () " "sa veAddress ' Me.saveAddress.Anchor = Ctype (( System. Windows.Forms.AnchorStyles.Bottom Sau S Me.saveAddress.DialogResult = System.Windows.Forms.DialogResult.OK Me.saveAddress.FlatStyle = sistem. Windows.Forms.FlatStyle.System

Me.saveAddress.Location = New System.Drawing.Point ( 128 , 120 ) Me.saveAddress.Name = "saveAddress" Me.saveAddress.TabIndex = 0 Me.saveAddress.Text = "OK" ' "CA ncelAddress ' Me.cancelAddress.Anchor = Ctype (( System.Windows.Forms.AnchorStyles.Bottom sau Me.cancelAddress.DialogResult = sistem. Windows.Forms.DialogResult.Cancel Me.cancelAddress.FlatStyle = System.Windows.Forms.FlatStyle.System Me.cancelAddress.Location = New System.Drawing.Point ( 208 , 120 ) Me.cancelAddress.Name = "cancelAddress" Me. cancelAddress.TabIndex = 1 Me.cancelAddress.Text = "Cancel" " "TX tStreet ' Me.txtStreet.Location = New System.Drawing.Point ( 80 , 16 ) Me.txtStreet.Name = "txtStreet" Me.txtStreet.Size = New System.Drawing.Size ( 200 , 20 ) Me.txtStreet.TabIndex = 2 Me.txtStreet.Text = "txtStreet" " "TX tCity ' Me.txtCity.Location = New System.Drawing.Point ( 80 , 40 ) Me.txtCity.Name = "txtCity" Me.txtCity.Size = New System.Drawing.Size ( 200 , 20 ) Me.txtCity.TabIndex = 3 Me.txtCity.Text = "txtCity" " "TX tPostalCode " Me.txtPostalCode . Locaia = New System.Drawing.Point ( 80 , 64 ) Me.txtPostalCode.Name = "txtPostalCode" Me.txtPostalCode.Size = New System.Drawing.Size ( 112 , 20 ) Me.txtPostalCode.TabIndex = 4 Me.txtPostalCode . Text = "txtPostalCode" " "TX tCountry ' Me.txtCountry.Location = New System.Drawing.Point ( 80 , 88 ) Me.txtCountry.Name = "txtCountry" Me.txtCountry.Size = New System.Drawing.Size ( 200 , 20 ) Me.txtCountry.TabIndex = 5 Me.txtCountry.Text = "txtCountry" " "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 39 , 18 ) Me . Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 38 , 16 ) Me.Label1.TabIndex = 6 Me.Label1.Text = "Street:" " "La bel2 " Me.Label2 . AutoSize = True Me.Label2.Location = New System.Drawing.Point ( 50 , 42 ) Me.Label2.Name = "Label2"

Me.Label2.Size = New System.Drawing.Size ( 27 , 16 ) Me.Label2 . tabindex = 7 Me.Label2.Text = "Oraul:" " "La bel3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point ( 8 , 66 ) Me.Label3.Name = " Label3 " Me.Label3.Size = New System.Drawing.Size ( 69 , 16 ) Me.Label3.TabIndex = 8 Me.Label3.Text = "Cod postal:" " "La bel4 ' Me.Label4.AutoSize = True Me . Label4.Location = New System.Drawing.Point ( 33 , 90 ) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size ( 44 , 16 ) Me.Label4.TabIndex = 9 Me . Label4.Text = "Tara" " "ad dressDialog ' Me.AcceptButton = Me.saveAddress Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.CancelButton = Me.cancelAddress Me.ClientSize = Nou

= System.Windows.Forms.FormBorderStyle.FixedDialog Me.MaximizeBox = Fals Me.MinimizeBox = false Me.Name = "addressDialog" Me.Text = "Adresa Dialog" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub saveAddress_Click ( ByVal expeditor Me.Close () End Sub Private Sub cancelAddress_Click ( ByVal expeditor Me.Close () End Sub End Class

Sy

Ca

System.Object, ByVal e

ca

Original

Imports System.Windows.Forms public class DialogWithProperties public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button1 '

Me.Button1.Location = New System.Drawing.Point(104, 88) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Button1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click Dim address As New addressDialog Dim Dim Dim Dim Street As String = "aaaa" City As String = "wwww" Country As String = "qqqq" PostalCode As String = "93333"

address.Street = Street address.City = City address.Country = Country address.PostalCode = PostalCode If address.ShowDialog = DialogResult.OK Then Street = address.Street City = address.City Country = address.Country PostalCode = address.PostalCode End If End Sub End Class Public Class addressDialog Inherits System.Windows.Forms.Form Public Property Street() As String Get Return Me.txtStreet.Text End Get Set(ByVal Value As String) Me.txtStreet.Text = Value End Set End Property Public Property City() As String Get Return Me.txtCity.Text End Get Set(ByVal Value As String) Me.txtCity.Text = Value End Set

End Property Public Property PostalCode() As String Get Return Me.txtPostalCode.Text End Get Set(ByVal Value As String) Me.txtPostalCode.Text = Value End Set End Property Public Property Country() As String Get Return Me.txtCountry.Text End Get Set(ByVal Value As String) Me.txtCountry.Text = Value End Set End Property #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents saveAddress As System.Windows.Forms.Button Friend WithEvents cancelAddress As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents txtStreet As System.Windows.Forms.TextBox Friend WithEvents txtCity As System.Windows.Forms.TextBox Friend WithEvents txtPostalCode As System.Windows.Forms.TextBox Friend WithEvents txtCountry As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.saveAddress = New System.Windows.Forms.Button Me.cancelAddress = New System.Windows.Forms.Button

Me.txtStreet = New System.Windows.Forms.TextBox Me.txtCity = New System.Windows.Forms.TextBox Me.txtPostalCode = New System.Windows.Forms.TextBox Me.txtCountry = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'saveAddress ' Me.saveAddress.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or Syste Me.saveAddress.DialogResult = System.Windows.Forms.DialogResult.OK Me.saveAddress.FlatStyle = System.Windows.Forms.FlatStyle.System Me.saveAddress.Location = New System.Drawing.Point(128, 120) Me.saveAddress.Name = "saveAddress" Me.saveAddress.TabIndex = 0 Me.saveAddress.Text = "OK" ' 'cancelAddress ' Me.cancelAddress.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or Sys Me.cancelAddress.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.cancelAddress.FlatStyle = System.Windows.Forms.FlatStyle.System Me.cancelAddress.Location = New System.Drawing.Point(208, 120) Me.cancelAddress.Name = "cancelAddress" Me.cancelAddress.TabIndex = 1 Me.cancelAddress.Text = "Cancel" ' 'txtStreet ' Me.txtStreet.Location = New System.Drawing.Point(80, 16) Me.txtStreet.Name = "txtStreet" Me.txtStreet.Size = New System.Drawing.Size(200, 20) Me.txtStreet.TabIndex = 2 Me.txtStreet.Text = "txtStreet" ' 'txtCity ' Me.txtCity.Location = New System.Drawing.Point(80, 40) Me.txtCity.Name = "txtCity" Me.txtCity.Size = New System.Drawing.Size(200, 20) Me.txtCity.TabIndex = 3 Me.txtCity.Text = "txtCity" ' 'txtPostalCode ' Me.txtPostalCode.Location = New System.Drawing.Point(80, 64) Me.txtPostalCode.Name = "txtPostalCode" Me.txtPostalCode.Size = New System.Drawing.Size(112, 20) Me.txtPostalCode.TabIndex = 4 Me.txtPostalCode.Text = "txtPostalCode" ' 'txtCountry ' Me.txtCountry.Location = New System.Drawing.Point(80, 88) Me.txtCountry.Name = "txtCountry" Me.txtCountry.Size = New System.Drawing.Size(200, 20) Me.txtCountry.TabIndex = 5 Me.txtCountry.Text = "txtCountry"

' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(39, 18) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(38, 16) Me.Label1.TabIndex = 6 Me.Label1.Text = "Street:" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(50, 42) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(27, 16) Me.Label2.TabIndex = 7 Me.Label2.Text = "City:" ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(8, 66) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(69, 16) Me.Label3.TabIndex = 8 Me.Label3.Text = "Postal Code:" ' 'Label4 ' Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(33, 90) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(44, 16) Me.Label4.TabIndex = 9 Me.Label4.Text = "Country" ' 'addressDialog ' Me.AcceptButton = Me.saveAddress Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.CancelButton = Me.cancelAddress Me.ClientSize = New System.Drawing.Size(292, 152) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.txtCountry) Me.Controls.Add(Me.txtPostalCode) Me.Controls.Add(Me.txtCity) Me.Controls.Add(Me.txtStreet) Me.Controls.Add(Me.cancelAddress) Me.Controls.Add(Me.saveAddress) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "addressDialog" Me.Text = "Address Dialog" Me.ResumeLayout(False) End Sub

#End Region

Private Sub saveAddress_Click(ByVal sender As System.Object, ByVal e As System.Event Me.Close() End Sub

Private Sub cancelAddress_Click(ByVal sender As System.Object, ByVal e As System.Eve Me.Close() End Sub End Class

DialogResult.Retry, Anulare, Cancel


Importurile System.Windows.Forms

Public class Test de Public comun sub principal Dim drResult Ca DialogResult drResult = MessageBox.Show ( "Q?" ,

"Sample" , MessageBoxButtons.RetryCancel )

Dac drResult = DialogResult.Retry Apoi Console.WriteLine ( "Retry" ) Else Console.WriteLine ( "Cancel" ) Dac End

Select MessageBox.Show caz ( "Lucrurile rele sa ntmplat" , "proces de lung d Case DialogResult.Abort Console.WriteLine ( "anulare" ) Cauza DialogResult.Retry Console.WriteLine ( "retry" ) Cauza DialogResult.Cancel Console.WriteLine ( "Cancel" ) Case Else Console.WriteLine ( "Else" ) End Select End Sub End Class

Original

Imports System.Windows.Forms Public Class Test Public Shared Sub Main Dim drResult As DialogResult drResult = MessageBox.Show("Q?", "Sample", MessageBoxButtons.RetryCancel) If drResult = DialogResult.Retry Then

Console.WriteLine("Retry") Else Console.WriteLine("Cancel") End If

Select Case MessageBox.Show("Bad stuff happened","Long Process", MessageBoxButto Case DialogResult.Abort Console.WriteLine("abort") Case DialogResult.Retry Console.WriteLine("retry") Case DialogResult.Cancel Console.WriteLine("cancel") Case Else Console.WriteLine("Else") End Select End Sub End Class

Set DialogResult pentru Button

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class GetDialogResult public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent ()

"Anuntul d orice iniializare dup InitializeComponent () End Sub

apel

"Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 112 , 40 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 88 , 23 ) Me. Button1.TabIndex = 0 Me.Button1.Text = "Arata fereastra de dialog" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 104 , 96 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1. size = New System.Drawing.Size ( 112 , 20 ) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me. ClientSize = New System.Drawing.Size ( 304 , 181 ) Me.Controls.Add ( Me.TextBox1 ) Me.Controls.Add ( Me.Button1 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub Button1_Click ( ByVal expeditor Dim frmDialog Ca New form2 Dac frmDialog.ShowDialog ()

System

= DialogResult.OK Apoi

TextBox1.Text = End Dac End Sub End Class

"ai tastat:"

& frmDialog.TextBox1.Text

Public class form2 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Button2 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = Noul Sistem . Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout () " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 16 , 16 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 256 , 20 ) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" " "Bu tton1 ' Me.Button1.DialogResult = System.Windows . Forms.DialogResult.OK Me.Button1.Location = New System.Drawing.Point ( 48 , 72 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 1 Me.Button1.Text = "OK" Ca apel

Bool

" " bu tton2 ' Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Button2.Location = New System.Drawing.Point ( 168 , 72 ) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 2 Me.Button2.Text = "Cancel" " "Fo RM2 ' Me.AcceptButton = Me.Button1 Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.CancelButton = Me.Button2 Me.ClientSize = Sistem . Drawing.Size ( 288 , 125 ) Me.ControlBox =

= System.Windows.Forms.FormBorderStyle.FixedDialog Me.Name = "form2" Me.Text = "Dialog" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub Button1_Click ( ByVal expeditor Me.Close () End Sub Private Sub Button2_Click ( ByVal expeditor Me.Close () End Sub End Class

System

Ca

System.Object, ByVal e

ca

System

Original

Imports System.Drawing Imports System.Drawing.Drawing2D

Imports System.Windows.Forms public class GetDialogResult public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(112, 40) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(88, 23) Me.Button1.TabIndex = 0 Me.Button1.Text = "Show Dialog" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(104, 96) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(112, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = ""

' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(304, 181) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Dim frmDialog As New Form2 If frmDialog.ShowDialog() = DialogResult.OK Then TextBox1.Text = "You typed: " & frmDialog.TextBox1.Text End If End Sub End Class Public Class Form2 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox

Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(16, 16) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(256, 20) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" ' 'Button1 ' Me.Button1.DialogResult = System.Windows.Forms.DialogResult.OK Me.Button1.Location = New System.Drawing.Point(48, 72) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 1 Me.Button1.Text = "OK" ' 'Button2 ' Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Button2.Location = New System.Drawing.Point(168, 72) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 2 Me.Button2.Text = "Cancel" ' 'Form2 ' Me.AcceptButton = Me.Button1 Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.CancelButton = Me.Button2 Me.ClientSize = New System.Drawing.Size(288, 125) Me.ControlBox = False Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.Name = "Form2" Me.Text = "Dialog" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Me.Close() End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Me.Close() End Sub End Class

Get DialogResult

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class GetDialogResult public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout () Ca apel

Bool

" "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 112 , 40 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 88 , 23 ) Me. Button1.TabIndex = 0 Me.Button1.Text = "Arata fereastra de dialog" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 104 , 96 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1. size = New System.Drawing.Size ( 112 , 20 ) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me. ClientSize = New System.Drawing.Size ( 304 , 181 ) Me.Controls.Add ( Me.TextBox1 ) Me.Controls.Add ( Me.Button1 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub Button1_Click ( ByVal expeditor Dim frmDialog Ca New form2 Dac

System

frmDialog.ShowDialog () = DialogResult.OK Apoi TextBox1.Text = "ai tastat:" & frmDialog.TextBox1.Text End Dac End Sub End Class Public class form2 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () Ca apel

Bool

End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Button2 Ca System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = Noul Sistem . Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout () " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 16 , 16 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 256 , 20 ) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" " "Bu tton1 ' Me.Button1.DialogResult = System.Windows . Forms.DialogResult.OK Me.Button1.Location = New System.Drawing.Point ( 48 , 72 ) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 1 Me.Button1.Text = "OK" " " bu tton2 ' Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Button2.Location = New System.Drawing.Point ( 168 , 72 ) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 2 Me.Button2.Text = "Cancel" " "Fo RM2 ' Me.AcceptButton = Me.Button1 Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.CancelButton = Me.Button2 Me.ClientSize = Sistem . Drawing.Size ( 288 , 125 ) Me.ControlBox =

= System.Windows.Forms.FormBorderStyle.FixedDialog Me.Name = "form2" Me.Text = "Dialog" Me.ResumeLayout ( Fals ) End Sub

# End

Regiunea Ca System.Object, ByVal e ca

Private Sub Button1_Click ( ByVal expeditor Me.Close () End Sub Private Sub Button2_Click ( ByVal expeditor Me.Close () End Sub End Class

System

Ca

System.Object, ByVal e

ca

System

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class GetDialogResult public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then

If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(112, 40) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(88, 23) Me.Button1.TabIndex = 0 Me.Button1.Text = "Show Dialog" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(104, 96) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(112, 20) Me.TextBox1.TabIndex = 1 Me.TextBox1.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(304, 181) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Button1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Dim frmDialog As New Form2 If frmDialog.ShowDialog() = DialogResult.OK Then TextBox1.Text = "You typed: " & frmDialog.TextBox1.Text End If End Sub End Class Public Class Form2

Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(16, 16) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(256, 20) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" ' 'Button1 ' Me.Button1.DialogResult = System.Windows.Forms.DialogResult.OK Me.Button1.Location = New System.Drawing.Point(48, 72) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 1 Me.Button1.Text = "OK" ' 'Button2 ' Me.Button2.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Button2.Location = New System.Drawing.Point(168, 72) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 2

Me.Button2.Text = "Cancel" ' 'Form2 ' Me.AcceptButton = Me.Button1 Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.CancelButton = Me.Button2 Me.ClientSize = New System.Drawing.Size(288, 125) Me.ControlBox = False Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.TextBox1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.Name = "Form2" Me.Text = "Dialog" Me.ResumeLayout(False) End Sub #End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Me.Close() End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Me.Close() End Sub End Class

Font se aplic aciune

Importurile Importurile public class

System.Drawing System.Windows.Forms FontDialogApplyAction

public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Private Sub btnSetFont_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere btnSetFont.Click Dim Dim old_font Ca Font = Me.Font old_color Ca color = Me.ForeColor 'L 'L 'D 'S et utilizatorul selecta culoarea fontului. et utilizatorul alege Barat i subliniate. isplay butonul Apply. et fontul iniial.

dlgFont.ShowColor = True dlgFont.ShowEffects = True dlgFont.ShowApply = True dlgFont.Font = Me.Font Dac Else

dlgFont.ShowDialog () = DialogResult.OK Apoi SetFormFont ( dlgFont.Font, dlgFont.Color )

SetFormFont ( old_font, old_color ) Dac End End Sub Private Sub dlgFont_Apply ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere dlgFont.Apply Dim DLG Ca FontDialog = DirectCast ( expeditor, FontDialog ) SetFormFont ( dlg.Font, dlg.Color ) End Sub Private Sub SetFormFont ( ByVal new_font Ca Font, ByVal new_color Me.Font = new_font Me.ForeColor = new_color End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial public class Form1 Motenete System.Windows . Forms.Form Ca Color )

"Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.btnSetFont = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.dlgFont = New System.Windows.Forms.FontDialog mine. SuspendLayout () "

"bt nSetFont ' Me.btnSetFont.Location = New System.Drawing.Point ( 8 , 8 ) Me.btnSetFont.Name = "btnSetFont" Me.btnSetFont.Size = New System.Drawing.Size ( 96 , 32 ) Me.btnSetFont.TabIndex = 0 Me.btnSetFont.Text = "font Set" " "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 8 , 48 ) Me.Label1 . Nume = "Label1" Me.Label1.Size = New System.Drawing.Size ( 35 , 13 ) Me.Label1.TabIndex = 1 Me.Label1.Text = "Label1" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 8 , 80 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 160 , 20 ) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "Iat un TextBox" " "Fo RM1 ' Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None Me.ClientSize = Nou

= "Form1" Me.Text = "UseFontDialogWithShowEffects" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents btnSetFont Ca System.Windows.Forms.Button prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents dlgFont Ca System.Windows.Forms.FontDialog End Class

Original

Imports System.Drawing Imports System.Windows.Forms public class FontDialogApplyAction public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub btnSetFont_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnSetFont.Click Dim old_font As Font = Me.Font Dim old_color As Color = Me.ForeColor dlgFont.ShowColor = True dlgFont.ShowEffects = True dlgFont.ShowApply = True dlgFont.Font = Me.Font ' ' ' ' Let the Let the Display Set the user select font color. user select Strikeout and Underline. the Apply button. initial font.

If dlgFont.ShowDialog() = DialogResult.OK Then SetFormFont(dlgFont.Font, dlgFont.Color) Else SetFormFont(old_font, old_color) End If End Sub Private Sub dlgFont_Apply(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles dlgFont.Apply Dim dlg As FontDialog = DirectCast(sender, FontDialog) SetFormFont(dlg.Font, dlg.Color) End Sub Private Sub SetFormFont(ByVal new_font As Font, ByVal new_color As Color) Me.Font = new_font Me.ForeColor = new_color End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.btnSetFont = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.dlgFont = New System.Windows.Forms.FontDialog Me.SuspendLayout() ' 'btnSetFont ' Me.btnSetFont.Location = New System.Drawing.Point(8, 8) Me.btnSetFont.Name = "btnSetFont" Me.btnSetFont.Size = New System.Drawing.Size(96, 32) Me.btnSetFont.TabIndex = 0 Me.btnSetFont.Text = "Set Font" ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(8, 48) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(35, 13) Me.Label1.TabIndex = 1 Me.Label1.Text = "Label1" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(8, 80) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(160, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "Here's a TextBox" ' 'Form1 ' Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None Me.ClientSize = New System.Drawing.Size(325, 273) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.btnSetFont) Me.Name = "Form1" Me.Text = "UseFontDialogWithShowEffects" Me.ResumeLayout(False) Me.PerformLayout()

End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class

btnSetFont As System.Windows.Forms.Button Label1 As System.Windows.Forms.Label TextBox1 As System.Windows.Forms.TextBox dlgFont As System.Windows.Forms.FontDialog

Original

Imports System.Drawing Imports System.Windows.Forms public class FontDialogApplyAction public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub btnSetFont_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnSetFont.Click Dim old_font As Font = Me.Font Dim old_color As Color = Me.ForeColor dlgFont.ShowColor = True dlgFont.ShowEffects = True dlgFont.ShowApply = True dlgFont.Font = Me.Font ' ' ' ' Let the Let the Display Set the user select font color. user select Strikeout and Underline. the Apply button. initial font.

If dlgFont.ShowDialog() = DialogResult.OK Then SetFormFont(dlgFont.Font, dlgFont.Color) Else SetFormFont(old_font, old_color) End If

End Sub Private Sub dlgFont_Apply(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles dlgFont.Apply Dim dlg As FontDialog = DirectCast(sender, FontDialog) SetFormFont(dlg.Font, dlg.Color) End Sub Private Sub SetFormFont(ByVal new_font As Font, ByVal new_color As Color) Me.Font = new_font Me.ForeColor = new_color End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.btnSetFont = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.dlgFont = New System.Windows.Forms.FontDialog Me.SuspendLayout() ' 'btnSetFont ' Me.btnSetFont.Location = New System.Drawing.Point(8, 8) Me.btnSetFont.Name = "btnSetFont" Me.btnSetFont.Size = New System.Drawing.Size(96, 32) Me.btnSetFont.TabIndex = 0 Me.btnSetFont.Text = "Set Font" ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(8, 48) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(35, 13) Me.Label1.TabIndex = 1 Me.Label1.Text = "Label1" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(8, 80) Me.TextBox1.Name = "TextBox1"

Me.TextBox1.Size = New System.Drawing.Size(160, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "Here's a TextBox" ' 'Form1 ' Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None Me.ClientSize = New System.Drawing.Size(325, 273) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.btnSetFont) Me.Name = "Form1" Me.Text = "UseFontDialogWithShowEffects" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class btnSetFont As System.Windows.Forms.Button Label1 As System.Windows.Forms.Label TextBox1 As System.Windows.Forms.TextBox dlgFont As System.Windows.Forms.FontDialog

Dialog 14.71.2.Font arat efectele

Importurile Importurile

System.Drawing System.Windows.Forms

public class FontDialogApplyAction public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa public class Form1 Private Sub btnSetFont_Click ( ByVal expeditor

Ca

System.Object, _

ByVal e Dim Dim

ca

System.EventArgs )

Manere btnSetFont.Click

old_font Ca Font = Me.Font old_color Ca color = Me.ForeColor 'L 'L 'D 'S et utilizatorul selecta culoarea fontului. et utilizatorul alege Barat i subliniate. isplay butonul Apply. et fontul iniial.

dlgFont.ShowColor = True dlgFont.ShowEffects = True dlgFont.ShowApply = True dlgFont.Font = Me.Font Dac Else

dlgFont.ShowDialog () = DialogResult.OK Apoi SetFormFont ( dlgFont.Font, dlgFont.Color )

SetFormFont ( old_font, old_color ) Dac End End Sub Private Sub dlgFont_Apply ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere dlgFont.Apply Dim DLG Ca FontDialog = DirectCast ( expeditor, FontDialog ) SetFormFont ( dlg.Font, dlg.Color ) End Sub Private Sub SetFormFont ( ByVal new_font Ca Font, ByVal new_color Me.Font = new_font Me.ForeColor = new_color End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial public class Form1 Motenete System.Windows . Forms.Form Ca Color )

"Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.btnSetFont = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.dlgFont = New System.Windows.Forms.FontDialog mine. SuspendLayout () " "bt nSetFont ' Me.btnSetFont.Location = New System.Drawing.Point ( 8 , 8 ) Me.btnSetFont.Name = "btnSetFont" Me.btnSetFont.Size = New System.Drawing.Size ( 96 , 32 ) Me.btnSetFont.TabIndex = 0

Me.btnSetFont.Text = "font Set" " "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 8 , 48 ) Me.Label1 . Nume = "Label1" Me.Label1.Size = New System.Drawing.Size ( 35 , 13 ) Me.Label1.TabIndex = 1 Me.Label1.Text = "Label1" " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 8 , 80 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 160 , 20 ) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "Iat un TextBox" " "Fo RM1 ' Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None Me.ClientSize = Nou

= "Form1" Me.Text = "UseFontDialogWithShowEffects" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents btnSetFont Ca System.Windows.Forms.Button prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents dlgFont Ca System.Windows.Forms.FontDialog End Class

Original

Imports System.Drawing Imports System.Windows.Forms public class FontDialogApplyAction public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub btnSetFont_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnSetFont.Click Dim old_font As Font = Me.Font Dim old_color As Color = Me.ForeColor dlgFont.ShowColor = True dlgFont.ShowEffects = True dlgFont.ShowApply = True dlgFont.Font = Me.Font ' ' ' ' Let the Let the Display Set the user select font color. user select Strikeout and Underline. the Apply button. initial font.

If dlgFont.ShowDialog() = DialogResult.OK Then SetFormFont(dlgFont.Font, dlgFont.Color) Else SetFormFont(old_font, old_color) End If End Sub Private Sub dlgFont_Apply(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles dlgFont.Apply Dim dlg As FontDialog = DirectCast(sender, FontDialog) SetFormFont(dlg.Font, dlg.Color) End Sub Private Sub SetFormFont(ByVal new_font As Font, ByVal new_color As Color) Me.Font = new_font Me.ForeColor = new_color End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.btnSetFont = New System.Windows.Forms.Button Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.dlgFont = New System.Windows.Forms.FontDialog Me.SuspendLayout() ' 'btnSetFont ' Me.btnSetFont.Location = New System.Drawing.Point(8, 8) Me.btnSetFont.Name = "btnSetFont" Me.btnSetFont.Size = New System.Drawing.Size(96, 32) Me.btnSetFont.TabIndex = 0 Me.btnSetFont.Text = "Set Font" ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(8, 48) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(35, 13) Me.Label1.TabIndex = 1 Me.Label1.Text = "Label1" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(8, 80) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(160, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "Here's a TextBox" ' 'Form1 ' Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None Me.ClientSize = New System.Drawing.Size(325, 273) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.btnSetFont) Me.Name = "Form1" Me.Text = "UseFontDialogWithShowEffects" Me.ResumeLayout(False) Me.PerformLayout()

End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class

btnSetFont As System.Windows.Forms.Button Label1 As System.Windows.Forms.Label TextBox1 As System.Windows.Forms.TextBox dlgFont As System.Windows.Forms.FontDialog

Proprieti 14.71.3.Set pentru un FontDialog

Importurile Importurile

System.Drawing System.Windows.Forms

public class FontDialogProperty public comun sub principal Dim Dim FontDialog1 objNewFont Ca Ca FontDialog = New System.Windows.Forms.FontDialog Font 12 , FontStyle.Underline )

objNewFont = New Font ( "Verdana" , Cu FontDialog1 . Font = objNewFont . AllowScriptChange = Fals . ShowColor = Adevrat . Color = Color.Blue . ShowApply = True 'S. howEffects = False End Cu Dac

FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Apoi Console.WriteLine ( FontDialog1.Font )

Console.WriteLine ( FontDialog1.Color ) End If End Sub clasa End

Original

Imports System.Drawing Imports System.Windows.Forms public class FontDialogProperty public Shared Sub Main Dim FontDialog1 As FontDialog = New System.Windows.Forms.FontDialog Dim objNewFont As Font objNewFont = New Font("Verdana", 12, FontStyle.Underline) With FontDialog1 .Font = objNewFont .AllowScriptChange = False .ShowColor = True .Color = Color.Blue .ShowApply = True '.ShowEffects = False End With If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then Console.WriteLine(FontDialog1.Font) Console.WriteLine(FontDialog1.Color)

End If End Sub End class

Font 14.71.4.Get selectate din FontDialog


Importurile Importurile System.IO System.Windows.Forms

public class FontDialogSelectedFont public comun sub principal Dim FontDB Ca New FontDialog () n cazul n care ( FontDB.ShowDialog () Console.WriteLine ( FontDB.Font ) End If End Sub clasa End = DialogResult.OK ) Atunci

Original

Imports System.IO Imports System.Windows.Forms public class FontDialogSelectedFont public Shared Sub Main Dim FontDB As New FontDialog() If (FontDB.ShowDialog() = DialogResult.OK) Then Console.WriteLine(FontDB.Font) End If End Sub End class

Dialog Font 14.71.5.Use pentru a seta fontul Label

Imports Imports Imports Imports

System.Drawing.Text System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class UseFontDialogToSetLabelFont public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form Public Sub New () MyBase.New () InitializeComponent () End Sub Protejate Suprancrcarea nlocuiete Sub Dac dispunerea Apoi Daca nu ( componente este nimic ) components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub Private componente Ca Distrugerea ( ByVal eliminare Apoi Ca

Bool

System.ComponentModel.IContainer

Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents FontDialog1 As System.Windows.Forms.FontDialog <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button

Me.FontDialog1 = New System.Windows.Forms.FontDialog Me.SuspendLayout() ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(48, 16) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(168, 96) Me.Label1.TabIndex = 0 Me.Label1.Text = "Font Setting" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(88, 136) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(88, 24) Me.Button1.TabIndex = 1 Me.Button1.Text = "Change Font" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(272, 190) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub Private Sub Button1_Click ( ByVal expeditor FontDialog1.ShowDialog () Label1.Font = FontDialog1.Font End Sub End Class Ca System.Object, ByVal e ca

System

Original

Imports Imports Imports Imports

System.Drawing.Text System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class UseFontDialogToSetLabelFont public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ComponentModel.IContainer Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents FontDialog1 As System.Windows.Forms.FontDialog <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button

Me.FontDialog1 = New System.Windows.Forms.FontDialog Me.SuspendLayout() ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(48, 16) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(168, 96) Me.Label1.TabIndex = 0 Me.Label1.Text = "Font Setting" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(88, 136) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(88, 24) Me.Button1.TabIndex = 1 Me.Button1.Text = "Change Font" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(272, 190) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs FontDialog1.ShowDialog() Label1.Font = FontDialog1.Font End Sub End Class

Handle mai multe Stivuitoare eveniment de controale diferite

Importurile

System.Windows.Forms

public class HandleMultipleEventsFromDifferentControls public comun Sub principal Application.Run ( New Form1 ) End Sub

End clasa Publice clasa Form1 Private Sub MultipleEvents ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere _ TextBox1.Enter, TextBox2.Enter, TextBox3.Enter, _ TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged Dim activeControl Ca TextBox

activeControl = Ctype ( expeditor, TextBox ) ShowInfo.Text = "TextField #" & _ activeControl.Name & _ "," & activeControl.Text.Length & "caracter (e)" End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox mine. Label3 = New System.Windows.Forms.Label Me.TextBox3 = New System.Windows.Forms.TextBox Me.Label4 = New System.Windows.Forms.Label Me.ShowInfo = New System.Windows.Forms.Label Me.SuspendLayout ( ) " "Te xtBox1 ' Me.TextBox1.Location = New System.Drawing.Point ( 120 , 8 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 160 , 20 ) Me TextBox1.TabIndex =. 1 ' "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 8 , 10 ) Me.Label1.Name = "Label1"

Boolean )

Me.Label1.Size = New System.Drawing.Size ( 93 , 13 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "Text Box camp # 1:" " "La bel2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point ( 8 , 42 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 93 , 13 ) Me.Label2.TabIndex = 2 Me.Label2.Text = "Text Box camp # 2:" " "Te xtBox2 ' Me.TextBox2.Location = New System.Drawing.Point ( 120 , 40 ) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing. Dimensiune ( 160 , 20 ) Me.TextBox2.TabIndex = 3 " 'La bel3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point ( 9 , 72 ) Me.Label3.Name = "Label3 " Me.Label3.Size = New System.Drawing.Size ( 93 , 13 ) Me.Label3.TabIndex = 4 Me.Label3.Text = "Text Box camp # 3:" " "Te xtBox3 ' Me.TextBox3.Location = New System.Drawing.Point ( 121 , 70 ) Me.TextBox3.Name = "TextBox3" Me.TextBox3.Size = New System.Drawing.Size ( 159 , 20 ) Me.TextBox3.TabIndex = 5 ' 'La bel4 " Me . Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point ( 8 , 104 ) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size ( 62 , 13 ) Me . Label4.TabIndex = 6 Me.Label4.Text = "Informaii:" " "Sh owInfo ' Me.ShowInfo.AutoSize = True Me.ShowInfo.Location = New System.Drawing.Point ( 120 , 104 ) Me.ShowInfo.Name = "ShowInfo" Me.ShowInfo.Size = New System.Drawing.Size ( 27 , 13 ) Me.ShowInfo.TabIndex = 7 Me.ShowInfo.Text = "N / A" " "Fo RM1 ' Me.AutoScaleDimensions = Sistem . Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou

= System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = false Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Sharing Logic Control" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents TextBox2 Ca System.Windows.Forms.TextBox prieten WithEvents Label3 Ca System.Windows.Forms.Label prieten WithEvents TextBox3 Ca System.Windows.Forms.TextBox prieten WithEvents Label4 Ca System.Windows.Forms.Label prieten WithEvents ShowInfo Ca System.Windows.Forms.Label End Class

Original

Imports System.Windows.Forms public class HandleMultipleEventsFromDifferentControls public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub MultipleEvents(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles _ TextBox1.Enter, TextBox2.Enter, TextBox3.Enter, _ TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged Dim activeControl As TextBox

activeControl = CType(sender, TextBox) ShowInfo.Text = "TextField #" & _ activeControl.Name & _ ", " & activeControl.Text.Length & " character(s)" End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label Me.TextBox3 = New System.Windows.Forms.TextBox Me.Label4 = New System.Windows.Forms.Label Me.ShowInfo = New System.Windows.Forms.Label Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(120, 8) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(160, 20) Me.TextBox1.TabIndex = 1 ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(8, 10) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(93, 13) Me.Label1.TabIndex = 0 Me.Label1.Text = "Text Box Field #1:" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(8, 42) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(93, 13)

Me.Label2.TabIndex = 2 Me.Label2.Text = "Text Box Field #2:" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(120, 40) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(160, 20) Me.TextBox2.TabIndex = 3 ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(9, 72) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(93, 13) Me.Label3.TabIndex = 4 Me.Label3.Text = "Text Box Field #3:" ' 'TextBox3 ' Me.TextBox3.Location = New System.Drawing.Point(121, 70) Me.TextBox3.Name = "TextBox3" Me.TextBox3.Size = New System.Drawing.Size(159, 20) Me.TextBox3.TabIndex = 5 ' 'Label4 ' Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(8, 104) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(62, 13) Me.Label4.TabIndex = 6 Me.Label4.Text = "Information:" ' 'ShowInfo ' Me.ShowInfo.AutoSize = True Me.ShowInfo.Location = New System.Drawing.Point(120, 104) Me.ShowInfo.Name = "ShowInfo" Me.ShowInfo.Size = New System.Drawing.Size(27, 13) Me.ShowInfo.TabIndex = 7 Me.ShowInfo.Text = "N/A" ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(320, 136) Me.Controls.Add(Me.ShowInfo) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.TextBox3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen

Me.Text = "Sharing Control Logic" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class TextBox1 As System.Windows.Forms.TextBox Label1 As System.Windows.Forms.Label Label2 As System.Windows.Forms.Label TextBox2 As System.Windows.Forms.TextBox Label3 As System.Windows.Forms.Label TextBox3 As System.Windows.Forms.TextBox Label4 As System.Windows.Forms.Label ShowInfo As System.Windows.Forms.Label

A tratare a evenimentului simplu

Importurile

System.Windows.Forms

public class GenericEventHandler public comun Sub principal Application.Run ( New FrmSimple ) End Sub End clasa Public class FrmSimple Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "T apelul su este cerut de formularul de Designer Windows. InitializeComponent () "O dd orice iniializare dup "I nitializeComponent () apel End Sub 'N ew "F ORM prevaleaz dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Aruncai ( _ ByVal eliminare Ca Boolean ) Dac aruncai Apoi,

Dac nu ( componente este nimic ) components.Dispose () End If End If MyBase.Dispose ( eliminare ) End Sub 'D ispose Prietenul WithEvents lblOutput Ca

Apoi

System.Windows.Forms.Label

"R equired de forma Designer pentru Windows private componente Ca System.ComponentModel.Container "N NOT: Urmtoarea procedur este prevzut de 't el pentru Windows Form Designer. " Eu nu pot fi modificate cu ajutorul Form Designer pentru Windows. " D o nu se modifica folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.lblOutput = New System.Windows.Forms.Label () Me.SuspendLayout () " "lb lOutput " Me . lblOutput.Location = New System.Drawing.Point ( 16 , 16 ) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size ( 152 , 80 ) Me.lblOutput.TabIndex = 0 Me lblOutput.Text =. "Click aici!" Me.lblOutput.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' "Parintele mSimple ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = Sistem. Drawing.Size ( 176 , 101 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.lblOutput }) Me.Name = "FrmSimple" Me.Text = "SimpleEventExample" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

Private Sub lblOutput_Click ( expeditor ByVal Ca obiect, _ ByVal e ca System.EventArgs ) Manere lblOutput.Click MessageBox.Show ( "eticheta a fost fcut clic" ) End Sub End Class

Original

Imports System.Windows.Forms public class GenericEventHandler public Shared Sub Main Application.Run(New FrmSimple) End Sub End class Public Class FrmSimple Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the ' InitializeComponent() call End Sub ' New ' Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose( _ ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub ' Dispose Friend WithEvents lblOutput As System.Windows.Forms.Label ' Required by the Windows Form Designer Private components As System.ComponentModel.Container ' NOTE: The following procedure is required by ' the Windows Form Designer. ' It can be modified using the Windows Form Designer. ' Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lblOutput = New System.Windows.Forms.Label()

Me.SuspendLayout() ' 'lblOutput ' Me.lblOutput.Location = New System.Drawing.Point(16, 16) Me.lblOutput.Name = "lblOutput" Me.lblOutput.Size = New System.Drawing.Size(152, 80) Me.lblOutput.TabIndex = 0 Me.lblOutput.Text = "Click Me!" Me.lblOutput.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'FrmSimple ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(176, 101) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblOutput}) Me.Name = "FrmSimple" Me.Text = "SimpleEventExample" Me.ResumeLayout(False) End Sub #End Region Private Sub lblOutput_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles lblOutput.Click MessageBox.Show("Label was clicked") End Sub End Class

Eticheta 14.73.1.Add la o form

Importurile

System.Windows.Forms

public class AddNewLabelToForm public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Form1 System.Object, ByVal e ca

Private Sub Form1_Load ( ByVal expeditor Ca Dim LBL Ca noua etichet lbl.SetBounds ( 10 , 50 , 100 , 25 ) lbl.Text = "Hello World!" Me. Controls.Add ( LBL ) End Sub End Class

System.Ev

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.SuspendLayout () " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 292 , 273 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals ) End Sub End Class

Ca

Bool

Original

Imports System.Windows.Forms public class AddNewLabelToForm public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) H Dim lbl As New Label lbl.SetBounds(10, 50, 100, 25) lbl.Text = "Hello World!" Me.Controls.Add(lbl) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SuspendLayout()

' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 273) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub End Class

TextBox 14.73.2.Add s se formeze n codul

Importurile

System.Windows.Forms

public class AddTextBoxForm public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Form1 Ca obiect, ByVal e ca

Private Sub Form1_Load ( expeditor ByVal Dim dynamicText Ca TextBox = Nimic

System.EventArgs

dynamicText = New Windows.Forms.TextBox dynamicText.Name = "TimeTextBox" dynamicText.Location = New System.Drawing.Point ( 8 , 8 ) dynamicText.Size = New System.Drawing.Size ( 232 , 20 ) dynamicText.TabIndex = 0 Me.Controls.Add ( dynamicText ) Dim theTextBox Ca TextBox

theTextBox = Me.Controls ( "TimeTextBox" ) Dac ( theTextBox isnot nimic ) Apoi theTextBox.Text = Now.ToLongTimeString () End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _

parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.SuspendLayout () " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 260 , 76 ) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = false Me.Name = "Form1" Me.Text = "Dynamic Control" Me.ResumeLayout ( Fals ) End Sub End Class

Boolean )

Original

Add TextBox to Form in code

Imports System.Windows.Forms public class AddTextBoxForm public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dim dynamicText As TextBox = Nothing dynamicText = New Windows.Forms.TextBox dynamicText.Name = "TimeTextBox" dynamicText.Location = New System.Drawing.Point(8, 8) dynamicText.Size = New System.Drawing.Size(232, 20) dynamicText.TabIndex = 0 Me.Controls.Add(dynamicText) Dim theTextBox As TextBox theTextBox = Me.Controls("TimeTextBox") If (theTextBox IsNot Nothing) Then theTextBox.Text = Now.ToLongTimeString() End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.SuspendLayout() ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(260, 76) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "Dynamic Controls" Me.ResumeLayout(False) End Sub

End Class

Tipul de control 14.73.3.Check


Opiunea stricte cu privire la Importurile Importurile System.Drawing System.Windows.Forms

Clasa publice Form1: Motenete Formularul "Am nstantiate butoane publice WithEvents btnOK Ca nou buton () Public WithEvents btnCancel Ca nou buton () Public WithEvents btnQuit Ca nou buton () "A plicarea punctul de intrare Public comun Sub Main () Dim FRM Ca New Form1 () frm.ShowDialog () End Sub "C fat constructor Public Sub New () MyBase.New () "D efine dimensiuni buton i locaii Me.btnOK.Location = Noul punct ( 100 , 50 ) Me.btnOK.Size = Nou Dimensiune ( 100 , 50 ) Me.btnOK.Text = "OK" Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnCancel.Location = nou punct ( 100 , 125 ) Me.btnCancel.Size = noua dimensiune ( 100 , 50 ) Me.btnCancel.Text = "Cancel" Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnQuit.Location = nou punct ( 100 , 200 ) Me.btnQuit.Size = noua dimensiune ( 100 , 50 ) Me.btnQuit.Text = "Exit" Me.btnQuit.DialogResult = System.Windows.Forms.DialogResult.Abort "D efine forma de control i legend Me.Controls.Add ( btnOK ) Me.Controls.Add ( btnCancel ) Me.Controls.Add ( btnQuit ) Me.Text = "Facei clic pe butonul Evenimente" End Sub 'E handler de aerisire pentru toate cele trei butoane Sub Private ButtonClicked ( expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) _ Manere btnOK.Click, btnCancel.Click, btnQuit.Click Dac typeof expeditorul este apoi butonul Dim BTN Ca Button = DirectCast ( expeditor, Button ) Dac btn.Name = "btnOK" Atunci

Console.WriteLine ( "btnOK" ) elseif btn.Name = "btnCancel" Atunci Console.WriteLine ( "Cancel" ) Exit Sub Else Me.Close () End If Altfel Arunca ArgumentException nou ( _ "Evenimentul a fost crescut de un obiect invalid." ) End If End Sub End Class

Original

Option Strict On Imports System.Drawing Imports System.Windows.Forms Public Class Form1 : Inherits Form ' Instantiate buttons Public WithEvents btnOK As New Button() Public WithEvents btnCancel As New Button() Public WithEvents btnQuit As New Button() ' Application entry point Public Shared Sub Main() Dim frm As New Form1() frm.ShowDialog() End Sub ' Class constructor Public Sub New() MyBase.New() ' Define button sizes and locations Me.btnOK.Location = New Point(100, 50) Me.btnOK.Size = New Size(100, 50) Me.btnOK.Text = "OK" Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnCancel.Location = New Point(100, 125) Me.btnCancel.Size = New Size(100, 50) Me.btnCancel.Text = "Cancel" Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnQuit.Location = New Point(100, 200) Me.btnQuit.Size = New Size(100, 50) Me.btnQuit.Text = "Exit" Me.btnQuit.DialogResult = System.Windows.Forms.DialogResult.Abort ' Define form controls and caption Me.Controls.Add(btnOK)

Me.Controls.Add(btnCancel) Me.Controls.Add(btnQuit) Me.Text = "Button Click Events" End Sub ' Event handler for all three buttons Private Sub ButtonClicked(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btnOK.Click, btnCancel.Click, btnQuit.Click If TypeOf sender Is Button Then Dim btn As Button = DirectCast(sender, Button) If btn.Name = "btnOK" Then Console.WriteLine("btnOK") ElseIf btn.Name = "btnCancel" Then Console.WriteLine("Cancel") Exit Sub Else Me.Close() End If Else Throw New ArgumentException( _ "The event was raised by an invalid object.") End If End Sub End Class

Original

Option Strict On Imports System.Drawing Imports System.Windows.Forms Public Class Form1 : Inherits Form ' Instantiate buttons Public WithEvents btnOK As New Button() Public WithEvents btnCancel As New Button() Public WithEvents btnQuit As New Button() ' Application entry point Public Shared Sub Main() Dim frm As New Form1() frm.ShowDialog() End Sub ' Class constructor Public Sub New() MyBase.New() ' Define button sizes and locations Me.btnOK.Location = New Point(100, 50) Me.btnOK.Size = New Size(100, 50) Me.btnOK.Text = "OK" Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK

Me.btnCancel.Location = New Point(100, 125) Me.btnCancel.Size = New Size(100, 50) Me.btnCancel.Text = "Cancel" Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnQuit.Location = New Point(100, 200) Me.btnQuit.Size = New Size(100, 50) Me.btnQuit.Text = "Exit" Me.btnQuit.DialogResult = System.Windows.Forms.DialogResult.Abort ' Define form controls and caption Me.Controls.Add(btnOK) Me.Controls.Add(btnCancel) Me.Controls.Add(btnQuit) Me.Text = "Button Click Events" End Sub ' Event handler for all three buttons Private Sub ButtonClicked(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btnOK.Click, btnCancel.Click, btnQuit.Click If TypeOf sender Is Button Then Dim btn As Button = DirectCast(sender, Button) If btn.Name = "btnOK" Then Console.WriteLine("btnOK") ElseIf btn.Name = "btnCancel" Then Console.WriteLine("Cancel") Exit Sub Else Me.Close() End If Else Throw New ArgumentException( _ "The event was raised by an invalid object.") End If End Sub End Class

Cast expeditor eveniment pentru a controla


Opiunea stricte cu privire la Importurile Importurile System.Drawing System.Windows.Forms

Clasa publice Form1: Motenete Formularul "Am nstantiate butoane publice WithEvents btnOK Ca nou buton () Public WithEvents btnCancel Ca nou buton () Public WithEvents btnQuit Ca nou buton () "A plicarea punctul de intrare Public comun Sub Main ()

Dim FRM Ca New Form1 () frm.ShowDialog () End Sub "C fat constructor Public Sub New () MyBase.New () "D efine dimensiuni buton i locaii Me.btnOK.Location = Noul punct ( 100 , 50 ) Me.btnOK.Size = Nou Dimensiune ( 100 , 50 ) Me.btnOK.Text = "OK" Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnCancel.Location = nou punct ( 100 , 125 ) Me.btnCancel.Size = noua dimensiune ( 100 , 50 ) Me.btnCancel.Text = "Cancel" Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnQuit.Location = nou punct ( 100 , 200 ) Me.btnQuit.Size = noua dimensiune ( 100 , 50 ) Me.btnQuit.Text = "Exit" Me.btnQuit.DialogResult = System.Windows.Forms.DialogResult.Abort "D efine forma de control i legend Me.Controls.Add ( btnOK ) Me.Controls.Add ( btnCancel ) Me.Controls.Add ( btnQuit ) Me.Text = "Facei clic pe butonul Evenimente" End Sub 'E handler de aerisire pentru toate cele trei butoane Sub Private ButtonClicked ( expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) _ Manere btnOK.Click, btnCancel.Click, btnQuit.Click Dac typeof expeditorul este apoi butonul Dim BTN Ca Button = DirectCast ( expeditor, Button ) Dac btn.Name = "btnOK" Atunci Console.WriteLine ( "btnOK" ) elseif btn.Name = "btnCancel" Atunci Console.WriteLine ( "Cancel" ) Exit Sub Else Me.Close () End If Altfel Arunca ArgumentException nou ( _ "Evenimentul a fost crescut de un obiect invalid." ) End If End Sub End Class

Original

Option Strict On

Imports System.Drawing Imports System.Windows.Forms Public Class Form1 : Inherits Form ' Instantiate buttons Public WithEvents btnOK As New Button() Public WithEvents btnCancel As New Button() Public WithEvents btnQuit As New Button() ' Application entry point Public Shared Sub Main() Dim frm As New Form1() frm.ShowDialog() End Sub ' Class constructor Public Sub New() MyBase.New() ' Define button sizes and locations Me.btnOK.Location = New Point(100, 50) Me.btnOK.Size = New Size(100, 50) Me.btnOK.Text = "OK" Me.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnCancel.Location = New Point(100, 125) Me.btnCancel.Size = New Size(100, 50) Me.btnCancel.Text = "Cancel" Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnQuit.Location = New Point(100, 200) Me.btnQuit.Size = New Size(100, 50) Me.btnQuit.Text = "Exit" Me.btnQuit.DialogResult = System.Windows.Forms.DialogResult.Abort ' Define form controls and caption Me.Controls.Add(btnOK) Me.Controls.Add(btnCancel) Me.Controls.Add(btnQuit) Me.Text = "Button Click Events" End Sub ' Event handler for all three buttons Private Sub ButtonClicked(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btnOK.Click, btnCancel.Click, btnQuit.Click If TypeOf sender Is Button Then Dim btn As Button = DirectCast(sender, Button) If btn.Name = "btnOK" Then Console.WriteLine("btnOK") ElseIf btn.Name = "btnCancel" Then Console.WriteLine("Cancel") Exit Sub Else Me.Close() End If Else Throw New ArgumentException( _ "The event was raised by an invalid object.")

End If End Sub End Class

Read i Salvare controale la un formular ntr-un fiier

Opiunea stricte privind importurile System.IO Importurile Importurile Importurile System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class SaveReadControlsFile public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub apel

"Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub prieten WithEvents PANOU1 Ca System.Windows.Forms.Panel prieten WithEvents RichTextBox1 Ca System.Windows.Forms.RichTextBox prieten WithEvents ColorDialog1 Ca System.Windows.Forms.ColorDialog prieten WithEvents FontDialog1 Ca System.Windows.Forms.FontDialog prieten WithEvents SaveFileDialog1 Ca sistem . Windows.Forms.SaveFileDialog prieten WithEvents OpenFileDialog1 Ca System.Windows.Forms.OpenFileDialog prieten WithEvents btnChangeColor Ca System.Windows.Forms.Button prieten WithEvents btnChangeFont Ca System.Windows.Forms.Button prieten WithEvents btnSaveRTF Ca System.Windows.Forms.Button Prietenul WithEvents btnOpenRTF Ca System.Windows.Forms.Button prieten WithEvents btnWriteControls Ca System.Windows.Forms.Button prieten WithEvents btnReadControls Ca System.Windows.Forms.Button prieten WithEvents TextBox1 Ca System.Windows.Forms.TextBox prieten WithEvents TextBox2 Ca sistem. Windows.Forms.TextBox prieten WithEvents TextBox3 Ca System.Windows.Forms.TextBox "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . PANOU1 = New System.Windows.Forms.Panel () Me.RichTextBox1 = New System.Windows.Forms.RichTextBox () Me.ColorDialog1 = New System.Windows.Forms.ColorDialog () Me.FontDialog1 = New System.Windows. Forms.FontDialog () Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog () Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog () Me.btnChangeColor = New System.Windows.Forms.Button () Me.btnChangeFont = New System.Windows.Forms.Button () Me.btnSaveRTF = New System.Windows.Forms.Button () Me.btnOpenRTF = New System.Windows.Forms.Button () Me.btnWriteControls = System.Windows.Forms noi. Butonul () Me.btnReadControls = New System.Windows.Forms.Button () Me.TextBox1 = New System.Windows.Forms.TextBox () Me.TextBox2 = New System.Windows.Forms.TextBox () Me.TextBox3 = Nou

System.Windows.Forms.Control () { Me.btnReadControls, Me.btnWriteControls, Me.bt Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom Me.Panel1.Location = New System.Drawing.Point ( 0 , 222 ) Me.Panel1.Name = "PANOU1" Me.Panel1.Size = New System.Drawing.Size ( 656 , 64 ) Me.Panel1.TabIndex = 0 " "Ri chTextBox1 '

Me.RichTextBox1.Location = New System.Drawing.Point ( 16 , 8 ) Me.RichTextBox1.Name = "RichTextBox1" Me.RichTextBox1.Size = New System.Drawing.Size ( 336 , 176 ) Eu. RichTextBox1.TabIndex = 1 Me.RichTextBox1.Text = "Domnul i doamna Dursley, de numrul patru, Privet Driv "ere perfect normal, v mulumesc foarte mult." " "bt nChangeColor ' Me.btnChangeColor.Location = New System.Drawing.Point ( 24 , 24 ) Me.btnChangeColor.Name = "btnChangeColor" Me.btnChangeColor.Size = New System.Drawing.Size ( 88 , 32 ) Me.btnChangeColor.TabIndex = 0 Me.btnChangeColor.Text = "schimbare de culoare" " "bt nChangeFont ' Me.btnChangeFont.Location = New System.Drawing.Point ( 128 , 24 ) Me.btnChangeFont.Name = "btnChangeFont" Me.btnChangeFont.Size = Nou System.Drawing.Size ( 88 , 32 ) Me.btnChangeFont.TabIndex = 1 Me.btnChangeFont.Text = "Change Font" " "bt nSaveRTF ' Me.btnSaveRTF.Location = New System.Drawing.Point ( 232 , 24 ) Me . btnSaveRTF.Name = "btnSaveRTF" Me.btnSaveRTF.Size = New System.Drawing.Size ( 88 , 32 ) Me.btnSaveRTF.TabIndex = 2 Me.btnSaveRTF.Text = "Salvare RTF" " "bt nOpenRTF " Me.btnOpenRTF . Locaia = New System.Drawing.Point ( 336 , 24 ) Me.btnOpenRTF.Name = "btnOpenRTF" Me.btnOpenRTF.Size = New System.Drawing.Size ( 88 , 32 ) Me.btnOpenRTF.TabIndex = 3 Me.btnOpenRTF . Text = "Deschide RTF" " "bt nWriteControls ' Me.btnWriteControls.Location = New System.Drawing.Point ( 440 , 24 ) Me.btnWriteControls.Name = "btnWriteControls" Me.btnWriteControls.Size = New System.Drawing.Size ( 88 , 32 ) Me.btnWriteControls.TabIndex = 4 Me.btnWriteControls.Text = "Controls Write" " "bt nReadControls ' Me.btnReadControls.Location = New System.Drawing.Point ( 544 , 24 ) Me.btnReadControls.Name = "btnReadControls" Me.btnReadControls.Size = New System.Drawing.Size ( 88 , 32 ) Me.btnReadControls.TabIndex = 5 Me.btnReadControls.Text = "Citete Controls" " "Te xtBox1 ' Me.TextBox1.Location = Sistem . Drawing.Point ( 400 , 24 ) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size ( 232 , 20 ) Me.TextBox1.TabIndex = 2

Me.TextBox1.Text = "TextBox1 " " "Te xtBox2 ' Me.TextBox2.Location = New System.Drawing.Point ( 400 , 68 ) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size ( 232 , 20 ) Me TextBox2.TabIndex =. 3 Me.TextBox2.Text = "TextBox2" " "Te xtBox3 ' Me.TextBox3.Location = New System.Drawing.Point ( 400 , 112 ) Me.TextBox3.Name = "TextBox3" Me.TextBox3. size = New System.Drawing.Size ( 232 , 20 ) Me.TextBox3.TabIndex = 4 Me.TextBox3.Text = "TextBox3" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me . ClientSize = New System.Drawing.Size ( 656 , 286 ) Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.TextBox3, Me.Tex Me.Panel1.ResumeLayout ( False ) Me.ResumeLayout ( Fals ) End Sub # End Regiunea

Private Sub btnWriteControls_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere btnWriteControls.Click "Ge ta dosar Dim thefile Ca String SaveFileDialog1.InitialDirectory = Application.ExecutablePath SaveFileDialog1.DefaultExt = "HLD" "cu format stom SaveFileDialog1 . FileName = "myfile" SaveFileDialog1.Filter = "Fiiere HLD (* HLD.) | * | HLD. Toate fiierele (* *. SaveFileDialog1.OverwritePrompt = True SaveFileDialog1.ShowDialog () thefile = SaveFileDialog1.FileName Dim Dim fs Ca FileStream = New FileStream ( thefile, FileMode.OpenOrCreate ) w Ca StreamWriter StreamWriter = Nou ( fs )

Dim C Ca obiect pentru fiecare c n Me.Controls Dac typeof ( c ) Este TextBox Apoi Dim tbox Ca TextBox = Ctype ( c, TextBox ) w.WriteLine ( tbox.Name & "=" & tbox.Text ) Dac End Urmtorul w.Close () fs.Close () End Sub Private Sub btnReadControls_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere btnReadControls.Click Dim thefile Ca String OpenFileDialog1.InitialDirectory = Application.ExecutablePath

OpenFileDialog1.DefaultExt = "HLD" "cu stom format OpenFileDialog1.FileName = " myfile " OpenFileDialog1.Filter = "Fiiere HLD (* HLD.) | * | HLD. Toate fiierele (* *. OpenFileDialog1.ShowDialog () thefile = OpenFileDialog1.FileName Dim Dim fs Ca FileStream = New FileStream ( thefile, FileMode.Open ) r Ca StreamReader = New StreamReader ( fs )

Dim C Ca obiect Dim tmpArray () Ca String Pentru fiecare c n Me.Controls Dac typeof ( c ) Este TextBox Dim tbox Ca TextBox = Ctype tmpArray = Split, ( r.ReadLine Dac tbox.Name = tmpArray ( 0 tbox.Text = tmpArray ( 1 ) End Dac End Dac Urmtor r.Close () End Sub End Class

Apoi ( c, TextBox ) () , "=" ) ) Apoi

Original

Option Strict On Imports System.IO Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class SaveReadControlsFile

public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox Friend WithEvents ColorDialog1 As System.Windows.Forms.ColorDialog Friend WithEvents FontDialog1 As System.Windows.Forms.FontDialog Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog Friend WithEvents btnChangeColor As System.Windows.Forms.Button Friend WithEvents btnChangeFont As System.Windows.Forms.Button Friend WithEvents btnSaveRTF As System.Windows.Forms.Button Friend WithEvents btnOpenRTF As System.Windows.Forms.Button Friend WithEvents btnWriteControls As System.Windows.Forms.Button Friend WithEvents btnReadControls As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents TextBox3 As System.Windows.Forms.TextBox 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel() Me.RichTextBox1 = New System.Windows.Forms.RichTextBox() Me.ColorDialog1 = New System.Windows.Forms.ColorDialog() Me.FontDialog1 = New System.Windows.Forms.FontDialog() Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog() Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() Me.btnChangeColor = New System.Windows.Forms.Button() Me.btnChangeFont = New System.Windows.Forms.Button()

Me.btnSaveRTF = New System.Windows.Forms.Button() Me.btnOpenRTF = New System.Windows.Forms.Button() Me.btnWriteControls = New System.Windows.Forms.Button() Me.btnReadControls = New System.Windows.Forms.Button() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.TextBox2 = New System.Windows.Forms.TextBox() Me.TextBox3 = New System.Windows.Forms.TextBox() Me.Panel1.SuspendLayout() Me.SuspendLayout() ' 'Panel1 ' Me.Panel1.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnReadContro Me.Panel1.Dock = System.Windows.Forms.DockStyle.Bottom Me.Panel1.Location = New System.Drawing.Point(0, 222) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(656, 64) Me.Panel1.TabIndex = 0 ' 'RichTextBox1 ' Me.RichTextBox1.Location = New System.Drawing.Point(16, 8) Me.RichTextBox1.Name = "RichTextBox1" Me.RichTextBox1.Size = New System.Drawing.Size(336, 176) Me.RichTextBox1.TabIndex = 1 Me.RichTextBox1.Text = "Mr. and Mrs. Dursley, of number four, Privet Drive, were "ere perfectly normal, thank you very much." ' 'btnChangeColor ' Me.btnChangeColor.Location = New System.Drawing.Point(24, 24) Me.btnChangeColor.Name = "btnChangeColor" Me.btnChangeColor.Size = New System.Drawing.Size(88, 32) Me.btnChangeColor.TabIndex = 0 Me.btnChangeColor.Text = "Change Color" ' 'btnChangeFont ' Me.btnChangeFont.Location = New System.Drawing.Point(128, 24) Me.btnChangeFont.Name = "btnChangeFont" Me.btnChangeFont.Size = New System.Drawing.Size(88, 32) Me.btnChangeFont.TabIndex = 1 Me.btnChangeFont.Text = "Change Font" ' 'btnSaveRTF ' Me.btnSaveRTF.Location = New System.Drawing.Point(232, 24) Me.btnSaveRTF.Name = "btnSaveRTF" Me.btnSaveRTF.Size = New System.Drawing.Size(88, 32) Me.btnSaveRTF.TabIndex = 2 Me.btnSaveRTF.Text = "Save RTF" ' 'btnOpenRTF ' Me.btnOpenRTF.Location = New System.Drawing.Point(336, 24) Me.btnOpenRTF.Name = "btnOpenRTF" Me.btnOpenRTF.Size = New System.Drawing.Size(88, 32) Me.btnOpenRTF.TabIndex = 3 Me.btnOpenRTF.Text = "Open RTF" ' 'btnWriteControls

' Me.btnWriteControls.Location = New System.Drawing.Point(440, 24) Me.btnWriteControls.Name = "btnWriteControls" Me.btnWriteControls.Size = New System.Drawing.Size(88, 32) Me.btnWriteControls.TabIndex = 4 Me.btnWriteControls.Text = "Write Controls" ' 'btnReadControls ' Me.btnReadControls.Location = New System.Drawing.Point(544, 24) Me.btnReadControls.Name = "btnReadControls" Me.btnReadControls.Size = New System.Drawing.Size(88, 32) Me.btnReadControls.TabIndex = 5 Me.btnReadControls.Text = "Read Controls" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(400, 24) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(232, 20) Me.TextBox1.TabIndex = 2 Me.TextBox1.Text = "TextBox1" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(400, 68) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(232, 20) Me.TextBox2.TabIndex = 3 Me.TextBox2.Text = "TextBox2" ' 'TextBox3 ' Me.TextBox3.Location = New System.Drawing.Point(400, 112) Me.TextBox3.Name = "TextBox3" Me.TextBox3.Size = New System.Drawing.Size(232, 20) Me.TextBox3.TabIndex = 4 Me.TextBox3.Text = "TextBox3" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(656, 286) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox3, Me.TextBox Me.Panel1.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub btnWriteControls_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnWriteControls.Click 'Get a file Dim theFile As String SaveFileDialog1.InitialDirectory = Application.ExecutablePath SaveFileDialog1.DefaultExt = "hld" 'custom format SaveFileDialog1.FileName = "myFile" SaveFileDialog1.Filter = "HLD Files (*.hld)|*.hld|All Files (*.*) | *.*" SaveFileDialog1.OverwritePrompt = True SaveFileDialog1.ShowDialog()

theFile = SaveFileDialog1.FileName Dim fs As FileStream = New FileStream(theFile, FileMode.OpenOrCreate) Dim w As StreamWriter = New StreamWriter(fs) Dim c As Object For Each c In Me.Controls If TypeOf (c) Is TextBox Then Dim tbox As TextBox = CType(c, TextBox) w.WriteLine(tbox.Name & "=" & tbox.Text) End If Next w.Close() fs.Close() End Sub Private Sub btnReadControls_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnReadControls.Click Dim theFile As String OpenFileDialog1.InitialDirectory = Application.ExecutablePath OpenFileDialog1.DefaultExt = "hld" 'custom format OpenFileDialog1.FileName = "myFile" OpenFileDialog1.Filter = "HLD Files (*.hld)|*.hld|All Files (*.*) | *.*" OpenFileDialog1.ShowDialog() theFile = OpenFileDialog1.FileName Dim fs As FileStream = New FileStream(theFile, FileMode.Open) Dim r As StreamReader = New StreamReader(fs) c As Object tmpArray() As String Each c In Me.Controls TypeOf (c) Is TextBox Then Dim tbox As TextBox = CType(c, TextBox) tmpArray = Split(r.ReadLine(), "=") If tbox.Name = tmpArray(0) Then tbox.Text = tmpArray(1) End If End If Next r.Close() End Sub End Class Dim Dim For If

Mam de control 14.73.6.Set

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class ControlParent: motenete Forma privat WithEvents BTN ca Button publice sub noi () BTN = new Button () btn.Location = new Punct ( 50 , 50 ) btn.Size = new Dimensiune ( 100 , 23 ) btn.Text = "Relaii" Controls.Add ( BTN ) btn.Parent = mi finali sub public comun sub Main () Application.Run ( nou ControlParent ()) end sub privat sub btn_Click Console.WriteLine ( Console.WriteLine ( Console.WriteLine ( Console.WriteLine ( Console.WriteLine ( sfritul sub clasa de final

( expeditor ByVal ca obiect, e ByVal ca EventArgs ) Manere btn. "Parent Button:" + btn.Parent.ToString ()) "hasChildren Button:" + btn.HasChildren. ToString ()) "TopLevelControl:" + btn.TopLevelControl.ToString ()) "Formularul hasChildren:" + me.HasChildren.ToString ()) "Form Controls Count:" + me.Controls.Count.ToString ())

Original

imports System imports System.Drawing imports System.Windows.Forms public class ControlParent : inherits Form Private WithEvents btn as Button public sub New() btn = new Button() btn.Location = new Point(50,50) btn.Size = new Size(100,23) btn.Text = "Relationships" Controls.Add(btn) btn.Parent = me end sub public shared sub Main() Application.Run(new ControlParent()) end sub private sub btn_Click(ByVal sender as object,ByVal e as EventArgs) Handles btn.Click Console.WriteLine("Button Parent: " + btn.Parent.ToString()) Console.WriteLine("Button HasChildren: " + btn.HasChildren.ToString()) Console.WriteLine("TopLevelControl: " + btn.TopLevelControl.ToString()) Console.WriteLine("Form HasChildren: " + me.HasChildren.ToString()) Console.WriteLine("Form Controls Count: " + me.Controls.Count.ToString()) end sub end class

Add butonul de control la Form Controale de colectare

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class ControlParent: motenete Forma privat WithEvents BTN ca Button publice sub noi () BTN = new Button () btn.Location = new Punct ( 50 , 50 ) btn.Size = new Dimensiune ( 100 , 23 ) btn.Text = "Relaii" Controls.Add ( BTN ) btn.Parent = mi finali sub public comun sub Main () Application.Run ( nou ControlParent ()) end sub privat sub btn_Click Console.WriteLine ( Console.WriteLine ( Console.WriteLine ( Console.WriteLine ( Console.WriteLine ( sfritul sub clasa de final

( expeditor ByVal ca obiect, e ByVal ca EventArgs ) Manere btn. "Parent Button:" + btn.Parent.ToString ()) "hasChildren Button:" + btn.HasChildren. ToString ()) "TopLevelControl:" + btn.TopLevelControl.ToString ()) "Formularul hasChildren:" + me.HasChildren.ToString ()) "Form Controls Count:" + me.Controls.Count.ToString ())

Original

imports System imports System.Drawing imports System.Windows.Forms public class ControlParent : inherits Form Private WithEvents btn as Button public sub New() btn = new Button() btn.Location = new Point(50,50) btn.Size = new Size(100,23) btn.Text = "Relationships" Controls.Add(btn) btn.Parent = me end sub public shared sub Main() Application.Run(new ControlParent()) end sub private sub btn_Click(ByVal sender as object,ByVal e as EventArgs) Handles btn.Click Console.WriteLine("Button Parent: " + btn.Parent.ToString()) Console.WriteLine("Button HasChildren: " + btn.HasChildren.ToString()) Console.WriteLine("TopLevelControl: " + btn.TopLevelControl.ToString()) Console.WriteLine("Form HasChildren: " + me.HasChildren.ToString()) Console.WriteLine("Form Controls Count: " + me.Controls.Count.ToString()) end sub end class

VB.Net Tutorial GUI Controls

Tag 14.73.8.Use Constrol lui

importurile de sistem importurile System.Drawing importurile System.Windows.Forms public class Tag-uri: motenete Forma privat LBL ca etichet public sub Nou () Dimensiune = new Dimensiune ( 300 , 200 ) LBL = new Label () lbl.Text = "Label ..." lbl.AutoSize = true lbl.Parent = ma lbl.Location = new Punct ( 10 , 10 )

theEnum dim ca nou FontStyle () theStyles Dim FontStyle () = Ctype ([ Enum ] . GetValues ( theEnum.GetType ()) , F dim i ca ntreg = 1 stil dim ca FontStyle pentru fiecare stil n theStyles BTN slab ca noi Button () btn.Parent = ma btn.Location = new Punct ( 25 , 25 * i ) btn.Size = new Dimensiune ( 75 , 20 ) btn.Text = style.ToString () btn.Tag = stil AddHandler btn.Click, AddressOf btn_Click i + = 1 urmtorii finali sub public comun sub Main () Application.Run ( nou Tag-uri ()) finali sub privat sub btn_Click ( expeditor ByVal ca obiect, e ByVal ca EventArgs ) BTN dim ca Button = Ctype ( expeditor, Button ) FS dim ca FontStyle = Ctype ( btn.Tag, FontStyle ) lbl.Font = new Font ( lbl.Font, fs ) capt sub clasa de final

Original

VB.Net Tutorial GUI Controls

14.73.8.Use Constrol's Tag

imports System imports System.Drawing imports System.Windows.Forms public class Tags : inherits Form private lbl as Label public sub New() Size = new Size(300,200) lbl = new Label() lbl.Text = "Label..." lbl.AutoSize = true lbl.Parent = me lbl.Location = new Point(10,10)

dim theEnum as new FontStyle() dim theStyles as FontStyle() = CType([Enum].GetValues(theEnum.GetType()), FontStyle dim i as integer = 1 dim style as FontStyle for each style in theStyles dim btn as new Button() btn.Parent = me btn.Location = new Point(25,25 * i) btn.Size = new Size(75,20) btn.Text = style.ToString() btn.Tag = style AddHandler btn.Click, AddressOf btn_Click i += 1 next end sub public shared sub Main() Application.Run(new Tags()) end sub private sub btn_Click(ByVal sender as object,ByVal e as EventArgs)

dim btn as Button = CType(sender, Button) dim fs as FontStyle = CType(btn.Tag, FontStyle) lbl.Font = new Font(lbl.Font, fs) end sub end class

Hide un control

Importurile

System.Windows.Forms

public class HideControl public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 publice VAL1 Ca Integer Private Sub Button2_Click ( ByVal expeditor Ca System.Object, ByVal e Dac val1 = 1 Apoi Button1.Visible = false val1 = 0 Button2.Text = "Button1 Hidden" Altfel Button1.Visible = True val1 = 1 Button2.Text = "Click Button2 pentru a ascunde button1" Dac End End Sub Private Sub End Sub Button1_Click ( ByVal expeditor Ca System.Object, ByVal e ca

ca

System

System

End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout () " "Bu tton1 ' Me.Button1.Location = New System.Drawing.Point ( 105 , 65 ) Me.Button1.Margin = New System.Windows.Forms.Padding ( 4 , 4 , 4 , 4 ) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size ( 253 , 40 ) Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" Me.Button1.UseVisualStyleBackColor = True Me.Button1.Visible = False ' 'Bu tton2 ' Me.Button2.Location = New System.Drawing.Point ( 105 , 162 ) Me.Button2.Margin = New System.Windows.Forms.Padding ( 4 , 4 , 4 , 4 ) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size ( 253 , 41 ) Me.Button2.TabIndex = 1 Me.Button2.Text = "click Button2 pentru a ascunde button1" Me.Button2.UseVisualStyleBackColor = True ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 8.0 !, 15.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 473 , 300 ) Me.Controls.Add ( Me.Button2 ) Me.Controls.Add ( Me.Button1 ) Me. Marja = New System.Windows.Forms.Padding ( 4 , 4 , 4 , 4 ) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout ( Fals )

Boolean )

End Sub prieten WithEvents Button1 Ca System.Windows.Forms.Button prieten WithEvents Button2 Ca System.Windows.Forms.Button End Class

Original

Imports System.Windows.Forms public class HideControl public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Public val1 As Integer Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs If val1 = 1 Then Button1.Visible = False val1 = 0 Button2.Text = "Button1 Hidden" Else Button1.Visible = True val1 = 1 Button2.Text = "Click Button2 to hide button1" End If End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs End Sub End Class

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(105, 65) Me.Button1.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(253, 40) Me.Button1.TabIndex = 0 Me.Button1.Text = "Button1" Me.Button1.UseVisualStyleBackColor = True Me.Button1.Visible = False ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(105, 162) Me.Button2.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(253, 41) Me.Button2.TabIndex = 1 Me.Button2.Text = "click Button2 to hide button1" Me.Button2.UseVisualStyleBackColor = True ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 15.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(473, 300) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub

Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button End Class

Label pictur

Importurile Importurile Importurile

System.Data System.Data.OleDb System.Windows.Forms

public class LabelDrag2 public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Form1

Sub privat lblDragSource_MouseDown ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere lblDragSource.MouseDown lblDragSource.DoDragDrop ( "Iat datele tragei!" , DragDropEffects.Copy ) End Sub Private Sub lblDropTarget_DragEnter ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.DragEventArgs ) Manere lblDropTarget.DragEnter Dac e.Data.GetDataPresent ( "text" ) Apoi e.Effect = DragDropEffects.Copy Altele e.Effect = DragDropEffects . Nici unul End If End Sub Sub privat lblDropTarget_DragDrop ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.DragEventArgs ) _ Manere lblDropTarget.DragDrop MessageBox.Show ( e.Data.GetData ( "text" ) . ToString ) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente.

<System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.lblDropTarget = New System.Windows.Forms.Label Me.lblDragSource = New System.Windows.Forms.Label Me.SuspendLayout () " "lb lDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows Forms.BorderStyle.Fixed3D. Me.lblDropTarget.Location = New System.Drawing.Point ( 168 , 16 ) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size ( 96 , 64 ) Me . lblDropTarget.TabIndex = 3 Me.lblDropTarget.Text = "s renune la obiectivul" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'lb lDragSource ' Me.lblDragSource.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me . lblDragSource.Location = New System.Drawing.Point ( 16 , 16 ) Me.lblDragSource.Name = "lblDragSource" Me.lblDragSource.Size = New System.Drawing.Size ( 96 , 64 ) Me.lblDragSource.TabIndex = 2 Me . lblDragSource.Text = "Sursa drag" Me.lblDragSource.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = sistem. Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 279 , 95 ) Me.Controls.Add ( Me.lblDropTarget ) Me.Controls.Add ( Me.lblDragSource ) Me.Name = "Form1" Me . Text = "LabelDrag2" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents lblDropTarget Ca System.Windows.Forms.Label prieten WithEvents lblDragSource Ca System.Windows.Forms.Label End Class

Original

Imports System.Data Imports System.Data.OleDb Imports System.Windows.Forms public class LabelDrag2 public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub lblDragSource_MouseDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles lblDragSource.MouseDown lblDragSource.DoDragDrop("Here's the drag data!", DragDropEffects.Copy) End Sub Private Sub lblDropTarget_DragEnter(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) Handles lblDropTarget.DragEnter If e.Data.GetDataPresent("Text") Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub Private Sub lblDropTarget_DragDrop(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles lblDropTarget.DragDrop MessageBox.Show(e.Data.GetData("Text").ToString) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub

'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lblDropTarget = New System.Windows.Forms.Label Me.lblDragSource = New System.Windows.Forms.Label Me.SuspendLayout() ' 'lblDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Location = New System.Drawing.Point(168, 16) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size(96, 64) Me.lblDropTarget.TabIndex = 3 Me.lblDropTarget.Text = "Drop Target" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'lblDragSource ' Me.lblDragSource.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDragSource.Location = New System.Drawing.Point(16, 16) Me.lblDragSource.Name = "lblDragSource" Me.lblDragSource.Size = New System.Drawing.Size(96, 64) Me.lblDragSource.TabIndex = 2 Me.lblDragSource.Text = "Drag Source" Me.lblDragSource.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(279, 95) Me.Controls.Add(Me.lblDropTarget) Me.Controls.Add(Me.lblDragSource) Me.Name = "Form1" Me.Text = "LabelDrag2" Me.ResumeLayout(False) End Sub Friend WithEvents lblDropTarget As System.Windows.Forms.Label Friend WithEvents lblDragSource As System.Windows.Forms.Label End Class

Label tragei

Importurile Importurile Importurile

System.Data System.Data.OleDb System.Windows.Forms

public class LabelDrag public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 "S tart o tragei. Private Sub lblDragSource_MouseDown ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere lblDragSource.MouseDown lblDragSource.DoDragDrop ( "Iat datele tragei!" , DragDropEffects.Copy ) End Sub "M ake-v c tragei vine din lblDragSource. Private Sub lblDropTarget_DragEnter ( expeditor ByVal ByVal e ca System.Windows.Forms.DragEventArgs ) _ Manere lblDropTarget.DragEnter e.Effect = DragDropEffects.Copy End Sub Ca obiect, _

"D isplay datele sczut. Private Sub lblDropTarget_DragDrop ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.DragEventArgs ) _ Manere lblDropTarget.DragDrop MessageBox.Show ( e.Data.GetData ( "text" ) . ToString ) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows

Ca

Bool

"Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.lblDragSource = New System.Windows.Forms.Label Me.lblDropTarget = New System.Windows.Forms.Label Me.SuspendLayout () " "lb lDragSource ' Me.lblDragSource.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me . lblDragSource.Location = New System.Drawing.Point ( 16 , 16 ) Me.lblDragSource.Name = "lblDragSource" Me.lblDragSource.Size = New System.Drawing.Size ( 96 , 64 ) Me.lblDragSource.TabIndex = 0 Me . lblDragSource.Text = "Sursa drag" Me.lblDragSource.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'lb lDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me . lblDropTarget.Location = New System.Drawing.Point ( 168 , 16 ) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size ( 96 , 64 ) Me.lblDropTarget.TabIndex = 1 Me . lblDropTarget.Text = "s renune la obiectivul" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = sistem. Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 279 , 95 ) Me.Controls.Add ( Me.lblDropTarget ) Me.Controls.Add ( Me.lblDragSource ) Me.Name = "Form1" Me . Text = "LabelDrag" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents lblDragSource Ca System.Windows.Forms.Label prieten WithEvents lblDropTarget Ca System.Windows.Forms.Label End Class

Original

Imports System.Data Imports System.Data.OleDb Imports System.Windows.Forms public class LabelDrag public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 ' Start a drag. Private Sub lblDragSource_MouseDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles lblDragSource.MouseDown lblDragSource.DoDragDrop("Here's the drag data!", DragDropEffects.Copy) End Sub ' Make sure the drag is coming from lblDragSource. Private Sub lblDropTarget_DragEnter(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles lblDropTarget.DragEnter e.Effect = DragDropEffects.Copy End Sub ' Display the dropped data. Private Sub lblDropTarget_DragDrop(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles lblDropTarget.DragDrop MessageBox.Show(e.Data.GetData("Text").ToString) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lblDragSource = New System.Windows.Forms.Label Me.lblDropTarget = New System.Windows.Forms.Label Me.SuspendLayout() ' 'lblDragSource

' Me.lblDragSource.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDragSource.Location = New System.Drawing.Point(16, 16) Me.lblDragSource.Name = "lblDragSource" Me.lblDragSource.Size = New System.Drawing.Size(96, 64) Me.lblDragSource.TabIndex = 0 Me.lblDragSource.Text = "Drag Source" Me.lblDragSource.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'lblDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Location = New System.Drawing.Point(168, 16) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size(96, 64) Me.lblDropTarget.TabIndex = 1 Me.lblDropTarget.Text = "Drop Target" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(279, 95) Me.Controls.Add(Me.lblDropTarget) Me.Controls.Add(Me.lblDragSource) Me.Name = "Form1" Me.Text = "LabelDrag" Me.ResumeLayout(False) End Sub Friend WithEvents lblDragSource As System.Windows.Forms.Label Friend WithEvents lblDropTarget As System.Windows.Forms.Label End Class

Label Drag and Drop

Importurile Importurile Importurile

System.Data System.Data.OleDb System.Windows.Forms

public class DragWithApp public comun Sub principal Application.Run ( New Form1 )

End Sub End clasa Publice clasa Form1 private m_Dragging Ca Boolean ca

Sub privat lblDragSource_MouseDown ( expeditor ByVal Ca obiect, ByVal e m_Dragging = True lblDragSource.DoDragDrop ( "Unele textul" , DragDropEffects.Copy ) m_Dragging = false End Sub Private Sub lblDropTarget_DragEnter ( expeditor ByVal Dac m_Dragging Apoi e.Effect = DragDropEffects.Copy Altfel e.Effect = DragDropEffects.None Dac End End Sub Ca obiect, e ByVal

Syst

Ca

Sys

Sub privat lblDropTarget_DragDrop ( expeditor ByVal Ca obiect, e ByVal MessageBox.Show ( e.Data.GetData ( DataFormats.Text ) . ToString ) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Syste

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.lblDropTarget = New System.Windows.Forms.Label Me.lblDragSource = New System.Windows.Forms.Label Me.SuspendLayout () " "lb lDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows Forms.BorderStyle.Fixed3D. Me.lblDropTarget.Location = New System.Drawing.Point ( 160 , 8 ) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size ( 120 , 96 ) Me . lblDropTarget.TabIndex = 3 Me.lblDropTarget.Text = "s renune la obiectivul" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter

' 'lb lDragSource ' Me.lblDragSource.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me . lblDragSource.Location = New System.Drawing.Point ( 8 , 8 ) Me.lblDragSource.Name = "lblDragSource" Me.lblDragSource.Size = New System.Drawing.Size ( 120 , 96 ) Me.lblDragSource.TabIndex = 2 Me . lblDragSource.Text = "Sursa drag" Me.lblDragSource.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = sistem. Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou = "Form1" Me.Text = "DragWithinApp" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents lblDropTarget Ca System.Windows.Forms.Label prieten WithEvents lblDragSource Ca System.Windows.Forms.Label End Class

Original

Imports System.Data Imports System.Data.OleDb Imports System.Windows.Forms public class DragWithApp public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private m_Dragging As Boolean

Private Sub lblDragSource_MouseDown(ByVal sender As Object, ByVal e As System.Window m_Dragging = True

lblDragSource.DoDragDrop("Some text", DragDropEffects.Copy) m_Dragging = False End Sub

Private Sub lblDropTarget_DragEnter(ByVal sender As Object, ByVal e As System.Window If m_Dragging Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub

Private Sub lblDropTarget_DragDrop(ByVal sender As Object, ByVal e As System.Windows MessageBox.Show(e.Data.GetData(DataFormats.Text).ToString) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lblDropTarget = New System.Windows.Forms.Label Me.lblDragSource = New System.Windows.Forms.Label Me.SuspendLayout() ' 'lblDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Location = New System.Drawing.Point(160, 8) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size(120, 96) Me.lblDropTarget.TabIndex = 3 Me.lblDropTarget.Text = "Drop Target" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'lblDragSource ' Me.lblDragSource.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDragSource.Location = New System.Drawing.Point(8, 8) Me.lblDragSource.Name = "lblDragSource" Me.lblDragSource.Size = New System.Drawing.Size(120, 96) Me.lblDragSource.TabIndex = 2

Me.lblDragSource.Text = "Drag Source" Me.lblDragSource.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(288, 114) Me.Controls.Add(Me.lblDropTarget) Me.Controls.Add(Me.lblDragSource) Me.Name = "Form1" Me.Text = "DragWithinApp" Me.ResumeLayout(False) End Sub Friend WithEvents lblDropTarget As System.Windows.Forms.Label Friend WithEvents lblDragSource As System.Windows.Forms.Label End Class

Drag i pictur obiect personalizat

Importurile Importurile Importurile Importurile Importurile

System.Data System.Data.OleDb System.Xml.Serialization System.IO System.Windows.Forms

public class DragEmployee2 public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 <Serializable () > _ public class Angajat publice Prenume Ca String Public NumeDeFamilie Ca String Public Sub New () End Sub

Public Sub New ( ByVal prenume Prenume = prenume LastName = LAST_NAME End Sub End clas

Ca

String, LAST_NAME ByVal

Ca

String )

Sub privat lblDragSource_MouseDown ( expeditor ByVal Ca obiect, e ByVal Dim EMP Ca nou angajat ( txtFirstName.Text, txtLastName.Text ) Dim data_object Ca New DataObject () data_object.SetData ( " angajat " , EMP ) Dac Apoi txtFirstName.Text = "" txtLastName.Text = "" Dac End End Sub Sub privat lblDropTarget_DragOver ( expeditor ByVal Ca Dac e.Data.GetDataPresent ( "Angajat" ) Apoi KEY_CTRL Const Ca Integer = 8 Dac ( e.KeyState i KEY_CTRL ) <> 0 atunci e.Effect = DragDropEffects.Copy Altfel e.Effect = DragDropEffects.Move End Dac End Dac End Sub obiect, ByVal e lblDragSource.DoDragDrop ( data_object, _ DragDropEffects.Copy Sau DragDropEffects.Move )

Ca

Syst

= DragDropEffects.Move _

ca

Syste

Sub privat lblDropTarget_DragDrop ( expeditor ByVal Ca obiect, e ByVal Ca Syste Dim EMP Ca angajat = DirectCast ( e.Data.GetData ( "angajat" ) , Angajat ) lblFirstName.Text = EMP. Prenume lblLastName.Text = emp.LastName End Sub Private Sub btnShowSerialization_Click ( ByVal expeditor Ca System.Object, ByVal Dim EMP Ca nou angajat ( txtFirstName.Text, txtLastName.Text ) Dim string_writer Ca StringWriter Nou () Dim serializer Ca New XmlSerializer ( gettype ( Angajat )) serializer.Serialize ( string_writer, EMP ) Console.WriteLine ( string_writer.ToString ) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Ca

Bool

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.lblLastName = New System.Windows.Forms.Label Me.lblFirstName = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label mine. btnShowSerialization = New System.Windows.Forms.Button Me.txtLastName = New System.Windows.Forms.TextBox Me.txtFirstName = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.Label1 = New System.Windows.Forms.Label Me.lblDropTarget = New System.Windows.Forms.Label Me.lblDragSource = New System.Windows.Forms.Label Me.SuspendLayout () " "lb lLastName ' Me.lblLastName.BorderStyle = sistem. Windows.Forms.BorderStyle.Fixed3D Me.lblLastName.Location = New System.Drawing.Point ( 288 , 104 ) Me.lblLastName.Name = "lblLastName" Me.lblLastName.Size = New System.Drawing.Size ( 136 , 20 ) Me.lblLastName.TabIndex = 28 Me.lblLastName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'lb lFirstName ' Me.lblFirstName.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblFirstName.Location = New System.Drawing . Punct ( 288 , 80 ) Me.lblFirstName.Name = "lblFirstName" Me.lblFirstName.Size = New System.Drawing.Size ( 136 , 20 ) Me.lblFirstName.TabIndex = 27 Me.lblFirstName.TextAlign = System.Drawing. ContentAlignment.MiddleLeft " "La bel3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point ( 224 , 104 ) Me.Label3.Name = "Label3" Me.Label3.Size = Sistem. Drawing.Size ( 54 , 13 ) Me.Label3.TabIndex = 26 Me.Label3.Text = "Nume" " "La bel4 ' Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point ( 224 , 80 ) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size ( 53 , 13 ) Me.Label4.TabIndex = 25 Me.Label4.Text = "Nume" " "bt nShowSerialization ' Me.btnShowSerialization.Location = New System.Drawing.Point ( 56 , 136 ) Me.btnShowSerialization.Name = "btnShowSerialization" Me.btnShowSerialization.Size = New System.Drawing.Size ( 104 , 24 ) Me.btnShowSerialization.TabIndex = 24 Me.btnShowSerialization.Text = "Arat serializare"

" "TX tLastName ' Me.txtLastName.Location = New System.Drawing.Point ( 72 , 104 ) Me.txtLastName.Name = "txtLastName" Me.txtLastName.Size = Nou System.Drawing.Size ( 136 , 20 ) Me.txtLastName.TabIndex = 23 Me.txtLastName.Text = "S" " "TX tFirstName ' Me.txtFirstName.Location = New System.Drawing.Point ( 72 , 80 ) Me. txtFirstName.Name = "txtFirstName" Me.txtFirstName.Size = New System.Drawing.Size ( 136 , 20 ) Me.txtFirstName.TabIndex = 22 Me.txtFirstName.Text = "R" " "La bel2 " Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point ( 8 , 104 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 54 , 13 ) Me.Label2.TabIndex = 21 Me.Label2.Text = "Nume" " "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 8 , 80 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 53 , 13 ) Me.Label1.TabIndex = 20 Me.Label1.Text = "Nume" " 'lb lDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget. BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Location = New System.Drawing.Point ( 224 , 8 ) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size ( 200 , 64 ) Me.lblDropTarget.TabIndex = 19 Me.lblDropTarget.Text = "Target" " 'lb lDragSource ' Me.lblDragSource.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDragSource.Location = Sistem. Drawing.Point ( 8 , 8 ) Me.lblDragSource.Name = "lblDragSource" Me.lblDragSource.Size = New System.Drawing.Size ( 200 , 64 ) Me.lblDragSource.TabIndex = 18 Me.lblDragSource.Text = "Sursa Drag " " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou

= "Form1" Me.Text = "DragEmployee2" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents lblLastName Ca System.Windows.Forms.Label prieten WithEvents lblFirstName Ca System.Windows.Forms.Label prieten WithEvents Label3 Ca System.Windows.Forms.Label prieten WithEvents Label4 Ca System.Windows.Forms.Label prieten WithEvents btnShowSerialization Ca System.Windows.Forms.Button prieten WithEvents txtLastName Ca System.Windows.Forms.TextBox prieten WithEvents txtFirstName Ca System.Windows.Forms.TextBox prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents Label1 Ca System.Windows.Forms. Eticheta prieten WithEvents lblDropTarget Ca System.Windows.Forms.Label prieten WithEvents lblDragSource Ca System.Windows.Forms.Label End Class

Original

Imports Imports Imports Imports

System.Data System.Data.OleDb System.Xml.Serialization System.IO

Imports System.Windows.Forms public class DragEmployee2 public Shared Sub Main Application.Run(New Form1) End Sub

End class Public Class Form1 <Serializable()> _ Public Class Employee Public FirstName As String Public LastName As String Public Sub New() End Sub Public Sub New(ByVal first_name As String, ByVal last_name As String) FirstName = first_name LastName = last_name End Sub End Class

Private Sub lblDragSource_MouseDown(ByVal sender As Object, ByVal e As System.Window Dim emp As New Employee(txtFirstName.Text, txtLastName.Text) Dim data_object As New DataObject() data_object.SetData("Employee", emp) If lblDragSource.DoDragDrop(data_object, _ DragDropEffects.Copy Or DragDropEffects.Move) = DragDropEffects.Move _ Then txtFirstName.Text = "" txtLastName.Text = "" End If End Sub

Private Sub lblDropTarget_DragOver(ByVal sender As Object, ByVal e As System.Windows If e.Data.GetDataPresent("Employee") Then Const KEY_CTRL As Integer = 8 If (e.KeyState And KEY_CTRL) <> 0 Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.Move End If End If End Sub

Private Sub lblDropTarget_DragDrop(ByVal sender As Object, ByVal e As System.Windows Dim emp As Employee = DirectCast(e.Data.GetData("Employee"), Employee) lblFirstName.Text = emp.FirstName lblLastName.Text = emp.LastName End Sub

Private Sub btnShowSerialization_Click(ByVal sender As System.Object, ByVal e As Sys Dim emp As New Employee(txtFirstName.Text, txtLastName.Text) Dim string_writer As New StringWriter() Dim serializer As New XmlSerializer(GetType(Employee)) serializer.Serialize(string_writer, emp) Console.WriteLine(string_writer.ToString) End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lblLastName = New System.Windows.Forms.Label Me.lblFirstName = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.btnShowSerialization = New System.Windows.Forms.Button Me.txtLastName = New System.Windows.Forms.TextBox Me.txtFirstName = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.Label1 = New System.Windows.Forms.Label Me.lblDropTarget = New System.Windows.Forms.Label Me.lblDragSource = New System.Windows.Forms.Label Me.SuspendLayout() ' 'lblLastName ' Me.lblLastName.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblLastName.Location = New System.Drawing.Point(288, 104) Me.lblLastName.Name = "lblLastName" Me.lblLastName.Size = New System.Drawing.Size(136, 20) Me.lblLastName.TabIndex = 28 Me.lblLastName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'lblFirstName ' Me.lblFirstName.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblFirstName.Location = New System.Drawing.Point(288, 80) Me.lblFirstName.Name = "lblFirstName" Me.lblFirstName.Size = New System.Drawing.Size(136, 20) Me.lblFirstName.TabIndex = 27 Me.lblFirstName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(224, 104) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(54, 13) Me.Label3.TabIndex = 26 Me.Label3.Text = "Last Name" ' 'Label4 ' Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(224, 80) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(53, 13)

Me.Label4.TabIndex = 25 Me.Label4.Text = "First Name" ' 'btnShowSerialization ' Me.btnShowSerialization.Location = New System.Drawing.Point(56, 136) Me.btnShowSerialization.Name = "btnShowSerialization" Me.btnShowSerialization.Size = New System.Drawing.Size(104, 24) Me.btnShowSerialization.TabIndex = 24 Me.btnShowSerialization.Text = "Show Serialization" ' 'txtLastName ' Me.txtLastName.Location = New System.Drawing.Point(72, 104) Me.txtLastName.Name = "txtLastName" Me.txtLastName.Size = New System.Drawing.Size(136, 20) Me.txtLastName.TabIndex = 23 Me.txtLastName.Text = "S" ' 'txtFirstName ' Me.txtFirstName.Location = New System.Drawing.Point(72, 80) Me.txtFirstName.Name = "txtFirstName" Me.txtFirstName.Size = New System.Drawing.Size(136, 20) Me.txtFirstName.TabIndex = 22 Me.txtFirstName.Text = "R" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(8, 104) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(54, 13) Me.Label2.TabIndex = 21 Me.Label2.Text = "Last Name" ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(8, 80) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(53, 13) Me.Label1.TabIndex = 20 Me.Label1.Text = "First Name" ' 'lblDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Location = New System.Drawing.Point(224, 8) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size(200, 64) Me.lblDropTarget.TabIndex = 19 Me.lblDropTarget.Text = "Drop Target" ' 'lblDragSource ' Me.lblDragSource.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDragSource.Location = New System.Drawing.Point(8, 8) Me.lblDragSource.Name = "lblDragSource" Me.lblDragSource.Size = New System.Drawing.Size(200, 64)

Me.lblDragSource.TabIndex = 18 Me.lblDragSource.Text = "Drag Source" ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(433, 177) Me.Controls.Add(Me.lblLastName) Me.Controls.Add(Me.lblFirstName) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.btnShowSerialization) Me.Controls.Add(Me.txtLastName) Me.Controls.Add(Me.txtFirstName) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.lblDropTarget) Me.Controls.Add(Me.lblDragSource) Me.Name = "Form1" Me.Text = "DragEmployee2" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class lblLastName As System.Windows.Forms.Label lblFirstName As System.Windows.Forms.Label Label3 As System.Windows.Forms.Label Label4 As System.Windows.Forms.Label btnShowSerialization As System.Windows.Forms.Button txtLastName As System.Windows.Forms.TextBox txtFirstName As System.Windows.Forms.TextBox Label2 As System.Windows.Forms.Label Label1 As System.Windows.Forms.Label lblDropTarget As System.Windows.Forms.Label lblDragSource As System.Windows.Forms.Label

Drag i pictur de culoare ntre eticheta

Imports Imports Imports Imports Imports Imports

System.ComponentModel System.Drawing System.Runtime.InteropServices System.Windows.Forms System.Windows.Forms.Design System.IO

public class LabelDragDrop public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Form1 ca

Sub privat Label5_MouseDown ( expeditor ByVal Ca System.Object, ByVal e Label5.DoDragDrop ( Label5, DragDropEffects.Copy ) End Sub Sub privat Label6_MouseDown ( expeditor ByVal Ca System.Object, ByVal e Label6.DoDragDrop ( Label6, DragDropEffects.Copy ) End Sub Sub privat Label7_MouseDown ( expeditor ByVal Ca System.Object, ByVal e Label7.DoDragDrop ( Label7.Text, DragDropEffects.Copy ) End Sub Sub privat Label8_MouseDown ( expeditor ByVal Ca System.Object, ByVal e Label8.DoDragDrop ( Label8.Text, DragDropEffects.Copy ) End Sub

Syst

ca

Syst

ca

Syst

ca

Syst

Private Sub Label9_DragEnter ( ByVal expeditor Ca System.Object, ByVal e ca Sys Dac e.Data.GetDataPresent ( gettype ( System.Windows.Forms.Label )) Apoi, e.Effect = DragDropEffects . Copiai Label9.BorderStyle = BorderStyle.FixedSingle Altfel e.Effect = DragDropEffects.None Dac End End Sub Private Sub Label9_DragLeave ( ByVal expeditor Label9.BorderStyle = BorderStyle.Fixed3D Ca System.Object, ByVal e ca

Sys

End Sub Sub privat Label9_DragDrop ( expeditor ByVal Ca System.Object, ByVal e Dim LBL Ca Label = DirectCast ( _ e.Data.GetData ( gettype ( Label )) , Label ) Label9. text = lbl.Text Label9.BackColor = lbl.BackColor Label9.BorderStyle = BorderStyle.Fixed3D End Sub Private Sub Label10_DragEnter ( expeditor ByVal Ca Dac e.Data.GetDataPresent ( DataFormats.Text ) e.Effect = DragDropEffects.Copy Altfel e.Effect = DragDropEffects.None End If End Sub ca

Syste

System.Object, ByVal e Apoi

ca

Sy

Sub privat Label10_DragDrop ( expeditor ByVal Ca System.Object, ByVal e Label10.Text = e.Data.GetData ( DataFormats.Text ) . ToString End Sub End Class <Global.Microsoft . VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

ca

Syst

Boolean )

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label mine. Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.Label8 = New System.Windows.Forms.Label Me.Label9 = New System.Windows.Forms.Label Me.Label10 = New System.Windows.Forms.Label Me.SuspendLayout () " "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 29 , 20 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 83 , 12 )

Me.Label1.TabIndex = 0 Me.Label1.Text = "label Surse" " "La bel2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point ( 221 , 20 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 77 , 12 ) Me.Label2.TabIndex = 1 Me.Label2.Text = "Surse text" " "La bel3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point ( 29 , 145 ) Eu. Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size ( 77 , 12 ) Me.Label3.TabIndex = 2 Me.Label3.Text = "Eticheta int" " "La bel4 " Me.Label4. AutoSize = True Me.Label4.Location = New System.Drawing.Point ( 221 , 145 ) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size ( 71 , 12 ) Me.Label4. tabindex = 3 Me.Label4.Text = "int Textul" " "La bel5 ' Me.Label5.BackColor = System.Drawing.Color.Blue Me.Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label5. Locaie = New System.Drawing.Point ( 35 , 43 ) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label5.TabIndex = 4 ' 'La bel6 " Me.Label6.BackColor = System.Drawing.Color.Red Me.Label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label6.Location = New System.Drawing.Point ( 35 , 77 ) Me.Label6. name = "Label6" Me.Label6.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label6.TabIndex = 5 ' 'La bel7 ' Me.Label7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me . Label7.Location = New System.Drawing.Point ( 229 , 47 ) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label7.TabIndex = 6 Mine . Label7.Text = "Hello" " "La bel8 ' Me.Label8.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label8.Location = New System.Drawing.Point ( 229 , 77 )

Me.Label8.Name = "Label8" Me.Label8.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label8.TabIndex = 7 Me.Label8.Text = "Bun" " "La bel9 ' Me.Label9.AllowDrop = True Me . Label9.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label9.Location = New System.Drawing.Point ( 35 , 170 ) Me.Label9.Name = "Label9" Me.Label9.Size = New System.Drawing . Dimensiune ( 100 , 23 ) Me.Label9.TabIndex = 8 ' 'La bel10 ' Me.Label10.AllowDrop = True Me.Label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label10.Location = Sistem. Drawing.Point ( 229 , 170 ) Me.Label10.Name = "Label10" Me.Label10.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label10.TabIndex = 9 ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 12.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou

Me.ResumeLayout ( False ) Me.PerformLayout () End Sub prieten WithEvents Label1 prieten WithEvents Label2 prieten WithEvents Label3 prieten WithEvents Label4 prieten WithEvents Label5 prieten WithEvents Label6 prieten WithEvents Label7 prieten WithEvents Label8 prieten WithEvents Label9 prieten WithEvents Label10 End Class Ca Ca Ca Ca Ca Ca Ca Ca Ca Ca System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms. Eticheta System.Windows.Forms.Label

Original

Imports Imports Imports Imports Imports Imports

System.ComponentModel System.Drawing System.Runtime.InteropServices System.Windows.Forms System.Windows.Forms.Design System.IO

public class LabelDragDrop public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub Label5_MouseDown(ByVal sender As System.Object, ByVal e As System.Window Label5.DoDragDrop(Label5, DragDropEffects.Copy) End Sub

Private Sub Label6_MouseDown(ByVal sender As System.Object, ByVal e As System.Window Label6.DoDragDrop(Label6, DragDropEffects.Copy) End Sub

Private Sub Label7_MouseDown(ByVal sender As System.Object, ByVal e As System.Window Label7.DoDragDrop(Label7.Text, DragDropEffects.Copy) End Sub

Private Sub Label8_MouseDown(ByVal sender As System.Object, ByVal e As System.Window Label8.DoDragDrop(Label8.Text, DragDropEffects.Copy) End Sub

Private Sub Label9_DragEnter(ByVal sender As System.Object, ByVal e As System.Window If e.Data.GetDataPresent(GetType(System.Windows.Forms.Label)) Then e.Effect = DragDropEffects.Copy Label9.BorderStyle = BorderStyle.FixedSingle Else e.Effect = DragDropEffects.None End If End Sub

Private Sub Label9_DragLeave(ByVal sender As System.Object, ByVal e As System.EventA Label9.BorderStyle = BorderStyle.Fixed3D End Sub

Private Sub Label9_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows Dim lbl As Label = DirectCast( _ e.Data.GetData(GetType(Label)), Label) Label9.Text = lbl.Text Label9.BackColor = lbl.BackColor Label9.BorderStyle = BorderStyle.Fixed3D End Sub

Private Sub Label10_DragEnter(ByVal sender As System.Object, ByVal e As System.Windo If e.Data.GetDataPresent(DataFormats.Text) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub

Private Sub Label10_DragDrop(ByVal sender As System.Object, ByVal e As System.Window Label10.Text = e.Data.GetData(DataFormats.Text).ToString End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.Label8 = New System.Windows.Forms.Label Me.Label9 = New System.Windows.Forms.Label Me.Label10 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(29, 20)

Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(83, 12) Me.Label1.TabIndex = 0 Me.Label1.Text = "Label Sources" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(221, 20) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(77, 12) Me.Label2.TabIndex = 1 Me.Label2.Text = "Text Sources" ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(29, 145) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(77, 12) Me.Label3.TabIndex = 2 Me.Label3.Text = "Label Target" ' 'Label4 ' Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(221, 145) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(71, 12) Me.Label4.TabIndex = 3 Me.Label4.Text = "Text Target" ' 'Label5 ' Me.Label5.BackColor = System.Drawing.Color.Blue Me.Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label5.Location = New System.Drawing.Point(35, 43) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(100, 23) Me.Label5.TabIndex = 4 ' 'Label6 ' Me.Label6.BackColor = System.Drawing.Color.Red Me.Label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label6.Location = New System.Drawing.Point(35, 77) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(100, 23) Me.Label6.TabIndex = 5 ' 'Label7 ' Me.Label7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label7.Location = New System.Drawing.Point(229, 47) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size(100, 23) Me.Label7.TabIndex = 6 Me.Label7.Text = "Hello" ' 'Label8 '

Me.Label8.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label8.Location = New System.Drawing.Point(229, 77) Me.Label8.Name = "Label8" Me.Label8.Size = New System.Drawing.Size(100, 23) Me.Label8.TabIndex = 7 Me.Label8.Text = "Hi" ' 'Label9 ' Me.Label9.AllowDrop = True Me.Label9.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label9.Location = New System.Drawing.Point(35, 170) Me.Label9.Name = "Label9" Me.Label9.Size = New System.Drawing.Size(100, 23) Me.Label9.TabIndex = 8 ' 'Label10 ' Me.Label10.AllowDrop = True Me.Label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label10.Location = New System.Drawing.Point(229, 170) Me.Label10.Name = "Label10" Me.Label10.Size = New System.Drawing.Size(100, 23) Me.Label10.TabIndex = 9 ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(373, 217) Me.Controls.Add(Me.Label10) Me.Controls.Add(Me.Label9) Me.Controls.Add(Me.Label8) Me.Controls.Add(Me.Label7) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class Label1 As System.Windows.Forms.Label Label2 As System.Windows.Forms.Label Label3 As System.Windows.Forms.Label Label4 As System.Windows.Forms.Label Label5 As System.Windows.Forms.Label Label6 As System.Windows.Forms.Label Label7 As System.Windows.Forms.Label Label8 As System.Windows.Forms.Label Label9 As System.Windows.Forms.Label Label10 As System.Windows.Forms.Label

Drag i pictur de text ntre etichete

Imports Imports Imports Imports Imports Imports

System.ComponentModel System.Drawing System.Runtime.InteropServices System.Windows.Forms System.Windows.Forms.Design System.IO

public class LabelDragDrop public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Clasa publice Form1 ca

Sub privat Label5_MouseDown ( expeditor ByVal Ca System.Object, ByVal e Label5.DoDragDrop ( Label5, DragDropEffects.Copy ) End Sub Sub privat Label6_MouseDown ( expeditor ByVal Ca System.Object, ByVal e Label6.DoDragDrop ( Label6, DragDropEffects.Copy ) End Sub Sub privat Label7_MouseDown ( expeditor ByVal Ca System.Object, ByVal e Label7.DoDragDrop ( Label7.Text, DragDropEffects.Copy ) End Sub Sub privat Label8_MouseDown ( expeditor ByVal Ca System.Object, ByVal e Label8.DoDragDrop ( Label8.Text, DragDropEffects.Copy ) End Sub

Syst

ca

Syst

ca

Syst

ca

Syst

Private Sub Label9_DragEnter ( ByVal expeditor Ca System.Object, ByVal e ca Sys Dac e.Data.GetDataPresent ( gettype ( System.Windows.Forms.Label )) Apoi, e.Effect = DragDropEffects . Copiai Label9.BorderStyle = BorderStyle.FixedSingle Altfel e.Effect = DragDropEffects.None Dac End

End Sub Private Sub Label9_DragLeave ( ByVal expeditor Label9.BorderStyle = BorderStyle.Fixed3D End Sub Ca System.Object, ByVal e ca

Sys

Sub privat Label9_DragDrop ( expeditor ByVal Ca System.Object, ByVal e Dim LBL Ca Label = DirectCast ( _ e.Data.GetData ( gettype ( Label )) , Label ) Label9. text = lbl.Text Label9.BackColor = lbl.BackColor Label9.BorderStyle = BorderStyle.Fixed3D End Sub Private Sub Label10_DragEnter ( expeditor ByVal Ca Dac e.Data.GetDataPresent ( DataFormats.Text ) e.Effect = DragDropEffects.Copy Altfel e.Effect = DragDropEffects.None End If End Sub

ca

Syste

System.Object, ByVal e Apoi

ca

Sy

Sub privat Label10_DragDrop ( expeditor ByVal Ca System.Object, ByVal e Label10.Text = e.Data.GetData ( DataFormats.Text ) . ToString End Sub End Class <Global.Microsoft . VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

ca

Syst

Boolean )

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label mine. Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.Label8 = New System.Windows.Forms.Label Me.Label9 = New System.Windows.Forms.Label Me.Label10 = New System.Windows.Forms.Label Me.SuspendLayout () " "La bel1 '

Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 29 , 20 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 83 , 12 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "label Surse" " "La bel2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point ( 221 , 20 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 77 , 12 ) Me.Label2.TabIndex = 1 Me.Label2.Text = "Surse text" " "La bel3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point ( 29 , 145 ) Eu. Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size ( 77 , 12 ) Me.Label3.TabIndex = 2 Me.Label3.Text = "Eticheta int" " "La bel4 " Me.Label4. AutoSize = True Me.Label4.Location = New System.Drawing.Point ( 221 , 145 ) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size ( 71 , 12 ) Me.Label4. tabindex = 3 Me.Label4.Text = "int Textul" " "La bel5 ' Me.Label5.BackColor = System.Drawing.Color.Blue Me.Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label5. Locaie = New System.Drawing.Point ( 35 , 43 ) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label5.TabIndex = 4 ' 'La bel6 " Me.Label6.BackColor = System.Drawing.Color.Red Me.Label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label6.Location = New System.Drawing.Point ( 35 , 77 ) Me.Label6. name = "Label6" Me.Label6.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label6.TabIndex = 5 ' 'La bel7 ' Me.Label7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me . Label7.Location = New System.Drawing.Point ( 229 , 47 ) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label7.TabIndex = 6 Mine . Label7.Text = "Hello" "

"La bel8 ' Me.Label8.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label8.Location = New System.Drawing.Point ( 229 , 77 ) Me.Label8.Name = "Label8" Me.Label8.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label8.TabIndex = 7 Me.Label8.Text = "Bun" " "La bel9 ' Me.Label9.AllowDrop = True Me . Label9.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label9.Location = New System.Drawing.Point ( 35 , 170 ) Me.Label9.Name = "Label9" Me.Label9.Size = New System.Drawing . Dimensiune ( 100 , 23 ) Me.Label9.TabIndex = 8 ' 'La bel10 ' Me.Label10.AllowDrop = True Me.Label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label10.Location = Sistem. Drawing.Point ( 229 , 170 ) Me.Label10.Name = "Label10" Me.Label10.Size = New System.Drawing.Size ( 100 , 23 ) Me.Label10.TabIndex = 9 ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 12.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou

Me.ResumeLayout ( False ) Me.PerformLayout () End Sub prieten WithEvents Label1 prieten WithEvents Label2 prieten WithEvents Label3 prieten WithEvents Label4 prieten WithEvents Label5 prieten WithEvents Label6 prieten WithEvents Label7 prieten WithEvents Label8 prieten WithEvents Label9 prieten WithEvents Label10 End Class Ca Ca Ca Ca Ca Ca Ca Ca Ca Ca System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms.Label System.Windows.Forms. Eticheta System.Windows.Forms.Label

Original

Imports Imports Imports Imports Imports Imports

System.ComponentModel System.Drawing System.Runtime.InteropServices System.Windows.Forms System.Windows.Forms.Design System.IO

public class LabelDragDrop public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1

Private Sub Label5_MouseDown(ByVal sender As System.Object, ByVal e As System.Window Label5.DoDragDrop(Label5, DragDropEffects.Copy) End Sub

Private Sub Label6_MouseDown(ByVal sender As System.Object, ByVal e As System.Window Label6.DoDragDrop(Label6, DragDropEffects.Copy) End Sub

Private Sub Label7_MouseDown(ByVal sender As System.Object, ByVal e As System.Window Label7.DoDragDrop(Label7.Text, DragDropEffects.Copy) End Sub

Private Sub Label8_MouseDown(ByVal sender As System.Object, ByVal e As System.Window Label8.DoDragDrop(Label8.Text, DragDropEffects.Copy) End Sub

Private Sub Label9_DragEnter(ByVal sender As System.Object, ByVal e As System.Window If e.Data.GetDataPresent(GetType(System.Windows.Forms.Label)) Then e.Effect = DragDropEffects.Copy Label9.BorderStyle = BorderStyle.FixedSingle Else e.Effect = DragDropEffects.None

End If End Sub

Private Sub Label9_DragLeave(ByVal sender As System.Object, ByVal e As System.EventA Label9.BorderStyle = BorderStyle.Fixed3D End Sub

Private Sub Label9_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows Dim lbl As Label = DirectCast( _ e.Data.GetData(GetType(Label)), Label) Label9.Text = lbl.Text Label9.BackColor = lbl.BackColor Label9.BorderStyle = BorderStyle.Fixed3D End Sub

Private Sub Label10_DragEnter(ByVal sender As System.Object, ByVal e As System.Windo If e.Data.GetDataPresent(DataFormats.Text) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub

Private Sub Label10_DragDrop(ByVal sender As System.Object, ByVal e As System.Window Label10.Text = e.Data.GetData(DataFormats.Text).ToString End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.Label8 = New System.Windows.Forms.Label Me.Label9 = New System.Windows.Forms.Label Me.Label10 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'Label1

' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(29, 20) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(83, 12) Me.Label1.TabIndex = 0 Me.Label1.Text = "Label Sources" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(221, 20) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(77, 12) Me.Label2.TabIndex = 1 Me.Label2.Text = "Text Sources" ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(29, 145) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(77, 12) Me.Label3.TabIndex = 2 Me.Label3.Text = "Label Target" ' 'Label4 ' Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(221, 145) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(71, 12) Me.Label4.TabIndex = 3 Me.Label4.Text = "Text Target" ' 'Label5 ' Me.Label5.BackColor = System.Drawing.Color.Blue Me.Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label5.Location = New System.Drawing.Point(35, 43) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(100, 23) Me.Label5.TabIndex = 4 ' 'Label6 ' Me.Label6.BackColor = System.Drawing.Color.Red Me.Label6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label6.Location = New System.Drawing.Point(35, 77) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(100, 23) Me.Label6.TabIndex = 5 ' 'Label7 ' Me.Label7.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label7.Location = New System.Drawing.Point(229, 47) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size(100, 23) Me.Label7.TabIndex = 6 Me.Label7.Text = "Hello"

' 'Label8 ' Me.Label8.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label8.Location = New System.Drawing.Point(229, 77) Me.Label8.Name = "Label8" Me.Label8.Size = New System.Drawing.Size(100, 23) Me.Label8.TabIndex = 7 Me.Label8.Text = "Hi" ' 'Label9 ' Me.Label9.AllowDrop = True Me.Label9.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label9.Location = New System.Drawing.Point(35, 170) Me.Label9.Name = "Label9" Me.Label9.Size = New System.Drawing.Size(100, 23) Me.Label9.TabIndex = 8 ' 'Label10 ' Me.Label10.AllowDrop = True Me.Label10.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.Label10.Location = New System.Drawing.Point(229, 170) Me.Label10.Name = "Label10" Me.Label10.Size = New System.Drawing.Size(100, 23) Me.Label10.TabIndex = 9 ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(373, 217) Me.Controls.Add(Me.Label10) Me.Controls.Add(Me.Label9) Me.Controls.Add(Me.Label8) Me.Controls.Add(Me.Label7) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class Label1 As System.Windows.Forms.Label Label2 As System.Windows.Forms.Label Label3 As System.Windows.Forms.Label Label4 As System.Windows.Forms.Label Label5 As System.Windows.Forms.Label Label6 As System.Windows.Forms.Label Label7 As System.Windows.Forms.Label Label8 As System.Windows.Forms.Label Label9 As System.Windows.Forms.Label Label10 As System.Windows.Forms.Label

Culoarea de fundal 14.75.1.Change de comand

Importurile Importurile Importurile

System.Windows.Forms System.Drawing System.Drawing.Drawing2D

public class GetAllControlsOnForm public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa

Public Class Form1 Private Sub ActRed_Click ( ByVal expeditor Ca System.Object, ByVal e pentru fiecare scanControls Ca de control n Me.Controls Dac ( typeof scanControls Este Label ) Apoi scanControls.BackColor = Color.Red End Dac scanControls Urmtor End Sub Private Sub ActNormal_Click ( ByVal expeditor Ca

ca

System.

System.Object, ByVal e

ca

Syst

Pentru fiecare scanControls Ca de control n Me.Controls Dac ( typeof scanControls Este Label ) Apoi scanControls.BackColor = SystemColors.Control End Dac scanControls Urmatorul End Sub End Class

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose ()

Boolean )

End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.ActRed = New System.Windows.Forms.Button Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label mine. ActNormal = New System.Windows.Forms.Button Me.SuspendLayout () " "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 8 , 8 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 39 , 13 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "Label1" " "Ac TRED ' Me.ActRed.Location = Sistem. Drawing.Point ( 16 , 88 ) Me.ActRed.Name = "ActRed" Me.ActRed.Size = New System.Drawing.Size ( 75 , 23 ) Me.ActRed.TabIndex = 1 Me.ActRed.Text = "Red" Me.ActRed.UseVisualStyleBackColor = True ' 'La bel2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point ( 8 , 32 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 39 , 13 ) Me.Label2.TabIndex = 2 Me.Label2.Text = "Label2" " "La bel3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing . Punctul ( 8 , 56 ) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size ( 39 , 13 ) Me.Label3.TabIndex = 3 Me.Label3.Text = "Label3" " "Ac tNormal ' Me.ActNormal.Location = New System.Drawing.Point ( 104 , 88 ) Me.ActNormal.Name = "ActNormal" Me.ActNormal.Size = New System.Drawing.Size ( 75 , 23 ) Me.ActNormal . tabindex = 4

Me.ActNormal.Text = "Normal" Me.ActNormal.UseVisualStyleBackColor = True ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows. Forms.AutoScaleMode.Font Me.ClientSize = Nou

= System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = false Me.Name = "Form1" Me.Text = "iterarea Controls" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents ActRed Ca System.Windows.Forms.Button prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents Label3 Ca System.Windows.Forms.Label prieten WithEvents ActNormal Ca System.Windows.Forms.Button End Class

Original

Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D public class GetAllControlsOnForm public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Private Sub ActRed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

For Each scanControls As Control In Me.Controls If (TypeOf scanControls Is Label) Then scanControls.BackColor = Color.Red End If Next scanControls End Sub

Private Sub ActNormal_Click(ByVal sender As System.Object, ByVal e As System.EventAr For Each scanControls As Control In Me.Controls If (TypeOf scanControls Is Label) Then scanControls.BackColor = SystemColors.Control End If Next scanControls End Sub End Class

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.ActRed = New System.Windows.Forms.Button Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.ActNormal = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(8, 8) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(39, 13) Me.Label1.TabIndex = 0 Me.Label1.Text = "Label1" ' 'ActRed ' Me.ActRed.Location = New System.Drawing.Point(16, 88)

Me.ActRed.Name = "ActRed" Me.ActRed.Size = New System.Drawing.Size(75, 23) Me.ActRed.TabIndex = 1 Me.ActRed.Text = "Red" Me.ActRed.UseVisualStyleBackColor = True ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(8, 32) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(39, 13) Me.Label2.TabIndex = 2 Me.Label2.Text = "Label2" ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(8, 56) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(39, 13) Me.Label3.TabIndex = 3 Me.Label3.Text = "Label3" ' 'ActNormal ' Me.ActNormal.Location = New System.Drawing.Point(104, 88) Me.ActNormal.Name = "ActNormal" Me.ActNormal.Size = New System.Drawing.Size(75, 23) Me.ActNormal.TabIndex = 4 Me.ActNormal.Text = "Normal" Me.ActNormal.UseVisualStyleBackColor = True ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 127) Me.Controls.Add(Me.ActNormal) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.ActRed) Me.Controls.Add(Me.Label1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "Iterating Controls" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class Label1 As ActRed As Label2 As Label3 As ActNormal System.Windows.Forms.Label System.Windows.Forms.Button System.Windows.Forms.Label System.Windows.Forms.Label As System.Windows.Forms.Button

Culoare prim-plan 14.75.2.Set de comand

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ColorDialogSetForgroundBackgroundColor public comun Sub principal Application.Run ( New FrmColorDialogTest ) End Sub End clasa Public class FrmColorDialogTest Motenete System.Windows.Forms.Form Prietenul WithEvents cmdBackgroundButton Ca prieten WithEvents cmdTextButton Ca Button # Region Button

"cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac Ca apel

Boole

MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . cmdBackgroundButton = New System.Windows.Forms.Button () Me.cmdTextButton = New System.Windows.Forms.Button () Me.SuspendLayout () " "cm dBackgroundButton ' Me.cmdBackgroundButton.Location = New System.Drawing.Point ( 16 , 16 ) Me.cmdBackgroundButton.Name = "cmdBackgroundButton" Me.cmdBackgroundButton.Size = New System.Drawing.Size ( 160 , 24 ) Me.cmdBackgroundButton.TabIndex = 0 Me.cmdBackgroundButton.Text = "Change Background Color" " " cm dTextButton ' Me.cmdTextButton.Location = New System.Drawing.Point ( 16 , 56 ) Me.cmdTextButton.Name = "cmdTextButton" Me.cmdTextButton.Size = New System.Drawing.Size ( 160 , 24 ) Me.cmdTextButton. tabindex = 1 Me.cmdTextButton.Text = "Schimb culoarea textului" ' "Parintele mColorDialogTest ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 192 , 93 ) Me . Controls.AddRange ( New System.Windows.Forms.Control () { Me.cmdTextButton, M Me.Name = "FrmColorDialogTest" Me.Text = "Utilizarea Dialoguri Color" Me.ResumeLayout ( Fals ) End Sub # End Dim Regiunea ColorBox Ca ColorDialog = New ColorDialog ()

Private Sub cmdTextButton_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere cmdTextButton.Click Dim rezultat ca DialogResult

Rezultat = colorBox.ShowDialog () Dac rezultatul = DialogResult.Cancel Apoi napoi End Dac cmdBackgroundButton.ForeColor = colorBox.Color cmdTextButton.ForeColor = colorBox.Color End Sub Private Sub cmdBackgroundButton_Click ( _

expeditor ByVal Ca System.Object, _ ByVal e ca System.EventArgs ) _ Manere cmdBackgroundButton.Click Dim rezultat ca DialogResult

colorBox.FullOpen = True rezultat = colorBox.ShowDialog () Dac rezultatul = DialogResult.Cancel Apoi napoi End Dac Me.BackColor = colorBox.Color End Sub End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ColorDialogSetForgroundBackgroundColor public Shared Sub Main Application.Run(New FrmColorDialogTest) End Sub End class Public Class FrmColorDialogTest Inherits System.Windows.Forms.Form Friend WithEvents cmdBackgroundButton As Button

Friend WithEvents cmdTextButton As Button #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.Container

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.cmdBackgroundButton = New System.Windows.Forms.Button() Me.cmdTextButton = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'cmdBackgroundButton ' Me.cmdBackgroundButton.Location = New System.Drawing.Point(16, 16) Me.cmdBackgroundButton.Name = "cmdBackgroundButton" Me.cmdBackgroundButton.Size = New System.Drawing.Size(160, 24) Me.cmdBackgroundButton.TabIndex = 0 Me.cmdBackgroundButton.Text = "Change Background Color" ' 'cmdTextButton ' Me.cmdTextButton.Location = New System.Drawing.Point(16, 56) Me.cmdTextButton.Name = "cmdTextButton" Me.cmdTextButton.Size = New System.Drawing.Size(160, 24) Me.cmdTextButton.TabIndex = 1 Me.cmdTextButton.Text = "Change Text Color" ' 'FrmColorDialogTest ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(192, 93) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdTextButton, Me.cmdB Me.Name = "FrmColorDialogTest" Me.Text = "Using Color Dialogs" Me.ResumeLayout(False) End Sub

#End Region Dim colorBox As ColorDialog = New ColorDialog() Private Sub cmdTextButton_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles cmdTextButton.Click Dim result As DialogResult result = colorBox.ShowDialog() If result = DialogResult.Cancel Then Return End If cmdBackgroundButton.ForeColor = colorBox.Color cmdTextButton.ForeColor = colorBox.Color End Sub Private Sub cmdBackgroundButton_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles cmdBackgroundButton.Click Dim result As DialogResult colorBox.FullOpen = True result = colorBox.ShowDialog() If result = DialogResult.Cancel Then Return End If Me.BackColor = colorBox.Color End Sub End Class

Copy i past de obiect

"R equires o Importurile Importurile Importurile

trimitere la System.Xml. System.Xml.Serialization System.IO System.Windows.Forms

public class CopyPasteEmployee public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa

Publice clasa Form1 <Serializable () > _ public class Angajat publice Prenume Ca String Public NumeDeFamilie Ca String Public Sub New () End Sub Public Sub New ( ByVal prenume Ca Prenume = prenume LastName = LAST_NAME End Sub End clas

String, LAST_NAME ByVal

Ca

String )

"C opy angajat n clipboard. Private Sub btnCopy_Click ( ByVal expeditor Ca System.Object, ByVal e Dim EMP Ca nou angajat ( txtFirstName.Text, txtLastName.Text ) Dim data_object Ca New DataObject data_object.SetData ( "Angajat" , EMP ) Clipboard.SetDataObject ( data_object ) End Sub

ca

System

"P datele aste din clipboard. Private Sub btnPaste_Click ( expeditor ByVal Ca System.Object, ByVal e ca Syste Dim data_object Ca IDataObject = Clipboard.GetDataObject () Dac data_object.GetDataPresent ( "Angajat" ) Apoi, Dim EMP Ca angajat = DirectCast ( data_object.GetData ( "angajat" ) , Ang txtPasteFirstName.Text = emp.FirstName txtPasteLastName.Text = emp.LastName End Dac End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent ()

Ca

Bool

Me.btnPaste = New System.Windows.Forms.Button Me.txtPasteLastName = New System.Windows.Forms.TextBox Me.txtPasteFirstName = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label mine. Label4 = New System.Windows.Forms.Label Me.btnCopy = New System.Windows.Forms.Button Me.txtLastName = New System.Windows.Forms.TextBox Me.txtFirstName = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout () " "bt nPaste ' Me.btnPaste.Location = New System.Drawing.Point ( 232 , 96 ) Me.btnPaste . Nume = "btnPaste" Me.btnPaste.Size = New System.Drawing.Size ( 48 , 24 ) Me.btnPaste.TabIndex = 22 Me.btnPaste.Text = "Paste" " "TX tPasteLastName ' Me.txtPasteLastName.Location = New System.Drawing.Point ( 72 , 112 ) Me.txtPasteLastName.Name = "txtPasteLastName" Me.txtPasteLastName.Size = New System.Drawing.Size ( 136 , 20 ) Me.txtPasteLastName.TabIndex = 21 ' 'TX tPasteFirstName " Me . txtPasteFirstName.Location = New System.Drawing.Point ( 72 , 88 ) Me.txtPasteFirstName.Name = "txtPasteFirstName" Me.txtPasteFirstName.Size = New System.Drawing.Size ( 136 , 20 ) Me.txtPasteFirstName.TabIndex = 20 ' "La bel3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point ( 8 , 112 ) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size ( 54 , 13 ) Me.Label3.TabIndex = 19 Me.Label3.Text = "Nume" " "La bel4 ' Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point ( 8 , 88 ) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size ( 53 , 13 ) Me.Label4.TabIndex = 18 Me.Label4.Text = "Nume" " "bt nCopy " Me. btnCopy.Location = New System.Drawing.Point ( 232 , 16 ) Me.btnCopy.Name = "btnCopy" Me.btnCopy.Size = New System.Drawing.Size ( 48 , 24 ) Me.btnCopy.TabIndex = 17 Me. btnCopy.Text = "Copy" " "TX tLastName

' Me.txtLastName.Location = New System.Drawing.Point ( 72 , 32 ) Me.txtLastName.Name = "txtLastName" Me.txtLastName.Size = New System.Drawing.Size ( 136 , 20 ) Me.txtLastName.TabIndex = 16 Me.txtLastName.Text = "AAAAAA" " "TX tFirstName ' Me.txtFirstName.Location = New System.Drawing.Point ( 72 , 8 ) Me.txtFirstName.Name = " txtFirstName " Me.txtFirstName.Size = New System.Drawing.Size ( 136 , 20 ) Me.txtFirstName.TabIndex = 15 Me.txtFirstName.Text = "bbbbb" " "La bel2 ' Me.Label2.AutoSize = True Me.Label2 . Locaia = New System.Drawing.Point ( 8 , 32 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 54 , 13 ) Me.Label2.TabIndex = 14 Me.Label2 . Text = "Nume" " "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 8 , 8 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 53 , 13 ) Me.Label1.TabIndex = 13 Me.Label1.Text = "Nume" " "Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou

= "Form1" Me.Text = "CopyPasteEmployee" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents btnPaste Ca System.Windows.Forms.Button prieten WithEvents txtPasteLastName Ca System.Windows.Forms.TextBox prieten WithEvents txtPasteFirstName Ca System.Windows.Forms.TextBox prieten WithEvents Label3 Ca System.Windows.Forms.Label prieten WithEvents Label4 Ca System.Windows.Forms.Label prieten WithEvents btnCopy Ca System.Windows.Forms.Button prieten WithEvents txtLastName Ca System.Windows.Forms.TextBox

prieten WithEvents txtFirstName Ca System.Windows.Forms.TextBox prieten WithEvents Label2 Ca System.Windows.Forms. Eticheta prieten WithEvents Label1 Ca System.Windows.Forms.Label End Class

Original

' Requires a reference to System.Xml. Imports System.Xml.Serialization Imports System.IO Imports System.Windows.Forms public class CopyPasteEmployee public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 <Serializable()> _ Public Class Employee Public FirstName As String Public LastName As String Public Sub New() End Sub Public Sub New(ByVal first_name As String, ByVal last_name As String) FirstName = first_name LastName = last_name End Sub End Class

' Copy the Employee to the clipboard. Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs Dim emp As New Employee(txtFirstName.Text, txtLastName.Text) Dim data_object As New DataObject data_object.SetData("Employee", emp) Clipboard.SetDataObject(data_object) End Sub

' Paste data from the clipboard. Private Sub btnPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArg

Dim data_object As IDataObject = Clipboard.GetDataObject() If data_object.GetDataPresent("Employee") Then Dim emp As Employee = DirectCast(data_object.GetData("Employee"), Employee) txtPasteFirstName.Text = emp.FirstName txtPasteLastName.Text = emp.LastName End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.btnPaste = New System.Windows.Forms.Button Me.txtPasteLastName = New System.Windows.Forms.TextBox Me.txtPasteFirstName = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.btnCopy = New System.Windows.Forms.Button Me.txtLastName = New System.Windows.Forms.TextBox Me.txtFirstName = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.Label1 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'btnPaste ' Me.btnPaste.Location = New System.Drawing.Point(232, 96) Me.btnPaste.Name = "btnPaste" Me.btnPaste.Size = New System.Drawing.Size(48, 24) Me.btnPaste.TabIndex = 22 Me.btnPaste.Text = "Paste" ' 'txtPasteLastName ' Me.txtPasteLastName.Location = New System.Drawing.Point(72, 112) Me.txtPasteLastName.Name = "txtPasteLastName" Me.txtPasteLastName.Size = New System.Drawing.Size(136, 20) Me.txtPasteLastName.TabIndex = 21 ' 'txtPasteFirstName ' Me.txtPasteFirstName.Location = New System.Drawing.Point(72, 88) Me.txtPasteFirstName.Name = "txtPasteFirstName" Me.txtPasteFirstName.Size = New System.Drawing.Size(136, 20)

Me.txtPasteFirstName.TabIndex = 20 ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(8, 112) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(54, 13) Me.Label3.TabIndex = 19 Me.Label3.Text = "Last Name" ' 'Label4 ' Me.Label4.AutoSize = True Me.Label4.Location = New System.Drawing.Point(8, 88) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(53, 13) Me.Label4.TabIndex = 18 Me.Label4.Text = "First Name" ' 'btnCopy ' Me.btnCopy.Location = New System.Drawing.Point(232, 16) Me.btnCopy.Name = "btnCopy" Me.btnCopy.Size = New System.Drawing.Size(48, 24) Me.btnCopy.TabIndex = 17 Me.btnCopy.Text = "Copy" ' 'txtLastName ' Me.txtLastName.Location = New System.Drawing.Point(72, 32) Me.txtLastName.Name = "txtLastName" Me.txtLastName.Size = New System.Drawing.Size(136, 20) Me.txtLastName.TabIndex = 16 Me.txtLastName.Text = "AAAAAA" ' 'txtFirstName ' Me.txtFirstName.Location = New System.Drawing.Point(72, 8) Me.txtFirstName.Name = "txtFirstName" Me.txtFirstName.Size = New System.Drawing.Size(136, 20) Me.txtFirstName.TabIndex = 15 Me.txtFirstName.Text = "BBBBB" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(8, 32) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(54, 13) Me.Label2.TabIndex = 14 Me.Label2.Text = "Last Name" ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(8, 8) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(53, 13) Me.Label1.TabIndex = 13 Me.Label1.Text = "First Name"

' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(288, 139) Me.Controls.Add(Me.btnPaste) Me.Controls.Add(Me.txtPasteLastName) Me.Controls.Add(Me.txtPasteFirstName) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.btnCopy) Me.Controls.Add(Me.txtLastName) Me.Controls.Add(Me.txtFirstName) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "CopyPasteEmployee" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class btnPaste As System.Windows.Forms.Button txtPasteLastName As System.Windows.Forms.TextBox txtPasteFirstName As System.Windows.Forms.TextBox Label3 As System.Windows.Forms.Label Label4 As System.Windows.Forms.Label btnCopy As System.Windows.Forms.Button txtLastName As System.Windows.Forms.TextBox txtFirstName As System.Windows.Forms.TextBox Label2 As System.Windows.Forms.Label Label1 As System.Windows.Forms.Label

Drop un fiier

Importurile Importurile

System.Data System.Data.OleDb

Importurile

System.Windows.Forms

public class FileDrop public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 "O copie llow dac exist date FileDrop. Private Sub lblDropTarget_DragEnter ( expeditor ByVal Ca obiect, e ByVal Dac e.Data.GetDataPresent ( DataFormats.FileDrop ) Apoi e . Efectul = DragDropEffects.Copy Altfel e.Effect = DragDropEffects.None Dac End End Sub

Ca

Sys

"D isplay numele de fiier a sczut. Private Sub lblDropTarget_DragDrop ( expeditor ByVal Ca obiect, ByVal e ca Syst lstFiles.Items.Clear () Dim file_names Ca String () = DirectCast ( e. Data.GetData ( DataFormats.Fil Pentru fiecare file_name Ca ir n file_names lstFiles.Items.Add ( FILE_NAME ) nainte file_name End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial publice clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.lstFiles = New System.Windows.Forms.ListBox Me.lblDropTarget = New System.Windows.Forms.Label Me.SuspendLayout () " "ls tFiles ' Me.lstFiles.Dock = System.Windows.Forms.DockStyle.Fill Me . lstFiles.FormattingEnabled = True Me.lstFiles.Location = New System.Drawing.Point ( 0 , 48 ) Me.lstFiles.Name = "lstFiles" Me.lstFiles.Size = New System.Drawing.Size ( 274 , 160 ) Me lstFiles.TabIndex =. 3 "

Ca

Bool

'lb lDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Dock = System.Windows.Forms.DockStyle.Top mine. lblDropTarget.Location = New System.Drawing.Point ( 0 , 0 ) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size ( 274 , 48 ) Me.lblDropTarget.TabIndex = 2 Me. lblDropTarget.Text = "s renune la obiectivul" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows . Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 274 , 210 ) Me.Controls.Add ( Me.lstFiles ) Me.Controls.Add ( Me.lblDropTarget ) Me.Name = "Form1" Me. Text = "AcceptFiles" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents lstFiles Ca prieten WithEvents lblDropTarget End Class System.Windows.Forms.ListBox Ca System.Windows.Forms.Label

Original

Imports System.Data Imports System.Data.OleDb Imports System.Windows.Forms public class FileDrop public Shared Sub Main Application.Run(New Form1)

End Sub End class

Public Class Form1 ' Allow Copy if there is FileDrop data. Private Sub lblDropTarget_DragEnter(ByVal sender As Object, ByVal e As System.Window If e.Data.GetDataPresent(DataFormats.FileDrop) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub

' Display the dropped file names. Private Sub lblDropTarget_DragDrop(ByVal sender As Object, ByVal e As System.Windows lstFiles.Items.Clear() Dim file_names As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop), St For Each file_name As String In file_names lstFiles.Items.Add(file_name) Next file_name End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.lstFiles = New System.Windows.Forms.ListBox Me.lblDropTarget = New System.Windows.Forms.Label Me.SuspendLayout() ' 'lstFiles ' Me.lstFiles.Dock = System.Windows.Forms.DockStyle.Fill Me.lstFiles.FormattingEnabled = True Me.lstFiles.Location = New System.Drawing.Point(0, 48) Me.lstFiles.Name = "lstFiles" Me.lstFiles.Size = New System.Drawing.Size(274, 160) Me.lstFiles.TabIndex = 3 ' 'lblDropTarget ' Me.lblDropTarget.AllowDrop = True Me.lblDropTarget.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblDropTarget.Dock = System.Windows.Forms.DockStyle.Top

Me.lblDropTarget.Location = New System.Drawing.Point(0, 0) Me.lblDropTarget.Name = "lblDropTarget" Me.lblDropTarget.Size = New System.Drawing.Size(274, 48) Me.lblDropTarget.TabIndex = 2 Me.lblDropTarget.Text = "Drop Target" Me.lblDropTarget.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(274, 210) Me.Controls.Add(Me.lstFiles) Me.Controls.Add(Me.lblDropTarget) Me.Name = "Form1" Me.Text = "AcceptFiles" Me.ResumeLayout(False) End Sub Friend WithEvents lstFiles As System.Windows.Forms.ListBox Friend WithEvents lblDropTarget As System.Windows.Forms.Label End Class

Drag i pictur ListBox

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class ListBoxDragDrop public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Publice clasa Form1 privat dragBounds Ca dreptunghi private dragMethod Ca String Private Sub ListBox1_DragEnter ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.DragEventArgs ) _ Manere ListBox1.DragEnter "- . ---- Da, am accepta elementele Dac ( e.Data.GetDataPresent ( ListBox2.SelectedItems . _ gettype ()) = true ) Apoi _

e.Effect = DragDropEffects.Move End Sub Sub privat ListBox1_DragDrop ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.DragEventArgs ) _ Manere ListBox1.DragDrop "- ---- accepta aceste elemente au sczut. Pentru fiecare oneItem Ca obiect n _ e.Data.GetData ( ListBox2.SelectedItems.GetType ()) ListBox1.Items.Add ( oneItem ) nainte oneItem End Sub Sub privat ListBox1_MouseDown ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere ListBox1.MouseDown, ListBox2.MouseDown "- ---- Pregtii coninutul draggable. Dac ( Ctype ( expeditor, ListBox ) . SelectedItems.Count =

0 )

apoi s se n

- " ---- Don t " ncepe tragei nc. Ateptai pn cnd vom muta o " sum anume. dragBounds = dreptunghi nou ( New Punctul ( EX - _ ( SystemInformation.DragSize.Width / 2 ) , _ eY - ( SystemInformation.DragSize.Height / 2 )) , _ SystemInformation.DragSize ) n cazul n care ( expeditorul este ListBox1 ) Apoi dragMethod = "1to2" Altfel dragMethod = "2to1" Dac End End Sub Private Sub ListBox1_MouseMove ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere ListBox1.MouseMove "- ---- Ignora dac nu tragei de ListBox1. Dac ( dragMethod <> "1to2" ) apoi s se ntoarc "- ---- Ne-am plecat de la limita tragei? Dac ( dragBounds.Contains ( EX, eY ) = false ) Apoi, "- . ---- ncepe operaiunea de drag-and-drop Dac ( ListBox1.DoDragDrop ( ListBox1. SelectedItems, _ DragDropEffects.Move ) = _ DragDropEffects.Move ) Apoi "- ---- micare de succes. Elimina elementele de la " aceast list. n timp ce face ListBox1.SelectedItems.Count> 0 ListBox1.Items.Remove ( ListBox1.SelectedItems ( 0 )) Bucl End Dac dragMethod = "" Dac End End Sub Sub privat ListBox1_MouseUp ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere ListBox1.MouseUp, ListBox2.MouseUp "- ---- End . de drag-and-drop dragMethod = "" End Sub

Private Sub ListBox2_DragEnter ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.DragEventArgs ) _ Manere ListBox2.DragEnter "- . ---- Da, am accepta elementele Dac ( e.Data.GetDataPresent ( ListBox1.SelectedItems . _ gettype ()) = true ) Apoi _ e.Effect = DragDropEffects.Move End Sub Sub privat ListBox2_DragDrop ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.DragEventArgs ) _ Manere ListBox2.DragDrop "- ---- accepta aceste elemente au sczut. Pentru fiecare oneItem Ca obiect n _ e.Data.GetData ( ListBox1.SelectedItems.GetType ()) ListBox2.Items.Add ( oneItem ) nainte oneItem End Sub Private Sub ListBox2_MouseMove ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.MouseEventArgs ) _ Manere ListBox2.MouseMove "- ---- Ignora dac nu tragei de ListBox2. Dac ( dragMethod <> "2to1" ) apoi s se ntoarc "- ---- Ne-am plecat de la limita tragei? Dac ( dragBounds.Contains ( EX, eY ) = false ) Apoi, "- . ---- ncepe operaiunea de drag-and-drop Dac ( ListBox2.DoDragDrop ( ListBox2. SelectedItems, _ DragDropEffects.Move ) = _ DragDropEffects.Move ) Apoi "- ---- micare de succes. Elimina elementele din " aceast list. n timp ce face ListBox2.SelectedItems.Count> 0 ListBox2.Items.Remove ( ListBox2.SelectedItems ( 0 )) Bucl End Dac dragMethod = "" Dac End End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows

Boolean )

"Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.ListBox1 = New System.Windows.Forms.ListBox Me.ListBox2 = New System.Windows.Forms.ListBox Me.SuspendLayout () " "Li stBox1 ' Me.ListBox1.AllowDrop = True Me.ListBox1.FormattingEnabled = True mine. ListBox1.Items.AddRange ( Object Nou () { "One" , "doi" , "trei" , "pat Me.ListBox1.Location = New System.Drawing.Point ( 8 , 8 ) Me.ListBox1.Name = "ListBox1" Me.ListBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended Me.ListBox1.Size = New System.Drawing.Size ( 192 , 95 ) Me.ListBox1.TabIndex = 0 " "Li stBox2 ' Me.ListBox2.AllowDrop = True Me.ListBox2.FormattingEnabled = True Me.ListBox2.Location = New System.Drawing.Point ( 208 , 8 ) Me.ListBox2.Name = "ListBox2" Me.ListBox2. SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended Me.ListBox2.Size = New System.Drawing.Size ( 192 , 95 ) Me.ListBox2.TabIndex = 1 ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = Nou = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = false Me.Name = "Form1" Me.Text = "ListBox drag-and-drop" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents ListBox1 Ca System.Windows.Forms.ListBox prieten WithEvents ListBox2 Ca System.Windows.Forms.ListBox End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class ListBoxDragDrop public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private dragBounds As Rectangle Private dragMethod As String Private Sub ListBox1_DragEnter(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles ListBox1.DragEnter ' ----- Yes, we accept the items. If (e.Data.GetDataPresent(ListBox2.SelectedItems. _ GetType()) = True) Then _ e.Effect = DragDropEffects.Move End Sub Private Sub ListBox1_DragDrop(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles ListBox1.DragDrop ' ----- Accept the dropped items. For Each oneItem As Object In _ e.Data.GetData(ListBox2.SelectedItems.GetType()) ListBox1.Items.Add(oneItem) Next oneItem End Sub Private Sub ListBox1_MouseDown(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles ListBox1.MouseDown, ListBox2.MouseDown ' ----- Prepare the draggable content. If (CType(sender, ListBox).SelectedItems.Count = 0) Then Return ' ----- Don't start the drag yet. Wait until we move a ' certain amount. dragBounds = New Rectangle(New Point(e.X - _ (SystemInformation.DragSize.Width / 2), _ e.Y - (SystemInformation.DragSize.Height / 2)), _ SystemInformation.DragSize) If (sender Is ListBox1) Then dragMethod = "1to2" Else dragMethod = "2to1" End If End Sub

Private Sub ListBox1_MouseMove(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles ListBox1.MouseMove ' ----- Ignore if not dragging from ListBox1. If (dragMethod <> "1to2") Then Return ' ----- Have we left the drag boundary? If (dragBounds.Contains(e.X, e.Y) = False) Then ' ----- Start the drag-and-drop operation. If (ListBox1.DoDragDrop(ListBox1.SelectedItems, _ DragDropEffects.Move) = _ DragDropEffects.Move) Then ' ----- Successful move. Remove the items from ' this list. Do While ListBox1.SelectedItems.Count > 0 ListBox1.Items.Remove(ListBox1.SelectedItems(0)) Loop End If dragMethod = "" End If End Sub Private Sub ListBox1_MouseUp(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles ListBox1.MouseUp, ListBox2.MouseUp ' ----- End of drag-and-drop. dragMethod = "" End Sub Private Sub ListBox2_DragEnter(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles ListBox2.DragEnter ' ----- Yes, we accept the items. If (e.Data.GetDataPresent(ListBox1.SelectedItems. _ GetType()) = True) Then _ e.Effect = DragDropEffects.Move End Sub Private Sub ListBox2_DragDrop(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles ListBox2.DragDrop ' ----- Accept the dropped items. For Each oneItem As Object In _ e.Data.GetData(ListBox1.SelectedItems.GetType()) ListBox2.Items.Add(oneItem) Next oneItem End Sub Private Sub ListBox2_MouseMove(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles ListBox2.MouseMove ' ----- Ignore if not dragging from ListBox2. If (dragMethod <> "2to1") Then Return ' ----- Have we left the drag boundary? If (dragBounds.Contains(e.X, e.Y) = False) Then ' ----- Start the drag-and-drop operation. If (ListBox2.DoDragDrop(ListBox2.SelectedItems, _ DragDropEffects.Move) = _ DragDropEffects.Move) Then

' ----- Successful move. Remove the items from ' this list. Do While ListBox2.SelectedItems.Count > 0 ListBox2.Items.Remove(ListBox2.SelectedItems(0)) Loop End If dragMethod = "" End If End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.ListBox1 = New System.Windows.Forms.ListBox Me.ListBox2 = New System.Windows.Forms.ListBox Me.SuspendLayout() ' 'ListBox1 ' Me.ListBox1.AllowDrop = True Me.ListBox1.FormattingEnabled = True Me.ListBox1.Items.AddRange(New Object() {"One", "Two", "Three", "Four", "Five", Me.ListBox1.Location = New System.Drawing.Point(8, 8) Me.ListBox1.Name = "ListBox1" Me.ListBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended Me.ListBox1.Size = New System.Drawing.Size(192, 95) Me.ListBox1.TabIndex = 0 ' 'ListBox2 ' Me.ListBox2.AllowDrop = True Me.ListBox2.FormattingEnabled = True Me.ListBox2.Location = New System.Drawing.Point(208, 8) Me.ListBox2.Name = "ListBox2" Me.ListBox2.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended Me.ListBox2.Size = New System.Drawing.Size(192, 95) Me.ListBox2.TabIndex = 1 ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)

Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(408, 112) Me.Controls.Add(Me.ListBox2) Me.Controls.Add(Me.ListBox1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "ListBox Drag-and-Drop" Me.ResumeLayout(False) End Sub Friend WithEvents ListBox1 As System.Windows.Forms.ListBox Friend WithEvents ListBox2 As System.Windows.Forms.ListBox End Class

Drag fiier de fiier Exploreaz la ListBox

Importurile Importurile Importurile

System.Drawing System.Drawing.Drawing2D System.Windows.Forms

public class FileDragDrop public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Public Class Form1 Private Sub ListBox1_DragEnter ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.DragEventArgs ) _ Manere ListBox1.DragEnter n cazul n care ( e.Data.GetDataPresent ( DataFormats.FileDrop ) e.Effect = DragDropEffects.Copy Dac End End Sub = True )

Ap

Sub privat ListBox1_DragDrop ( expeditor ByVal Ca obiect, _ ByVal e ca System.Windows.Forms.DragEventArgs ) _ Manere ListBox1.DragDrop Pentru fiecare oneFile Ca String n _ e.Data.GetData ( DataFormats.FileDrop ) ListBox1.Items.Add ( oneFile ) nainte oneFile End Sub End Class <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.ListBox1 = New System.Windows.Forms.ListBox Me.SuspendLayout () " "Li stBox1 ' Me.ListBox1.AllowDrop = True Me.ListBox1.FormattingEnabled = True Me.ListBox1.Location = New System.Drawing.Point ( 8 , 8 ) Me.ListBox1.Name = "ListBox1" Me.ListBox1.Size = New System.Drawing.Size ( 576 , 238 ) Me.ListBox1.TabIndex = 0 ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing. SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size ( 594 , 256 ) Me.Controls.Add ( Me.ListBox1 ) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = false Me.Name = "Form1" Me.Text = "Drag and Drop Files" Me.ResumeLayout ( Fals ) End Sub prieten WithEvents ListBox1 Ca System.Windows.Forms.ListBox

Boolean )

End Class

Original

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class FileDragDrop public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class Form1 Private Sub ListBox1_DragEnter(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles ListBox1.DragEnter If (e.Data.GetDataPresent(DataFormats.FileDrop) =True) Then e.Effect = DragDropEffects.Copy End If End Sub Private Sub ListBox1_DragDrop(ByVal sender As Object, _ ByVal e As System.Windows.Forms.DragEventArgs) _ Handles ListBox1.DragDrop For Each oneFile As String In _ e.Data.GetData(DataFormats.FileDrop) ListBox1.Items.Add(oneFile) Next oneFile End Sub End Class

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.ListBox1 = New System.Windows.Forms.ListBox Me.SuspendLayout() ' 'ListBox1 ' Me.ListBox1.AllowDrop = True Me.ListBox1.FormattingEnabled = True Me.ListBox1.Location = New System.Drawing.Point(8, 8) Me.ListBox1.Name = "ListBox1" Me.ListBox1.Size = New System.Drawing.Size(576, 238) Me.ListBox1.TabIndex = 0 ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(594, 256) Me.Controls.Add(Me.ListBox1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "Drag and Drop Files" Me.ResumeLayout(False) End Sub Friend WithEvents ListBox1 As System.Windows.Forms.ListBox End Class

Get toate controalele de pe o form i verifica tipul

Importurile Importurile Importurile

System.Windows.Forms System.Drawing System.Drawing.Drawing2D

public class GetAllControlsOnForm public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa

Public Class Form1 Private Sub ActRed_Click ( ByVal expeditor Ca System.Object, ByVal e pentru fiecare scanControls Ca de control n Me.Controls Dac ( typeof scanControls Este Label ) Apoi scanControls.BackColor = Color.Red End Dac scanControls Urmtor End Sub Private Sub ActNormal_Click ( ByVal expeditor Ca

ca

System.

System.Object, ByVal e

ca

Syst

Pentru fiecare scanControls Ca de control n Me.Controls Dac ( typeof scanControls Este Label ) Apoi scanControls.BackColor = SystemColors.Control End Dac scanControls Urmatorul End Sub End Class

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated () > _ parial clasa Form1 Motenete System.Windows.Forms.Form "Fo suprascrie rm dispune pentru a cura lista de componente. <System.Diagnostics.DebuggerNonUserCode () > _ protejate nlocuiete Sub Distrugerea ( ByVal eliminare Ca Dac dispunerea componentelor andalso isnot Nimic Apoi components.Dispose () End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer

Boolean )

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > _ Private Sub InitializeComponent () Me.Label1 = New System.Windows.Forms.Label Me.ActRed = New System.Windows.Forms.Button Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label mine. ActNormal = New System.Windows.Forms.Button Me.SuspendLayout () " "La bel1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point ( 8 , 8 ) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size ( 39 , 13 ) Me.Label1.TabIndex = 0 Me.Label1.Text = "Label1" " "Ac TRED ' Me.ActRed.Location = Sistem. Drawing.Point ( 16 , 88 ) Me.ActRed.Name = "ActRed" Me.ActRed.Size = New System.Drawing.Size ( 75 , 23 ) Me.ActRed.TabIndex = 1 Me.ActRed.Text = "Red" Me.ActRed.UseVisualStyleBackColor = True ' 'La bel2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point ( 8 , 32 ) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size ( 39 , 13 ) Me.Label2.TabIndex = 2 Me.Label2.Text = "Label2" " "La bel3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing . Punctul ( 8 , 56 ) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size ( 39 , 13 ) Me.Label3.TabIndex = 3 Me.Label3.Text = "Label3" " "Ac tNormal ' Me.ActNormal.Location = New System.Drawing.Point ( 104 , 88 ) Me.ActNormal.Name = "ActNormal" Me.ActNormal.Size = New System.Drawing.Size ( 75 , 23 ) Me.ActNormal . tabindex = 4 Me.ActNormal.Text = "Normal" Me.ActNormal.UseVisualStyleBackColor = True ' 'Fo RM1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF ( 6.0 !, 13.0 ! ) Me.AutoScaleMode = System.Windows. Forms.AutoScaleMode.Font

Me.ClientSize = Nou

= System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = false Me.Name = "Form1" Me.Text = "iterarea Controls" Me.ResumeLayout ( Fals ) Me.PerformLayout () End Sub prieten WithEvents Label1 Ca System.Windows.Forms.Label prieten WithEvents ActRed Ca System.Windows.Forms.Button prieten WithEvents Label2 Ca System.Windows.Forms.Label prieten WithEvents Label3 Ca System.Windows.Forms.Label prieten WithEvents ActNormal Ca System.Windows.Forms.Button End Class

Original

Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D public class GetAllControlsOnForm public Shared Sub Main Application.Run(New Form1) End Sub End class

Public Class Form1 Private Sub ActRed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) For Each scanControls As Control In Me.Controls If (TypeOf scanControls Is Label) Then scanControls.BackColor = Color.Red End If Next scanControls End Sub

Private Sub ActNormal_Click(ByVal sender As System.Object, ByVal e As System.EventAr For Each scanControls As Control In Me.Controls If (TypeOf scanControls Is Label) Then scanControls.BackColor = SystemColors.Control End If Next scanControls End Sub End Class

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Label1 = New System.Windows.Forms.Label Me.ActRed = New System.Windows.Forms.Button Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.ActNormal = New System.Windows.Forms.Button Me.SuspendLayout() ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(8, 8) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(39, 13) Me.Label1.TabIndex = 0 Me.Label1.Text = "Label1" ' 'ActRed ' Me.ActRed.Location = New System.Drawing.Point(16, 88) Me.ActRed.Name = "ActRed" Me.ActRed.Size = New System.Drawing.Size(75, 23) Me.ActRed.TabIndex = 1 Me.ActRed.Text = "Red" Me.ActRed.UseVisualStyleBackColor = True ' 'Label2

' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(8, 32) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(39, 13) Me.Label2.TabIndex = 2 Me.Label2.Text = "Label2" ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(8, 56) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(39, 13) Me.Label3.TabIndex = 3 Me.Label3.Text = "Label3" ' 'ActNormal ' Me.ActNormal.Location = New System.Drawing.Point(104, 88) Me.ActNormal.Name = "ActNormal" Me.ActNormal.Size = New System.Drawing.Size(75, 23) Me.ActNormal.TabIndex = 4 Me.ActNormal.Text = "Normal" Me.ActNormal.UseVisualStyleBackColor = True ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(292, 127) Me.Controls.Add(Me.ActNormal) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.ActRed) Me.Controls.Add(Me.Label1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "Iterating Controls" Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents Friend WithEvents End Class Label1 As ActRed As Label2 As Label3 As ActNormal System.Windows.Forms.Label System.Windows.Forms.Button System.Windows.Forms.Label System.Windows.Forms.Label As System.Windows.Forms.Button

RadioButton MenuItem

Importurile

System.Windows.Forms

public class RadioButtonCheckBox public comun Sub principal Application.Run ( New Form1 ) End Sub End clasa Public class MDIChild Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul Form Designer pentru Windows. "Nu -l modificai folosind editorul de cod. prieten WithEvents RichTextBox1 Ca System.Windows.Forms.RichTextBox prieten WithEvents mainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents mnuMDIOptions Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMDIOpiton1 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMDIOpiton2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMDIOpiton3 Ca System.Windows.Forms. MenuItem <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.RichTextBox1 = New System.Windows.Forms.RichTextBox () Ca apel

Bool

Me.mainMenu1 = New System.Windows.Forms.MainMenu () Me.mnuMDIOptions = Sistem. Windows.Forms.MenuItem () Me.mnuMDIOpiton1 = New System.Windows.Forms.MenuItem () Me.mnuMDIOpiton2 = New System.Windows.Forms.MenuItem () Me.mnuMDIOpiton3 = New System.Windows.Forms.MenuItem () Me . SuspendLayout () " "Ri chTextBox1 ' Me.RichTextBox1.Name = "RichTextBox1" Me.RichTextBox1.Size = New System.Drawing.Size ( 296 , 176 ) Me.RichTextBox1.TabIndex = 0 Me.RichTextBox1.Text = "RichTextBox1 " " "ma inMenu1 " Me.mainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuM " "mil lei uMDIOptions ' Me.mnuMDIOptions.Index = 0 Me.mnuMDIOptions.MenuItems.AddRange ( nou System.Windows.Forms.MenuItem () { Me. Me.mnuMDIOptions.MergeOrder = 1 Me.mnuMDIOptions.Text = "MDIChildOptions" " "milioane uMDIOpiton1 " Me.mnuMDIOpiton1.Index = 0 Me.mnuMDIOpiton1.Text = "MDI Opiunea 1" ' 'mil. uMDIOpiton2 ' Me.mnuMDIOpiton2.Index = 1 Me.mnuMDIOpiton2.Text = "MDI Opiunea 2" ' 'mil. uMDIOpiton3 ' Me.mnuMDIOpiton3.Index = 2 Me. mnuMDIOpiton3.Text = "MDI Opiunea 3" " "MD IChild ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 292 , 174 ) Me.Controls.AddRange ( nou System.Windows.Forms.Control () { Me.RichTextBox1 }) Me.Menu = Me.mainMenu1 Me.Name = "MDIChild" Me.Text = "MDIChild" Me.ResumeLayout ( Fals ) End Sub # End Regiunea Private Sub Option_Click ( ByVal expeditor Ca System.Object, ByVal e Manere mnuMDIOpiton1.Click, mnuMDIOpiton2.Click, mnuMDIOpiton3.Click Dim punctul Ca MenuItem = Ctype ( expeditor, MenuItem ) item.Checked = Nu item.Checked End Sub End Class ca

System.

Publice clasa Form1 Motenete System.Windows.Forms.Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () End Dac End Dac MyBase.Dispose ( eliminare ) End Sub "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.IContainer "NU TE: Urmtoarea procedur este necesar de Windows Form Designer "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind . editorul de cod WithEvents prieten mainMenu1 Ca System.Windows.Forms.MainMenu prieten WithEvents mnuFile Ca System.Windows.Forms.MenuItem prieten WithEvents mnuNew Ca System.Windows.Forms.MenuItem prieten WithEvents mnuFileOpen Ca System.Windows.Forms.MenuItem prieten WithEvents mnuFileClose Ca System.Windows.Forms.MenuItem prieten WithEvents mnuFileSave Ca System.Windows.Forms. MenuItem prieten WithEvents mnuFileSaveAs Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEdit Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEditCopy Ca System.Windows.Forms.MenuItem prieten WithEvents mnuEditPaste Ca System.Windows.Forms.MenuItem prieten mnuOptions WithEvents Ca sistem . Windows.Forms.MenuItem prieten WithEvents mnuOption1 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuOption2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuOption3 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOptions Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOption1 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOption2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuRadioOption3 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuWindow Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu1 Ca sistem. Windows.Forms.MenuItem prieten WithEvents mnuMenu11 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu12 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu13 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu14 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMerge Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu2 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu21 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu22 Ca System.Windows.Forms.MenuItem prieten WithEvents mnuMenu23 Ca System.Windows . Forms.MenuItem Ca apel

Bool

prieten WithEvents mnuMenu24 Ca System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me.mainMenu1 = New System.Windows.Forms.MainMenu () Me.mnuFile = Sistem. Windows.Forms.MenuItem () Me.mnuNew = New System.Windows.Forms.MenuItem () Me.mnuFileOpen = New System.Windows.Forms.MenuItem () Me.mnuFileClose = New System.Windows.Forms.MenuItem () Me . mnuFileSave = New System.Windows.Forms.MenuItem () Me.mnuFileSaveAs = New System.Windows.Forms.MenuItem () Me.mnuEdit = New System.Windows.Forms.MenuItem () Me.mnuEditCopy = New System.Windows. Forms.MenuItem () Me.mnuEditPaste = New System.Windows.Forms.MenuItem () Me.mnuOptions = New System.Windows.Forms.MenuItem () Me.mnuOption1 = New System.Windows.Forms.MenuItem () Me.mnuOption2 = New System.Windows.Forms.MenuItem () Me.mnuOption3 = New System.Windows.Forms.MenuItem () Me.mnuRadioOptions = New System.Windows.Forms.MenuItem () Me.mnuRadioOption1 = System.Windows.Forms noi. MenuItem () Me.mnuRadioOption2 = New System.Windows.Forms.MenuItem () Me.mnuRadioOption3 = New System.Windows.Forms.MenuItem () Me.mnuWindow = New System.Windows.Forms.MenuItem () Me.mnuMenu1 = Nou System.Windows.Forms.MenuItem () Me.mnuMenu11 = New System.Windows.Forms.MenuItem () Me.mnuMenu12 = New System.Windows.Forms.MenuItem () Me.mnuMenu13 = New System.Windows.Forms.MenuItem ( ) Me.mnuMenu14 = New System.Windows.Forms.MenuItem () Me.mnuMerge = New System.Windows.Forms.MenuItem () Me.mnuMenu2 = New System.Windows.Forms.MenuItem () Me.mnuMenu21 = Sistem. Windows.Forms.MenuItem () Me.mnuMenu22 = New System.Windows.Forms.MenuItem () Me.mnuMenu23 = New System.Windows.Forms.MenuItem () Me.mnuMenu24 = New System.Windows.Forms.MenuItem () " "ma inMenu1 " Me.mainMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuF " "mil lei uFile ' Me.mnuFile.Index = 0 Me.mnuFile.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuNew Me.mnuFile.Text = "File" " "milioane uNew ' Me.mnuNew.Index = 0 Me.mnuNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN Me.mnuNew.Text = "& New" " "mil. uFileOpen ' Me.mnuFileOpen.Index = 1 Me.mnuFileOpen.Text = "Open" " "milioane uFileClose ' Me.mnuFileClose.Index = 2 Me.mnuFileClose.Text = "Close" " "milioane uFileSave "

Me.mnuFileSave. index = 3 Me.mnuFileSave.Text = "Salvare" " "milioane uFileSaveAs ' Me.mnuFileSaveAs.Index = 4 Me.mnuFileSaveAs.Text = "Salvare & A" " "milioane uEdit " Me.mnuEdit.Index = 1 Me.mnuEdit.MenuItems . AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuE Me.mnuEdit.Text = "Edit" " "milioane uEditCopy ' Me.mnuEditCopy.Index = 0 Me.mnuEditCopy.Text = "& Copy", " 'mil. uEditPaste ' Me.mnuEditPaste.Index = 1 Me.mnuEditPaste.Text = "Paste" " "milioane uOptions ' Me.mnuOptions.Index = 2 Me.mnuOptions.MenuItems.AddRange ( New System.Windows.Forms . MenuItem () { Me.m Me.mnuOptions.Text = "Opiuni" " "milioane uOption1 ' Me.mnuOption1.Index = 0 Me.mnuOption1.Text = "Opiunea 1" " " mil. uOption2 ' Me.mnuOption2.Index = 1 Me.mnuOption2.Text = "Opiunea 2" ' 'mil. uOption3 ' Me.mnuOption3.Index = 2 Me.mnuOption3.Text = "Option3" " "milioane uRadioOptions " Me.mnuRadioOptions.Index = 3 Me.mnuRadioOptions.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { M Me.mnuRadioOptions.Text = "Opiuni de radio" " "milioane uROption1 " Me . mnuRadioOption1.Index = 0 Me.mnuRadioOption1.RadioCheck = True Me.mnuRadioOption1.Text = "Opiunea Radio 1" ' 'mil. uROption2 ' Me.mnuRadioOption2.Index = 1 Me.mnuRadioOption2.RadioCheck = True

Me.mnuRadioOption2.Text = " Opiunea Radio 2 " ' 'mil. uROption3 ' Me.mnuRadioOption3.Index = 2 Me.mnuRadioOption3.RadioCheck = True Me.mnuRadioOption3.Text = "Opiunea Radio 3", " 'mil. uWindow ' Me.mnuWindow.Index = 4 Me.mnuWindow. MdiList = True Me.mnuWindow.MergeOrder = 99 Me.mnuWindow.Text = "& Window" " "milioane uMenu1 ' Me.mnuMenu1.Index = 5 Me.mnuMenu1.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.mnuMe Me.mnuMenu1.Text = "Meniul 1" ' 'mil. uMenu11 ' Me.mnuMenu11.Index = 0 Me.mnuMenu11.MergeOrder = 1 Me.mnuMenu11.Text = "Meniu 1.1" " "milioane uMenu12 ' Me.mnuMenu12.Index = 1 Me.mnuMenu12.MergeOrder = 2 Me.mnuMenu12.Text = "Meniu 1.2" " "milioane uMenu13 ' Me.mnuMenu13.Index = 2 Me.mnuMenu13.MergeOrder = 3 Me.mnuMenu13.Text = "Meniu 1.3" " "milioane uMenu14 ' Me.mnuMenu14.Index = 3 Me.mnuMenu14.MergeOrder = 4 Me.mnuMenu14.Text = "Meniu 1.4", " milioane " uMerge ' Me.mnuMerge.Index = 4 Me.mnuMerge.MergeOrder = 99 Me.mnuMerge.Text = "Merge!" " "milioane uMenu2 ' Me.mnuMenu2.Index = 6 Me.mnuMenu2.MenuItems.AddRange ( New System.Windows . Forms.MenuItem () { Me.mnu Me.mnuMenu2.Text = "Meniul 2" ' 'mil. uMenu21 ' Me.mnuMenu21.Index = 0 Me.mnuMenu21. MergeOrder = 1

Me.mnuMenu21.Text = "Meniu 2.1" " "milioane uMenu22 ' Me.mnuMenu22.Index = 1 Me.mnuMenu22.MergeOrder = 2 Me.mnuMenu22.MergeType = System.Windows.Forms.MenuMerge.Replace Me.mnuMenu22 . Text = "Meniu 2.2" " "milioane uMenu23 ' Me.mnuMenu23.Index = 2 Me.mnuMenu23.MergeOrder = 3 Me.mnuMenu23.MergeType = System.Windows.Forms.MenuMerge.Remove Me.mnuMenu23.Text = "Meniul 2.3 " " "milioane uMenu24 ' Me.mnuMenu24.Index = 3 Me.mnuMenu24.MergeOrder = 5 Me.mnuMenu24.Text = "Meniu 2.4" " "Fo RM1 ' Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 ) Me.ClientSize = New System.Drawing.Size ( 456 , 146 ) Me.IsMdiContainer = True Me.Menu = Me.mainMenu1 Me.Name = "Form1" Me.Text = "Form1" End Sub # End Regiunea Ca System.Object, ByVal e ca

Private Sub mnuNew_Click ( ByVal expeditor Manere mnuNew.Click Dim newMDIChild Ca New MDIChild () newMDIChild.MdiParent = Me newMDIChild.Show () End Sub

System.

Private Sub mnuFileOpen_Click ( ByVal expeditor Ca System.Object, ByVal e Manere mnuFileOpen.Click MessageBox.Show ( "Ai fcut clic fiier deschis!" , _ "tester eveniment Menu" , _ MessageBoxButtons.OK, _ MessageBoxIcon. Informaii ) End Sub

ca

Sy

Private Sub mnuFileClose_Click ( ByVal expeditor Ca System.Object, ByVal e ca S Manere mnuFileClose.Click MessageBox.Show ( "Ai fcut clic fiier aproape!" , "tester Meniu eveniment" , End Sub Private Sub mnuEditCopy_Click ( ByVal expeditor Ca Manere mnuEditCopy.Click MessageBox.Show ( "Ai fcut clic Edit copie!" , End Sub System.Object, ByVal e ca

Sy

"tester Meniu eveniment" , Mes

Private Sub mnuEditPaste_Click ( ByVal expeditor Ca System.Object, ByVal e ca S Manere mnuEditPaste.Click MessageBox.Show ( "Ai fcut clic pe Editare paste!" , "tester Meniu eveniment" End Sub Private Sub Option_Click ( ByVal expeditor Ca System.Object, ByVal e Manere mnuOption1.Click, mnuOption2.Click, mnuOption3.Click Dim punctul Ca MenuItem = Ctype ( expeditor, MenuItem ) item.Checked = Nu item.Checked End Sub ca

System.

Private Sub RadioOption_Click ( ByVal expeditor Ca System.Object, ByVal e Manere mnuRadioOption1.Click, mnuRadioOption2.Click, mnuRadioOption3.Click Dim punctul Ca MenuItem = Ctype ( expeditor, MenuItem ) Dim printe Ca Meniu = item.Parent Dim tempMi Ca MenuItem pentru fiecare tempMi n parent.MenuItems tempMi.Checked = false nainte item.Checked = True End Sub Private Sub mnuMerge_Click ( ByVal expeditor Ca System.Object, ByVal e Dim element Ca MenuItem = Ctype ( expeditor, MenuItem ) item.Parent.MergeMenu ( mnuMenu2 ) End Sub End Class ca

ca

Sy

Syste

Original

Imports System.Windows.Forms public class RadioButtonCheckBox public Shared Sub Main Application.Run(New Form1) End Sub End class Public Class MDIChild Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox Friend WithEvents mainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents mnuMDIOptions As System.Windows.Forms.MenuItem Friend WithEvents mnuMDIOpiton1 As System.Windows.Forms.MenuItem Friend WithEvents mnuMDIOpiton2 As System.Windows.Forms.MenuItem Friend WithEvents mnuMDIOpiton3 As System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.RichTextBox1 = New System.Windows.Forms.RichTextBox() Me.mainMenu1 = New System.Windows.Forms.MainMenu() Me.mnuMDIOptions = New System.Windows.Forms.MenuItem() Me.mnuMDIOpiton1 = New System.Windows.Forms.MenuItem() Me.mnuMDIOpiton2 = New System.Windows.Forms.MenuItem() Me.mnuMDIOpiton3 = New System.Windows.Forms.MenuItem() Me.SuspendLayout() ' 'RichTextBox1 ' Me.RichTextBox1.Name = "RichTextBox1" Me.RichTextBox1.Size = New System.Drawing.Size(296, 176) Me.RichTextBox1.TabIndex = 0 Me.RichTextBox1.Text = "RichTextBox1" ' 'mainMenu1 ' Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMDIOp ' 'mnuMDIOptions ' Me.mnuMDIOptions.Index = 0 Me.mnuMDIOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuM Me.mnuMDIOptions.MergeOrder = 1 Me.mnuMDIOptions.Text = "MDIChildOptions"

' 'mnuMDIOpiton1 ' Me.mnuMDIOpiton1.Index = 0 Me.mnuMDIOpiton1.Text = "MDI Option 1" ' 'mnuMDIOpiton2 ' Me.mnuMDIOpiton2.Index = 1 Me.mnuMDIOpiton2.Text = "MDI Option 2" ' 'mnuMDIOpiton3 ' Me.mnuMDIOpiton3.Index = 2 Me.mnuMDIOpiton3.Text = "MDI Option 3" ' 'MDIChild ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 174) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.RichTextBox1}) Me.Menu = Me.mainMenu1 Me.Name = "MDIChild" Me.Text = "MDIChild" Me.ResumeLayout(False) End Sub

#End Region Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuMDIOpiton1.Click, mnuMDIOpiton2.Click, mnuMDIOpiton3.Click Dim item As MenuItem = CType(sender, MenuItem) item.Checked = Not item.Checked End Sub End Class Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing)

End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents mainMenu1 As System.Windows.Forms.MainMenu Friend WithEvents mnuFile As System.Windows.Forms.MenuItem Friend WithEvents mnuNew As System.Windows.Forms.MenuItem Friend WithEvents mnuFileOpen As System.Windows.Forms.MenuItem Friend WithEvents mnuFileClose As System.Windows.Forms.MenuItem Friend WithEvents mnuFileSave As System.Windows.Forms.MenuItem Friend WithEvents mnuFileSaveAs As System.Windows.Forms.MenuItem Friend WithEvents mnuEdit As System.Windows.Forms.MenuItem Friend WithEvents mnuEditCopy As System.Windows.Forms.MenuItem Friend WithEvents mnuEditPaste As System.Windows.Forms.MenuItem Friend WithEvents mnuOptions As System.Windows.Forms.MenuItem Friend WithEvents mnuOption1 As System.Windows.Forms.MenuItem Friend WithEvents mnuOption2 As System.Windows.Forms.MenuItem Friend WithEvents mnuOption3 As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOptions As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOption1 As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOption2 As System.Windows.Forms.MenuItem Friend WithEvents mnuRadioOption3 As System.Windows.Forms.MenuItem Friend WithEvents mnuWindow As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu1 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu11 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu12 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu13 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu14 As System.Windows.Forms.MenuItem Friend WithEvents mnuMerge As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu2 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu21 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu22 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu23 As System.Windows.Forms.MenuItem Friend WithEvents mnuMenu24 As System.Windows.Forms.MenuItem <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.mainMenu1 = New System.Windows.Forms.MainMenu() Me.mnuFile = New System.Windows.Forms.MenuItem() Me.mnuNew = New System.Windows.Forms.MenuItem() Me.mnuFileOpen = New System.Windows.Forms.MenuItem() Me.mnuFileClose = New System.Windows.Forms.MenuItem() Me.mnuFileSave = New System.Windows.Forms.MenuItem() Me.mnuFileSaveAs = New System.Windows.Forms.MenuItem() Me.mnuEdit = New System.Windows.Forms.MenuItem() Me.mnuEditCopy = New System.Windows.Forms.MenuItem() Me.mnuEditPaste = New System.Windows.Forms.MenuItem() Me.mnuOptions = New System.Windows.Forms.MenuItem() Me.mnuOption1 = New System.Windows.Forms.MenuItem() Me.mnuOption2 = New System.Windows.Forms.MenuItem() Me.mnuOption3 = New System.Windows.Forms.MenuItem() Me.mnuRadioOptions = New System.Windows.Forms.MenuItem() Me.mnuRadioOption1 = New System.Windows.Forms.MenuItem() Me.mnuRadioOption2 = New System.Windows.Forms.MenuItem() Me.mnuRadioOption3 = New System.Windows.Forms.MenuItem() Me.mnuWindow = New System.Windows.Forms.MenuItem() Me.mnuMenu1 = New System.Windows.Forms.MenuItem() Me.mnuMenu11 = New System.Windows.Forms.MenuItem() Me.mnuMenu12 = New System.Windows.Forms.MenuItem()

Me.mnuMenu13 = New System.Windows.Forms.MenuItem() Me.mnuMenu14 = New System.Windows.Forms.MenuItem() Me.mnuMerge = New System.Windows.Forms.MenuItem() Me.mnuMenu2 = New System.Windows.Forms.MenuItem() Me.mnuMenu21 = New System.Windows.Forms.MenuItem() Me.mnuMenu22 = New System.Windows.Forms.MenuItem() Me.mnuMenu23 = New System.Windows.Forms.MenuItem() Me.mnuMenu24 = New System.Windows.Forms.MenuItem() ' 'mainMenu1 ' Me.mainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, ' 'mnuFile ' Me.mnuFile.Index = 0 Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNew, Me Me.mnuFile.Text = "File" ' 'mnuNew ' Me.mnuNew.Index = 0 Me.mnuNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN Me.mnuNew.Text = "&New" ' 'mnuFileOpen ' Me.mnuFileOpen.Index = 1 Me.mnuFileOpen.Text = "Open" ' 'mnuFileClose ' Me.mnuFileClose.Index = 2 Me.mnuFileClose.Text = "Close" ' 'mnuFileSave ' Me.mnuFileSave.Index = 3 Me.mnuFileSave.Text = "Save" ' 'mnuFileSaveAs ' Me.mnuFileSaveAs.Index = 4 Me.mnuFileSaveAs.Text = "Save&As" ' 'mnuEdit ' Me.mnuEdit.Index = 1 Me.mnuEdit.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuEditCop Me.mnuEdit.Text = "Edit" ' 'mnuEditCopy ' Me.mnuEditCopy.Index = 0 Me.mnuEditCopy.Text = "&Copy" ' 'mnuEditPaste ' Me.mnuEditPaste.Index = 1 Me.mnuEditPaste.Text = "Paste" '

'mnuOptions ' Me.mnuOptions.Index = 2 Me.mnuOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuOpti Me.mnuOptions.Text = "Options" ' 'mnuOption1 ' Me.mnuOption1.Index = 0 Me.mnuOption1.Text = "Option1" ' 'mnuOption2 ' Me.mnuOption2.Index = 1 Me.mnuOption2.Text = "Option2" ' 'mnuOption3 ' Me.mnuOption3.Index = 2 Me.mnuOption3.Text = "Option3" ' 'mnuRadioOptions ' Me.mnuRadioOptions.Index = 3 Me.mnuRadioOptions.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mn Me.mnuRadioOptions.Text = "Radio Options" ' 'mnuROption1 ' Me.mnuRadioOption1.Index = 0 Me.mnuRadioOption1.RadioCheck = True Me.mnuRadioOption1.Text = "Radio Option 1" ' 'mnuROption2 ' Me.mnuRadioOption2.Index = 1 Me.mnuRadioOption2.RadioCheck = True Me.mnuRadioOption2.Text = "Radio Option 2" ' 'mnuROption3 ' Me.mnuRadioOption3.Index = 2 Me.mnuRadioOption3.RadioCheck = True Me.mnuRadioOption3.Text = "Radio Option 3" ' 'mnuWindow ' Me.mnuWindow.Index = 4 Me.mnuWindow.MdiList = True Me.mnuWindow.MergeOrder = 99 Me.mnuWindow.Text = "&Window" ' 'mnuMenu1 ' Me.mnuMenu1.Index = 5 Me.mnuMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMenu11 Me.mnuMenu1.Text = "Menu 1" ' 'mnuMenu11 ' Me.mnuMenu11.Index = 0

Me.mnuMenu11.MergeOrder = 1 Me.mnuMenu11.Text = "Menu 1.1" ' 'mnuMenu12 ' Me.mnuMenu12.Index = 1 Me.mnuMenu12.MergeOrder = 2 Me.mnuMenu12.Text = "Menu 1.2" ' 'mnuMenu13 ' Me.mnuMenu13.Index = 2 Me.mnuMenu13.MergeOrder = 3 Me.mnuMenu13.Text = "Menu 1.3" ' 'mnuMenu14 ' Me.mnuMenu14.Index = 3 Me.mnuMenu14.MergeOrder = 4 Me.mnuMenu14.Text = "Menu 1.4" ' 'mnuMerge ' Me.mnuMerge.Index = 4 Me.mnuMerge.MergeOrder = 99 Me.mnuMerge.Text = "Merge!" ' 'mnuMenu2 ' Me.mnuMenu2.Index = 6 Me.mnuMenu2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuMenu21 Me.mnuMenu2.Text = "Menu 2" ' 'mnuMenu21 ' Me.mnuMenu21.Index = 0 Me.mnuMenu21.MergeOrder = 1 Me.mnuMenu21.Text = "Menu 2.1" ' 'mnuMenu22 ' Me.mnuMenu22.Index = 1 Me.mnuMenu22.MergeOrder = 2 Me.mnuMenu22.MergeType = System.Windows.Forms.MenuMerge.Replace Me.mnuMenu22.Text = "Menu 2.2" ' 'mnuMenu23 ' Me.mnuMenu23.Index = 2 Me.mnuMenu23.MergeOrder = 3 Me.mnuMenu23.MergeType = System.Windows.Forms.MenuMerge.Remove Me.mnuMenu23.Text = "Menu 2.3" ' 'mnuMenu24 ' Me.mnuMenu24.Index = 3 Me.mnuMenu24.MergeOrder = 5 Me.mnuMenu24.Text = "Menu 2.4" ' 'Form1 '

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(456, 146) Me.IsMdiContainer = True Me.Menu = Me.mainMenu1 Me.Name = "Form1" Me.Text = "Form1" End Sub #End Region

Private Sub mnuNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNew.Click Dim newMDIChild As New MDIChild() newMDIChild.MdiParent = Me newMDIChild.Show() End Sub

Private Sub mnuFileOpen_Click(ByVal sender As System.Object, ByVal e As System.Event Handles mnuFileOpen.Click MessageBox.Show("You clicked file open!", _ "Menu event tester", _ MessageBoxButtons.OK, _ MessageBoxIcon.Information) End Sub

Private Sub mnuFileClose_Click(ByVal sender As System.Object, ByVal e As System.Even Handles mnuFileClose.Click MessageBox.Show("You clicked file close!", "Menu event tester", MessageBoxButton End Sub

Private Sub mnuEditCopy_Click(ByVal sender As System.Object, ByVal e As System.Event Handles mnuEditCopy.Click MessageBox.Show("You clicked Edit copy!", "Menu event tester", MessageBoxButtons End Sub

Private Sub mnuEditPaste_Click(ByVal sender As System.Object, ByVal e As System.Even Handles mnuEditPaste.Click MessageBox.Show("You clicked Edit paste!", "Menu event tester", MessageBoxButton End Sub

Private Sub Option_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOption1.Click, mnuOption2.Click, mnuOption3.Click Dim item As MenuItem = CType(sender, MenuItem) item.Checked = Not item.Checked End Sub Private Handles Dim Dim Dim For

Sub RadioOption_Click(ByVal sender As System.Object, ByVal e As System.Event mnuRadioOption1.Click, mnuRadioOption2.Click, mnuRadioOption3.Click item As MenuItem = CType(sender, MenuItem) parent As Menu = item.Parent tempMi As MenuItem Each tempMi In parent.MenuItems tempMi.Checked = False

Next item.Checked = True End Sub

Private Sub mnuMerge_Click(ByVal sender As System.Object, ByVal e As System.EventArg Dim item As MenuItem = CType(sender, MenuItem)

item.Parent.MergeMenu(mnuMenu2) End Sub End Class

Form ablon pentru utilizarea cu motenire vizual

Importurile

System.Windows.Forms

public class FormInheritance public comun Sub principal Application.Run ( New FrmInheritance ) End Sub End clasa Public class FrmInheritance Motenete Form # Region "cod pentru Windows Form Designer generat"

Public Sub New () MyBase.New () "Th este apelul este cerut de formularul de Designer Windows. InitializeComponent () "Anuntul d orice iniializare dup InitializeComponent () End Sub "Fo suprascrie rm dispune pentru a cura lista de componente. protejate Suprancrcarea nlocuiete Sub Distrugerea ( ByVal eliminare Dac dispunerea Apoi Daca nu ( componente este nimic ) Apoi components.Dispose () Ca apel

Boole

End Dac End Dac MyBase.Dispose ( eliminare ) End Sub prieten WithEvents lblText Ca System.Windows.Forms.Label prieten WithEvents lblCopyright Ca System.Windows.Forms.Label prieten WithEvents cmdLearn Ca System.Windows.Forms.Button "Re stea, conform Form Designer pentru Windows private componente Ca System.ComponentModel.Container

"NU TE: Urmtoarea procedur este cerut de formularul de designer pentru Windows "Acesta poate fi modificat cu ajutorul . Form Designer pentru Windows "Nu -l modificai folosind editorul de cod. <System.Diagnostics.DebuggerStepThrough () > Private Sub InitializeComponent () Me . lblCopyright = New System.Windows.Forms.Label () Me.cmdLearn = New System.Windows.Forms.Button () Me.lblText = New System.Windows.Forms.Label () Me.SuspendLayout () " "lb lCopyright " Me.lblCopyright.BackColor = System.Drawing.Color.LightYellow Me.lblCopyright.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblCopyright.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 11.25 ! Me.lblCopyright.ForeColor = System.Drawing.Color.MidnightBlue Me.lblCopyright.Location = New System.Drawing.Point ( 20 , 178 ) Me.lblCopyright.Name = "lblCopyright" Me.lblCopyright.Size = New System.Drawing.Size ( 318 , 29 ) Me.lblCopyright.TabIndex = 1 Me.lblCopyright.Text = "Copyright 2002" " "cm dLearn ' Me.cmdLearn.BackColor = System.Drawing.Color.Snow Me.cmdLearn.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 14.25 !, Sy Me.cmdLearn.ForeColor = System.Drawing.SystemColors.InfoText Me.cmdLearn.Location = New System.Drawing.Point ( 20 , 99 ) Me.cmdLearn.Name = "cmdLearn" Me . cmdLearn.Size = New System.Drawing.Size ( 144 , 59 ) Me.cmdLearn.TabIndex = 2 Me.cmdLearn.Text = "Aflai mai multe", " 'lb LTEXT " Me.lblText.BackColor = System.Drawing.Color. LightYellow Me.lblText.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblText.Font = New System.Drawing.Font ( "Microsoft Sans Serif" , 20.25 !, Sys Me.lblText.ForeColor = System.Drawing.Color.MidnightBlue Me.lblText.Location = New System.Drawing.Point ( 20 , 20 ) Me.lblText.Name = "lblText" Me.lblText.Size = New System.Drawing.Size ( 318 , 59 ) Me.lblText.TabIndex = 0 Me.lblText.Text = "text" Me.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Fr mInheritance " Me.AutoScaleBaseSize = New System.Drawing.Size ( 6 , 15 ) Me.BackColor = System.Drawing.SystemColors.ActiveBorder Me.ClientSize = New System.Drawing.Size ( 358 , 223 )

Me.Controls.AddRange ( nou sistem de . Windows.Forms.Control () { Me.cmdLearn, Me. Me.Name = "FrmInheritance" Me.Text = "Visual motenire" Me.ResumeLayout ( Fals ) End Sub # End Regiunea

"Am nvoked atunci cnd utilizatorul apas Aflai mai multe butonul Private Sub cmdLearn_Click ( ByVal expeditor Ca System.Object, _ ByVal e ca System.EventArgs ) Manere cmdLearn.Click MessageBox.Show ( "Message" , "Titlu" , MessageBoxButtons.OK, _ MessageBoxIcon.Information ) End Sub 'c mdLearn_Click End Class

Original

Imports System.Windows.Forms public class FormInheritance public Shared Sub Main Application.Run(New FrmInheritance) End Sub End class Public Class FrmInheritance Inherits Form #Region " Windows Form Designer generated code "

Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Friend WithEvents lblText As System.Windows.Forms.Label Friend WithEvents lblCopyright As System.Windows.Forms.Label Friend WithEvents cmdLearn As System.Windows.Forms.Button 'Required by the Windows Form Designer Private components As System.ComponentModel.Container

'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.lblCopyright = New System.Windows.Forms.Label() Me.cmdLearn = New System.Windows.Forms.Button() Me.lblText = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'lblCopyright ' Me.lblCopyright.BackColor = System.Drawing.Color.LightYellow Me.lblCopyright.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblCopyright.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, Sys Me.lblCopyright.ForeColor = System.Drawing.Color.MidnightBlue Me.lblCopyright.Location = New System.Drawing.Point(20, 178) Me.lblCopyright.Name = "lblCopyright" Me.lblCopyright.Size = New System.Drawing.Size(318, 29) Me.lblCopyright.TabIndex = 1 Me.lblCopyright.Text = "Copyright 2002" ' 'cmdLearn ' Me.cmdLearn.BackColor = System.Drawing.Color.Snow Me.cmdLearn.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System. Me.cmdLearn.ForeColor = System.Drawing.SystemColors.InfoText Me.cmdLearn.Location = New System.Drawing.Point(20, 99) Me.cmdLearn.Name = "cmdLearn" Me.cmdLearn.Size = New System.Drawing.Size(144, 59) Me.cmdLearn.TabIndex = 2 Me.cmdLearn.Text = "Learn More" ' 'lblText ' Me.lblText.BackColor = System.Drawing.Color.LightYellow

Me.lblText.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D Me.lblText.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.25!, System.D Me.lblText.ForeColor = System.Drawing.Color.MidnightBlue Me.lblText.Location = New System.Drawing.Point(20, 20) Me.lblText.Name = "lblText" Me.lblText.Size = New System.Drawing.Size(318, 59) Me.lblText.TabIndex = 0 Me.lblText.Text = "Text" Me.lblText.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'FrmInheritance ' Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) Me.BackColor = System.Drawing.SystemColors.ActiveBorder Me.ClientSize = New System.Drawing.Size(358, 223) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdLearn, Me.lblCopyri Me.Name = "FrmInheritance" Me.Text = "Visual Inheritance" Me.ResumeLayout(False) End Sub #End Region ' invoked when user presses Learn More button Private Sub cmdLearn_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles cmdLearn.Click MessageBox.Show("Message", "Title", MessageBoxButtons.OK, _ MessageBoxIcon.Information) End Sub ' cmdLearn_Click End Class

Creating o KeyBinding ntre comanda Deschidere i Ctrl-R


<Fereastra

Imports Imports Imports Imports Imports

System System.Windows System.Windows.Controls System.Windows.Input System.Windows.Media

Spaiul WpfApplication1 public parial Clasa window1 Motenete fereastra Public Sub New () InitializeComponent ()

Dim MainStackPanel Ca StackPanel Nou () Me.AddChild ( MainStackPanel ) Dim CommandButton Ca nou buton () CommandButton.Command = ApplicationCommands.Open CommandButton.Content = "Deschide (keybindings: Ctrl-R, Ctrl-0)" MainStackPanel.Children.Add ( CommandButton ) Dim OpenCmdBinding Ca New CommandBinding ( ApplicationCommands.Open, AddressOf

Me.CommandBindings.Add ( OpenCmdBinding ) Dim OpenCmdKeyBinding Ca

New KeyBinding ( ApplicationCommands.Open, Key.R, Modi

Me.InputBindings.Add ( OpenCmdKeyBinding ) End Sub Sub Private OpenCmdExecuted ( int Ca obiect, e MessageBox.Show ( "Comanda a fost invocat." ) End Sub Sub privat OpenCmdCanExecute ( expeditor e.CanExecute = True End Sub End Class End Namespace Ca ca ExecutedRoutedEventArgs )

obiect, e

ca

CanExecuteRoutedEventA

Original

<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="CommandHandlerProcedural" > </Window> //File:Window.xaml.vb Imports Imports Imports Imports System System.Windows System.Windows.Controls System.Windows.Input

Imports System.Windows.Media Namespace WpfApplication1 Public Partial Class Window1 Inherits Window Public Sub New() InitializeComponent() Dim MainStackPanel As New StackPanel() Me.AddChild(MainStackPanel) Dim CommandButton As New Button() CommandButton.Command = ApplicationCommands.Open CommandButton.Content = "Open (KeyBindings: Ctrl-R, Ctrl-0)" MainStackPanel.Children.Add(CommandButton)

Dim OpenCmdBinding As New CommandBinding(ApplicationCommands.Open, AddressOf OpenC Me.CommandBindings.Add(OpenCmdBinding)

Dim OpenCmdKeyBinding As New KeyBinding(ApplicationCommands.Open, Key.R, ModifierK Me.InputBindings.Add(OpenCmdKeyBinding) End Sub Private Sub OpenCmdExecuted(target As Object, e As ExecutedRoutedEventArgs) MessageBox.Show("The command has been invoked.") End Sub Private Sub OpenCmdCanExecute(sender As Object, e As CanExecuteRoutedEventArgs) e.CanExecute = True End Sub End Class End Namespace

S-ar putea să vă placă și