Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to develop WinForm with C #

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to develop WinForm with C #". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to develop WinForm with C #".

First, you have to initialize the component (see initializing Label in the program below). And use the "Controls.Add" method to add to the form, the following is the interface and source code for the program to run.

C # develop WinForm source code:

Using System; using System.Windows.Forms; using System.Drawing; public class Form3: Form {/ / define a tag private Label label1; public static void Main () {Application.Run (new Form3 ());} / construct public Form3 () {/ / create the tag and initialize this.label1 = new System.Windows.Forms.Label () / / inherit a Label class label1.Location = new System.Drawing.Point (24,16); / / set the display position of Label label1.Text = "this is a tag in WinForm"; label1.Size = new System.Drawing.Size (200,50); / / set the size of the label label1.TabIndex = 0; label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter / / set the alignment of labels this.Text = "add a tag to WinForm!" ; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.AutoScaleBaseSize = new System.Drawing.Size (8,16); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; / / sets the boundary type of the form this.ForeColor = System.Drawing.SystemColors.Desktop; this.Font = new System.Drawing.Font ("Arial", 10, System.Drawing.FontStyle.Bold) / / set font, size on font style this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.BackColor = System.Drawing.Color.Blue; / / set background color this.ClientSize = new System.Drawing.Size (250,250); / / add a label to the form this.Controls.Add (this.label1) }} Thank you for your reading, the above is the content of "how to develop WinForm with C #". After the study of this article, I believe you have a deeper understanding of how to develop WinForm with C #, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report