• c#devexpress GridContorl添加进度条


    demo 的实现图

    下边是步骤和代码

    1定义 时钟事件,定时的增加进度条的增量.

    2:  添加进度条

    3;定义字段属性

    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.Timers;
    using System.Windows.Forms;
    
    namespace ProgressBar
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                jindu = new JinduModel();
                jindu.jindu = 0;
                rarlist = new BindingList<JinduModel>();
                rarlist.Add(jindu);
                gridControl1.DataSource = rarlist;
                InitGridcontrol();
            }
            JinduModel jindu;
          //  BindingSource bs;
            BindingList<JinduModel> rarlist;
            void InitGridcontrol()
            {
                 
                // new System.Timers.Timer
                //实例化Timer类,设置间隔时间为10000毫秒; 
                aTimer = new System.Timers.Timer(1000);
                //注册计时器的事件
                aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
                //设置时间间隔为2秒(2000毫秒),覆盖构造函数设置的间隔
                aTimer.Interval = 2000;
                //设置是执行一次(false)还是一直执行(true),默认为true
                aTimer.AutoReset = true;
                //开始计时
                aTimer.Enabled = true;
    
    
            }
            //指定Timer触发的事件
            private  void OnTimedEvent(object source, ElapsedEventArgs e)
            {
                 this.Invoke( new Action(()=> jindu.jindu++));
                Console.WriteLine("触发的事件发生在: {0}", e.SignalTime);
            }
            //Timer不要声明成局部变量,否则会被GC回收
            private static System.Timers.Timer aTimer;
            private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
            {
                if (e.Column.FieldName == "count")
                {
                    int count = 10000;//Convert.ToInt32(System.Math.Ceiling(zipfileInfo.Length / 1024.0));//datalist[0].count;//(int)this.gridView1.GetRowCellValue(e.RowHandle, "Count");
                    int index = (int)e.CellValue;
                    e.DisplayText = string.Format("{0}/{1}", index, count);
                }
            }
    
            private void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
            {
                if (e.Column.FieldName == "count")
                {
                    //   int count = (int)this.gridView1.GetRowCellValue(e.RowHandle, "count");
                    //  int index = (int)e.CellValue;
                    repositoryItemProgressBar1.Maximum = 10000;//Convert.ToInt32(System.Math.Ceiling(zipfileInfo.Length / 1024.0));//datalist[0].count;//count;
                    e.RepositoryItem = repositoryItemProgressBar1;
                }
            }
        }
      
    
    }
     class JinduModel : INotifyPropertyChanged
        {
            private int _jindu;
            public int jindu
            {
                get { return _jindu; }
                set { _jindu = value; OnPropertyChanged("jindu"); }
            }
            public event PropertyChangedEventHandler PropertyChanged;
            protected void OnPropertyChanged(string name)
            { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); }
            
        }
  • 相关阅读:
    golang批量修改文件名
    golang执行带空格的cmd命令
    了解golang的可变参数(... parameters)
    ADB命令连接逍遥模拟器
    通达信如何批量导出自定义板块,以及定义常量
    通达信日K线图中取周K线指标值
    go读取通达信本地数据
    Python读取通达信本地数据
    Golang: 解析JSON数据之一
    MT【357】角度的对称性
  • 原文地址:https://www.cnblogs.com/zuochanzi/p/8962263.html
Copyright © 2020-2023  润新知