• 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)); }
            
        }
  • 相关阅读:
    利用国内的源安装 Python第三方库
    Python 算法(1) 快速排序
    Python 算法(2) 哈夫曼编码 Huffman Encoding
    Python sql注入 过滤字符串的非法字符
    tesseract中文语言文件包 下载
    python 多线程爬虫 实例
    Python 爬虫实例(5)—— 爬取爱奇艺视频电视剧的链接(2017-06-30 10:37)
    Django的ORM中如何判断查询结果是否为空,判断django中的orm为空
    Python 爬虫实例(4)—— 爬取网易新闻
    NLTK在自然语言处理
  • 原文地址:https://www.cnblogs.com/zuochanzi/p/8962263.html
Copyright © 2020-2023  润新知