Winform常用代码1

 

1.toolStripStatusLabel居右:
        StatusStrip→LayoutStyle→HorizontalStackWithOverflow 
        this.toolStripStatusLabel1.Alignment = ToolStripItemAlignment.Right;
    2.实体类:
         class prices
            {
                public prices(int par_level,double par_price)
                {
                    Level = par_level;
                    Price = par_price;
                }
                public int Level
                {
                    get;
                    set;
                }
                public double Price
                {
                    get;
                    set;
                }
            }
    3.保留两位小数:
        this.ttime_kryptonLabel.Text = total_time.ToString("0.00")+"小时";
    4.Linq查询:
        vvar price = from p in pris where p.Level == level select p.Price;
    5.TextBox中启用Tab:
        设置属性AcceptsTab为True
    6.设置Tooltip:
          //设置提示信息
                    ToolTip tip = new ToolTip();
                    tip.AutoPopDelay = 5000;
                    tip.InitialDelay = 1000;
                    tip.ReshowDelay = 500;
                    tip.ShowAlways = true;
        
                    tip.SetToolTip(this.organize_button, "将单页面Excel整合成一个Excel");
                    tip.SetToolTip(this.Math_button, "与前期捕获的数据对比,叠加没有捕获到的数据");
    7.处理前台界面假死:
        for (int i = 0; i < 10000; i++)
                    {
                        label1.Text = i.ToString();
                        Application.DoEvents();
                    }
    8.内存释放:
          #region 内存回收
                [DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
                public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
                /// <summary>
                /// 释放内存
                /// </summary>
                public static void ClearMemory()
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                    {
                        SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
                    }
                }
                #endregion

DotNetBar:
    1.Office窗体:继承: DevComponents.DotNetBar.OfficeForm
        在构造函数中加入:this.EnableGlass = false;
    2.Bar控件:
        设置属性MenuBar为True

转载于:https://www.cnblogs.com/zhaobijin/p/5807801.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值