当前位置:网站首页>C application interface development foundation - form control (3) - file control
C application interface development foundation - form control (3) - file control
2022-07-03 01:27:00 【DXB2021】
File control
One 、 Label control
1、Label Control settings
There are two ways : The first is directly in Label Control in the property panel Text attribute ; The second is to set up through code Text attribute .
label1.Text=" user name :";
2、Label Control
(1)Size attribute : The size of the control ( In pixels ).
(2)Location attribute : The position of the label in the form .
(3)Visible attribute : Visibility of labels , by True Visible when , by False It's not visible .
(4)BackColor attribute : Used to get or set the background color of the control . When the attribute value Set to Color
(5)ClientSize attribute : Get or set the size of the workspace .
(6)Location attribute : The position of the label in the form .
Programming , Realization “ You run after me ”.
The code is as follows :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
MessageBox.Show("(T.T) You caught me !!!");
}
private void label1_MouseEnter(object sender, EventArgs e)
{
int x = this.ClientSize.Width - label1.Width;
int y = this.ClientSize.Height - label1.Height;
Random r = new Random();
label1.Location = new Point(r.Next(0, x + 1), r.Next(0, y + 1));
}
}
}
The operation results are as follows :
Two 、 Button control
Button controls are the most commonly used controls , This control is mainly used to write the Click Events and MouseEnter Event code .
1、 Respond to the click event of the button
After the double-click , Put it in the right place .
stay Text Attribute input click the button
button Adjust the size , Placement position , Text changes .
trigger Click event
Double click later
Enter the code :
The code is as follows :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Click(object sender, EventArgs e)
{
MessageBox.Show(" You triggered Click event ");
}
}
}
Running results :
After clicking :
No response .
The code is as follows :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(" You triggered Click event ");
}
}
}
2、 Button settings
The code is as follows :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.AcceptButton = button1;
this.CancelButton = button2;
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(" ha-ha ! I'm kidding you ", " You believe it ");
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
}
}
3、 ... and 、 Text box control
C# Text controls are often used to receive user input or display in forms Text , With this control, users can enter text 、 Password and other information , It can also control Length of user input 、 Type, etc .
1、TextBox Control
(1)Backclock attribute : Set background color .
(2)BorderStyle attribute : Set up TextBox The type of border is enumeration value , There are three values :None( No borders )、FixedSingle( One side border )、Fixed3D( Three dimensional frame ).
(3)Font attribute : Set up TextBox The font of , Include font name 、 size 、 Is it bold 、 Is it italicized 、 Whether there is a lower line, etc .
(4)Forecolor attribute : The foreground , That is, the color of the font .
(5)MaxLength attribute : Control the number of characters that can be entered in the text box .
(6)Multiline attribute : Set up TextBox Control allows multiple lines of input .
(7)PasswordChar attribute : If you want to let TextBox Enter the password without displaying the original characters , You can specify a character to replace the original character .
(8)ReadOnly attribute : Control can be changed TextBox The text in the , The default is False, That is, you can modify , If True, Then the user cannot modify the text inside .
(9)Text attribute : For reading or setting TextBox The text in the .
(10)TextAlign attribute : Alignment of text , There are three values :Left、Center or Right, The default is Left.
(11)Visible attribute : Used to set whether the control is hidden or displayed , If set to False, The control is invisible when the program runs .
(12)WordWrap attribute : When Multiline Property is set to True when , This attribute works , Used to indicate whether the control wraps lines .
2、TextBox Control
(1)AppendText(): The method TextBox Control to append text .
(2)Clear(): Clear the contents of the text box .
(3)Copy(): Copy the contents of the text box to the clipboard .
(4)Focus(): Make the text box focus .
(5)Paste(): Replace the specified content in the text box with the content in the clipboard .
(6)Resettext(): Reset the contents of the text box to the default value .
(7)Select(): Select the text specified in the text box .
(8)Selectall(): Select all the text in the text box .
(9)Undo(): Undo the last modification of the text box .
3、TextBox Use of control
11 individual Label Control 、5 individual TextBox Control 、2 individual Button Control
Four 、 Formatted text control
1、 Show scroll bar
There are two kinds of scrollbars : level (Horizontal) Scroll bar and vertical (Vertical) Scroll bar , adopt RichTextBox Of ScrollBars Property to set how the scroll bar is displayed .
attribute | explain |
Both | Only if the text exceeds RichTextBox The width or length of , The horizontal scroll bar or vertical scroll bar is displayed , Or both scrollbars |
None | Do not display any type of scroll bar |
Horizontal | Only if the text exceeds RichTextBox The width of , The horizontal scroll bar is displayed |
Vertical | Only if the text exceeds RichTextBox Altitude time , The vertical scroll bar is displayed |
ForceHorizontal | When WordWrap Property is set to false when , Show horizontal scroll bar . In the text no more than RichTextBox The width of , The scroll bar is light gray |
ForcedVertical | Always show vertical scroll bar . In the text no more than RichTextBox When the length of the , The scroll bar is light gray |
ForcedBoth | Always show vertical scroll bar . In the text no more than RichTextBox Property is set to false when , Show horizontal scroll bar . In the text no more than RichTextBox The width or length of , Both scrollbars are gray . |
2、 Set font properties
There are two ways :
(1) Select Font Property settings RichTextBox Control font size and typeface ;
(2) adopt RichTextBox Of SelectionFont Properties and SelectionColor Property to set the font size and color .
3、 take RichTextBox Control is displayed as a hyperlink style
4、 Format paragraph
边栏推荐
- JS inheritance and prototype chain
- 2022 coal mine gas drainage examination question bank and coal mine gas drainage examination questions and analysis
- [fh-gfsk] fh-gfsk signal analysis and blind demodulation research
- Mongodb common commands of mongodb series
- Test shift right: Elk practice of online quality monitoring
- Database SQL language 01 where condition
- leetcode 6103 — 从树中删除边的最小分数
- 关于Fibonacci数列
- 对非ts/js文件模块进行类型扩充
- Druid database connection pool
猜你喜欢
[untitled]
Top ten regular spot trading platforms 2022
Database SQL language 01 where condition
【我的OpenGL学习进阶之旅】关于欧拉角、旋转顺序、旋转矩阵、四元数等知识的整理
Correctly distinguish the similarities and differences among API, rest API, restful API and web service
Database SQL language 02 connection query
一比特苦逼程序員的找工作經曆
MySQL basics 03 introduction to MySQL types
一位苦逼程序员的找工作经历
Daily topic: movement of haystack
随机推荐
JDBC courses
The meaning of wildcard, patsubst and notdir in makefile
MySQL foundation 04 MySQL architecture
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
Machine learning terminology
按键精灵打怪学习-自动寻路回打怪点
Arduino DY-SV17F自动语音播报
Daily topic: movement of haystack
看疫情之下服装企业如何顺势而为
Kivy tutorial how to create drop-down lists in Kivy
dotConnect for PostgreSQL数据提供程序
看完这篇 教你玩转渗透测试靶机Vulnhub——DriftingBlues-9
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core
SwiftUI 组件大全之使用 SceneKit 和 SwiftUI 构建交互式 3D 饼图(教程含源码)
R language ggplot2 visual faceting, visual facet_wrap bar plot, using strip Text function customize the size of the strip of each facet title in the facet graph (cutimi
Thinkphp+redis realizes simple lottery
Cut point of undirected graph
[principles of multithreading and high concurrency: 2. Solutions to cache consistency]
Canvas drawing -- bingdd
Androd Gradle 对其使用模块依赖的替换