c# winform界面开发1

  1. 资源文件  新建Resources 文件夹,把图片copy到Resources中
  2. 右击工程文件名称---属性---资源---然后把图片copy到其中即可
  1. c#开发winform程序

1.1)backcolor是控件的背景颜色

1.2)FORECOLOR是控件的字体颜色

1.3)AutoSize  设置控件自动大小 =true的时候,对于label就是字的总长度,false的时候,长度可以比字多

1.4)combobox 只能通过font来指定高度

1.5)TOOLSTRIPBUTTON 需要设置autosize = false

设置image

this.tsb_WLZTParam.Image = ((System.Drawing.Image)(resources.GetObject("tsb_WLZTParam.Image")));

设置text 的方向  以及文字与图片的关系

this.tsb_WLZTParam.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;

            this.tsb_WLZTParam.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;

textBox.BorderStyle= Fixed3D FixedSingle  设置边框样式  none是没有样式

  1. 设置form 背景色
  2. 所有控件与from的背景色相同,或相近
  3. Groupbox是指forecolor 和字体,最好粗体,显得好看
  4. Text 需要设置backcolor  font  forecolor 以及对其方式TextAlign  以及borderstyle
  5. Label 需要设置autosize false   TextAlign 以及 backColor foreColor font

 // 

            this.groupBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

            this.groupBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));

            this.groupBox1.Location = new System.Drawing.Point(408, 59);

            this.groupBox1.Margin = new System.Windows.Forms.Padding(4);

            this.groupBox1.Name = "groupBox1";

            this.groupBox1.Padding = new System.Windows.Forms.Padding(4);

            this.groupBox1.Size = new System.Drawing.Size(267, 133);

            this.groupBox1.TabIndex = 0;

            this.groupBox1.TabStop = false;

            this.groupBox1.Text = "groupBox1";

            // 

            // comboBox1

            // 

            this.comboBox1.BackColor = System.Drawing.Color.Black;

            this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;

            this.comboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;

            this.comboBox1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

            this.comboBox1.ForeColor = System.Drawing.SystemColors.Window;

            this.comboBox1.FormattingEnabled = true;

            this.comboBox1.Location = new System.Drawing.Point(408, 228);

            this.comboBox1.Margin = new System.Windows.Forms.Padding(4);

            this.comboBox1.Name = "comboBox1";

            this.comboBox1.Size = new System.Drawing.Size(160, 29);

            this.comboBox1.TabIndex = 1;

            

this.textBox1.BackColor = System.Drawing.Color.Black;

            this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

            this.textBox1.Cursor = System.Windows.Forms.Cursors.Cross;

            this.textBox1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

            this.textBox1.ForeColor = System.Drawing.SystemColors.Window;

            this.textBox1.Location = new System.Drawing.Point(150, 260);

            this.textBox1.Name = "textBox1";

            this.textBox1.Size = new System.Drawing.Size(100, 29);

            this.textBox1.TabIndex = 114;

            this.textBox1.Text = "sdsd";

            this.textBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;     

            

            

            this.label1.AllowDrop = true;

            this.label1.AutoSize = true;

            this.label1.ForeColor = System.Drawing.Color.YellowGreen;

            this.label1.Location = new System.Drawing.Point(147, 376);

            this.label1.Name = "label1";

            this.label1.Size = new System.Drawing.Size(56, 16);

            this.label1.TabIndex = 116;

            this.label1.Text = "label1";       

            

            

            this.tsb_WLZTParam.AutoSize = false;

            this.tsb_WLZTParam.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F);

            this.tsb_WLZTParam.Image = ((System.Drawing.Image)(resources.GetObject("tsb_WLZTParam.Image")));

            this.tsb_WLZTParam.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;

            this.tsb_WLZTParam.ImageTransparentColor = System.Drawing.Color.Magenta;

            this.tsb_WLZTParam.Margin = new System.Windows.Forms.Padding(5, 5, 0, 5);

            this.tsb_WLZTParam.Name = "tsb_WLZTParam";

            this.tsb_WLZTParam.Size = new System.Drawing.Size(59, 58);

            this.tsb_WLZTParam.Text = "网络状态";

            this.tsb_WLZTParam.TextDirection = System.Windows.Forms.ToolStripTextDirection.Horizontal;

            this.tsb_WLZTParam.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;

            this.tsb_WLZTParam.Click += new System.EventHandler(this.tsb_WLZTParam_Click);

            

            this.btn_OpenPort.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(30)))), ((int)(((byte)(90)))));

            this.btn_OpenPort.BackgroundImage = global::WellSiteRTU.Properties.Resources.bottonbkg;

            this.btn_OpenPort.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;

            this.btn_OpenPort.FlatAppearance.BorderSize = 0;

            this.btn_OpenPort.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(30)))), ((int)(((byte)(60)))));

            this.btn_OpenPort.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));

            this.btn_OpenPort.FlatStyle = System.Windows.Forms.FlatStyle.Flat;

            this.btn_OpenPort.Font = new System.Drawing.Font("黑体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

            this.btn_OpenPort.ForeColor = System.Drawing.Color.White;

            this.btn_OpenPort.Image = global::WellSiteRTU.Properties.Resources.poweroff;

            this.btn_OpenPort.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;

            this.btn_OpenPort.Location = new System.Drawing.Point(21, 116);

            this.btn_OpenPort.Name = "btn_OpenPort";

            this.btn_OpenPort.Size = new System.Drawing.Size(138, 39);

            this.btn_OpenPort.TabIndex = 3;

            this.btn_OpenPort.Text = "打开串口  ";

            this.btn_OpenPort.TextAlign = System.Drawing.ContentAlignment.MiddleRight;

            this.btn_OpenPort.UseVisualStyleBackColor = false;

            this.btn_OpenPort.Click += new System.EventHandler(this.btn_OpenPort_Click);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值