An warware: canza lakabin lambar forecolor

Tabbas, da fatan za a duba labarin da ke ƙasa:

A cikin yanayin ci gaban mu'amalar mai amfani, ikon canza canjin launi na tambarin yana ba da damar haɓaka ƙwarewar mai amfani kuma yana iya taimakawa tare da salon salo na aikace-aikacen. A cikin C #, ana iya cika wannan aikin da sauƙi da daidaito. A cikin wannan labarin, mun zurfafa cikin binciken yadda zaku iya sarrafa launi na alamar tambarin, samar da bayanin matakin mataki-mataki, da taɓa ɗakunan karatu da ayyuka masu mahimmanci ga wannan tsari.

amfani da Tsarin;
ta amfani da System.Windows.Forms;

Ajin jama'a Form1: Form
{
Lakabin lakabin1 = sabon Label ();

Jama'a Form1()
{
label1.Text = "Sannu, Duniya!";
label1.ForeColor = Tsarin.Zana.Launi.Ja;
Gudanarwa.Ƙara (lakabi1);
}

a tsaye babu Main()
{
Application.Run(sabon Form1());
}
}

Rarraba Magani

Maganinmu ya fara da Tsarin. Windows.Forms namespace, wanda ya haɗa da saitin nau'ikan don ƙirƙirar mu'amalar mai amfani da hoto da sarrafa halayensu. Daga cikin wadannan nau'ikan akwai Lakabin aji, wanda ke wakiltar daidaitaccen lakabin Windows.

Ajin mu na Form1 yana ɗaukar misali guda ɗaya na Label, lakabin1. A cikin maginin Form1, mun saita kayan Rubutun lakabin1 zuwa "Sannu, Duniya!" da kayan sa na ForeColor zuwa Ja. Kayan ForeColor ya shafi launi na gaba na sarrafawa, wanda don Lakabi, yana tasiri launin rubutun.

Sannan ana ƙara wannan alamar alamar a cikin Samfurin Gudanarwa - tarin duk abubuwan sarrafawa da ke cikin sigar.

A ƙarshe, a cikin Babban Hanyar, muna ƙaddamar da Form1 ɗin mu kuma muna gudanar da aikace-aikacen.

The System.Windows.Forms Namespace da Label Class

Ganin irin rawar da yake takawa wajen haɓaka aikace-aikacen tushen Windows, fahimtar abubuwan Tsarin. Windows.Forms sarari suna yana da mahimmanci ga kowane mai shirye-shiryen C #. Yana ba da iko iri-iri kamar maɓalli, akwatunan rubutu, da lakabi da sauransu.

The Lakabin aji, wani yanki na wannan filin suna, babban kayan aiki ne don nuna rubutu akan aikace-aikace. Tare da kaddarori daban-daban kamar ForeColor, BackColor, Font, Rubutu, da ƙari, wannan ajin yana ba da cikakkiyar saiti na zaɓuɓɓuka don sarrafa kamanni da halayen alamun.

A cikin yanayinmu, mun yi amfani da ikon ForeColor musamman don canza launi na Label ɗin mu.

Tarin Sarrafa da aiwatar da aikace-aikacen

Dangane da mahallin mai amfani, ControlCollection yana taka muhimmiyar rawa wajen sarrafa sarrafawa iri-iri, kamar Label ɗin mu, a cikin tsari. Ta ƙara Label ɗin mu, label1, zuwa ga Gudanarwar fom ɗinmu, muna sanya shi yadda yakamata a cikin aikace-aikacen mu don nunawa.

Hanyar Aikace-aikacen.Run a cikin Babban aikinmu shine injin da ke sarrafa nau'in mu, ɗaukar misalin mu na Form1 kuma yana gudanar da shi azaman aikace-aikace. Wannan Aikace-aikace.Run shine mataki na ƙarshe don kawo Form ɗin mu, da lakabinsa masu launi, zuwa rayuwa.

Muna fatan cewa wannan labarin ya ba ku ƙarin fahimtar yadda ake canza launi mai launi a cikin C # da kuma muhimmiyar rawar da System.Windows.Forms namespace, da Label class, taka a cikin irin wannan aiki. Murnar coding!

Shafi posts:

Leave a Comment