当前位置:网站首页>C form application of C (27)
C form application of C (27)
2022-07-06 03:47:00 【camellias_】
Start today C# forms .
( One ): First create a form application
file -> newly build -> project
( Two ): Buttons and labels in forms (button/label)
Click toolbox , Fix it on the screen .
When setting button and label properties , Remember to modify it NAME attribute And Text attribute
/**
* Method of event
*/
private void MyButton_Click(object sender, EventArgs e)
{
// Dialogue window display
MessageBox.Show("HELLO My first form ");
}
/**
* How to label
*/
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
// The attribute of this object is equal to
answer_label.Text = " answer : The eight trigrams of yin and Yang , Opposites attract ";
}
( 3、 ... and ): Hyperlink label (linklabel)
1:Linkcolor: The default color of hyperlinks .:
2:Activelinkcolor: The color of the hyperlink when it is clicked
3:Visitedlinkcolor: The color of hyperlinks that have been visited .
4:Linkbehavior: Hyperlink underline style
5: event :
/**
* Hyperlink event
*/
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
// Set the link color after clicking
oneLink.LinkVisited = true;
// open C disc (@ Is output as is )
System.Diagnostics.Process.Start(@"C:/");
}
private void linkLabel1_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
{
// Set the link color after clicking
linkTwo.LinkVisited = true;
// Open the web page
System.Diagnostics.Process.Start("chrome","https://guanchao.site");
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void linkLabel1_LinkClicked_2(object sender, LinkLabelLinkClickedEventArgs e)
{
// Set the link color after clicking
linkTwo.LinkVisited = true;
// Open application
System.Diagnostics.Process.Start("Notepad");
}
( Four ): The text box (textbox)
1: attribute
multiline: Controls whether text can span lines .
AcceptsReturn: Whether the multiline edit control allows the input of carriage return .
AcceptsTab: Whether the multiline edit control allows input Tab key .
ReadOnly: read-only
ScrollBars: For multiline controls , Show scroll bar or not .
TabIndex: Confirm that the secondary control applies Tab Indexes
PasswordChar: Display password characters
AcceptsButton: Pressing enter is equal to pressing OK ( Form event )
2: event
Textchange event : amount to javascript Medium Change event .
3: Method
Clear: Clear everything in the text box
Copy: Copy the selection
Cut: Cut the selected content
Paste: Replace the selected text with the cut text
ResetText: take text Property is reset to the default value
Redo: Repeat the previous operation
Redo: Undo last action
private void but_Click(object sender, EventArgs e)
{
string ques_str = quesBox.Text;
string pass_str = passBox.Text;
if (ques_str == "gc" && pass_str == "123456")
{
MessageBox.Show(" Successful operation ");
}
else {
MessageBox.Show(" Wrong password ");
}
}
( Four ): Radio button (RadioButton)
1: attribute :
Checked: Whether the radio button has been selected .
C# Radio button in NAME Attributes do not need to be the same
// Define a variable to store gender
public string sex;
// Choose male , Assign a value to the tag
private void boy_radio_CheckedChanged(object sender, EventArgs e)
{
sex = " male ";
}
// Choose women , Assign a value to the tag
private void gr_radio_CheckedChanged(object sender, EventArgs e)
{
sex = " Woman ";
}
// Click the confirm button to leave the event
private void button1_Click_1(object sender, EventArgs e)
{
if (boy_radio.Checked == false && gr_radio.Checked == false)
{
MessageBox.Show(" Please choose gender ");
}
else {
MessageBox.Show(" Your difference is :"+sex);
}
}
( 5、 ... and ): Check box (CheckBox)
1: attribute :
Checked: Whether the check button is selected .
CheckState: Component state ( Three states );
Check boxes are similar to radio boxes , There is no example here , Refer to the radio box .
( 6、 ... and ): Digital input box (NumericUpDown)
1: attribute
Increment: Click the plus sign behind once to increase the number
MiniMum: Input box minimum
MaxMum: Input box maximum
Value: The default value is
2: event
ValueChanged: Default event ( Value change )
public int num;
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
num = Convert.ToInt32(numUpOne.Text);
Font ff = new Font(" In black ", num);
label4.Font = ff;
}
private void num_button_Click(object sender, EventArgs e)
{
int nums = num + 1;
MessageBox.Show(" The number you entered is " + nums);
}
( 7、 ... and ): Group box (GroupBox)
This is nothing , It is a partition function .
Put the functional partitions of each part .
[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-iEh41uFh-1655864539618)(https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/8286432aab1e40a78f5d5d874df51090~tplv-k3u1fbpfcp-zoom-1.image#pic_center)]
There are good suggestions , Please enter your comments below
Welcome to personal blog
https://guanchao.site
Welcome to the applet :
边栏推荐
- C#(三十)之C#comboBox ListView treeView
- C#(二十八)之C#鼠标事件、键盘事件
- 记录一下逆向任务管理器的过程
- JS Vanke banner rotation chart JS special effect
- 数据分析——seaborn可视化(笔记自用)
- SAP ALV cell level set color
- 3分钟带你了解微信小程序开发
- An article will give you a comprehensive understanding of the internal and external components of "computer"
- Differential GPS RTK thousand search
- Indicator system of KQI and KPI
猜你喜欢
LTE CSFB test analysis
Esbuild & SWC: a new generation of construction tools
登录mysql输入密码时报错,ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES
Cubemx transplantation punctual atom LCD display routine
Canvas cut blocks game code
Align items and align content in flex layout
MADDPG的pythorch实现——(1)OpenAI MADDPG环境配置
BUAA magpie nesting
遥感图像超分辨重建综述
Schnuka: visual positioning system working principle of visual positioning system
随机推荐
[practice] mathematics in lottery
C#(二十八)之C#鼠标事件、键盘事件
2、GPIO相关操作
[practical exercise] face location model based on skin color
1. New project
Image super-resolution using deep convolutional networks(SRCNN)解读与实现
Ybtoj coloring plan [tree chain dissection, segment tree, tarjan]
Failure causes and optimization methods of LTE CSFB
2.2 STM32 GPIO operation
C#(三十)之C#comboBox ListView treeView
MySQL 中的数据类型介绍
RT thread -- FTP of LwIP (2)
自动化测试怎么规范部署?
Prime Protocol宣布在Moonbeam上的跨链互连应用程序
Mathematical modeling regression analysis relationship between variables
Pytorch load data
如何修改表中的字段约束条件(类型,default, null等)
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
Python implementation of maddpg - (1) openai maddpg environment configuration
Introduction to DeNO