开发者

What's the best way to add progressbar to cxGrid column

I am adding progressbar to each row of my first grid's banded tableview column ! The way I do it => I put 4 progressbars on my form and on btvArrProgGetProperties(TcxCustomGridTableItem *Sender, TcxCustomGridRecord *ARecord, TcxCustomEditProperties *&AProperties) assigning properties to a specific row by changing putted progressbar properties. here is my code

void __fastcall TfMain::btvArrProgGetProperties(TcxCustomGridTableItem *Sender, TcxCustomGridRecord *ARecord,
          TcxCustomEditProperties *&AProperties)
    {
          if ( StrToInt(ARecord->Values[ARecord->RecordIndex,1])==4 ){
            ARecord->Values[ARecord->RecordIndex,0]=100;
            AProperties=pCancel->Properties;
          }
          else
            if ( StrToInt(ARecord->Values[ARecord->RecordIndex,1])==2) {
                ARecord->Values[ARecord->RecordIndex,0]=100;
                AProperties=pDep->Properties;
          }
              else  {

                  if (StrToInt(ARecord->Values[ARecord->RecordIndex,1])==1) {
                        if ((ARecord->Values[ARecord->RecordIndex,7])!=0 && (ARecord->Values[ARecord->RecordIndex,12])!=0) {
                            //now time
                            nwTm=Now().FormatString("hh:mm:ss");
                            //get dep time
                            dpTm=StrToDateTime(ARecord->Values[ARecord->RecordIndex,7]);
                            dpTm.DecodeTime(&dpH,&dpM,&dpS,&dpMS);
                            //get reg time
                            rgTm=StrToDateTime(ARecord->Values[ARecord->RecordIndex,12]);
                            //find difference between dep and reg
                            dif=(1.0 + Double(dpTm)-Double(rgTm));
                            //get difference hours and mins
                            dif.DecodeTime(&difH,&difM,&difS,&difMS);
                            //diff between dep and reg in seconds
                            pReg->Properties->Max=difH*3600+difM*60+difS;
                            nwTm=Now().FormatString("hh:mm:ss");
                            nwTm.DecodeTime(&nwH,&nwM,&nwS,&nwMS);

                            if ((dpH>nwH) || ((dpH>nwH) && (dpM>=nwM ||dpM<=nwM)) || (dpH==nwH && dpM>nwM)  ) {
                                fltRem =(1.0 + Double(dpTm)-Double(nwTm));
                                fltRem.DecodeTime(&remH,&remM,&remS,&remMS);
                                _result=remH*3600+remM*60+remS;


                                pReg->Properties->Text=getTimeBySecs(_result);
                                ARecord->Values[ARecord->RecordIndex,0]=pReg->Properties->Max-_result;
                                pReg->Position=- _result;
                            }
                            else
                            {
                                    pReg->Properties->Max=100;
                                    ARecord->Values[ARecord->RecordIndex,0]=100;
                                    pReg->Properties->Text="Готово";

    /*
                                        ARecord->Values[ARecord->RecordIndex,0]=pReg->Properties->Max;

                                        pReg->Position=pReg->Properties->Max;

    */
                            }
                            AProperties=pReg->Properties;

                        }
                  }

            }

    }

I think that this not a good approach to solve my problem (adding progressbar to a column which it's position get's changed dynamically), because when I click to each's row progressbar'开发者_如何学JAVAs position gets changed due to a last value set to progressbar!!

I prefer to dynamically create progressbar set name and other properties to it during runtime and assign to specific row on GetProperties event. What approach is the best one ? Is there any demo on this issue? If yes could you share please! Thanks in advance !

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜