zoukankan      html  css  js  c++  java
  • 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)); }
            
        }
  • 相关阅读:
    mac下面xcode+ndk7配置cocos2dx & box2d的跨ios和android平台的游戏教程
    如何在macox下面配置集成ios和android游戏教程
    Cocos2d-x win7 + vs2010 配置图文详解(亲测)
    cocos2d-x学习资源汇总(持续更新。。。)
    我常用的iphone开发学习网站[原创]
    「C」关键字、标识符、注释、内存分析、数据、常量、变量
    「Foundation」集合
    「Foundation」字符串
    「Foundation」结构体
    「OC」block 和 protocol
  • 原文地址:https://www.cnblogs.com/zuochanzi/p/8962263.html
Copyright © 2011-2022 走看看