c#窗体开发

奇:
常用控件的使用(期间参杂着VS快捷键/常用设置)
公共控件:

WinForm          窗体
  Button           按钮
  ComboBox         下拉列表框
  Checkbox         复选框
  CheckedListBox
  ComboBox
  DateTimePicker   日期时间控件
  GroupBox         分组控件
  Label            标签
  LinkLabel
  ListBox          列表框
  ListView         列表控件
  LinkLabel        超链接标签
  MaskedTextBox
  MonthCalendar
  NotifyIcon       托盘控件
  NumericUpDown    数字输入框
  PictureBox       图片框
  ProgressBar      进度条
  RadioButton      单选框
RichTextBox TreeView 树控件 Textbox 文本框 ToolTip 气泡提示 webBrowser

容器:

Panel                   面板
SplitContainer          分隔容器
TabControl              选项卡控件
FlowLayoutPanel
GroupBox
tableLayoutPanel

菜单和工具栏:

ContextMenuStrip         右键菜单
MenuStrip                菜单控件
StatusStrip              状态栏控件
ToolStrip                工具栏控件
ImageList                图片集合   ????(4.7版本未找到)
Timer                    时间控件

对话框:

FolderBrowserDialog         文件夹选择
OpenFileDialog              打开文件
SaveFileDialog              保存文件

数据

Chart
BindingNavigator
BindingSource
DataGridView
DataSet

组件

BackgroundWorker
DirectoryEntry
DirectorySearcher
ErrorProvider
Eventlog
FilesystemWatcher
CHelpProvider
ImageList
MessageQueue
PerformanceCounter
Process
SerialPort
ServiceController
Timer

属性面板

布局
--AuteScaleMode 
--Autoscroll
--AltoScrollMargin
--AutoScrollMinsize
--AutoSize
--AutoSizeMode
--Location
--MaximumSize
--MinimumSize
--Padding
--Size
--StartPosition 
--Windowstate

窗口样式
--ControlBox
--HelpButton
--lcon
    -size
--IsMdiContainer
--MainMenuStrip
--MaximizeBox
--MinimizeBox
--Opacity
--Showlcon
--ShowlnTaskbar
--SizeGripStyle
--TopMost
--TransparencyKey
行为
--AllowDrop
--AutoValidate
--ContextMennuStrip
--DoubleBuffered
--enabled
--ImeMode
焦点
--CausesValidation
可访问性
--AccessibleDescription
--AccessibleName
--AccessibleRole
设计
(Name)
language
Localizable
locked
数据
--(ApplicationSettings)
    --(PropertyBinding)
    --Location
    --Text
--(DataBindings)
    --(Advanced)
    --Tag
    --Text
--Tag
外观
--BackColorControl
--Backgroundlmage
--BackgroundImageLayout
--Cursor
    --Name
    --Size
    --Unit
    --Bold
    --GdiCharSet
    --GdiVerticalFont
    --Italic
    --Strikeout
    --OUnderline
--ForeColor
--FormBorderStyle
--RightToLeft
--RightToLeftLayout
--Text
--UseWaitCursor
杂项
--AcceptButton
--CancelButton
--KeyPreview
--tooltip1上的ToolTip

初始:

app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
</configuration>

cs

namespace WindowsFormsApp2
{
    partial class Form1
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要修改
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(800, 450);
            this.Text = "Form1";
        }

        #endregion
    }
}

program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

笔记:

窗体
怎么修改标题 :外观--Text属性即可.

怎么修改左上角图标 :   窗口样式->ICON属性  图标最合适的大小 32*32

窗体出现的位置
StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
固定窗体的大小(不允许修改窗体大小)
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 不允许修改窗体大小[GrowOnly(默认)]

是否有最大化,最小化.
this.MaximizeBox = false;

一些小技巧:
部分异常
全局异常
日志的重要性
门:
合理的使用控件
面向对象的方式使用控件
控件多的时候如何操作.
动态加载和组合控件
自定义控件(用户控件)

遁:
窗体美化
如何使用皮肤来美化控件(SkinH)
制作我们自己的窗体


甲:
案例大集合
读取文件到列表框显示/保存数据为csv/txt等格式.
一个简单的登录案列.
闯关游戏.

猜你喜欢

转载自www.cnblogs.com/lichihua/p/10885432.html