This is a migrated thread and some comments may be shown as answers.

GirdView Grouping with Progress bar

2 Answers 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 10 Oct 2012, 05:54 PM
Below is blocks of code I use to update a radprogressbar while exporting the data out of a radgridview to excel.  The issue I am having is I get the correct row counts and the progress updates fine if the list is filtered or unfiltered.  The issue I have is once you group the progress bar keeps resetting and starting over.  Any ideas how to get a consistant update to the progress bar with a grouped gridview.  (I appollogize if this is the wrong forum, but seems to me the issue is with getting the correct grouped row counts of the radgridview.

        private void exporter_ExcelCellFormatting(object sender, ExcelCellFormattingEventArgs e)
        {
            if (e.GridRowInfoType == typeof(GridViewDataRowInfo))
            {
                //update progress bar
                int position = (int)(100 * (double)e.GridRowIndex / (double)(GetVisibleRows(this.radGridView.ChildRows)));
                this.UpdateProgressBar(position);
                this.radProgressBar.IndicatorElement1.UpdateLayout();
            }
        }

        public long GetVisibleRows(GridViewChildRowCollection rows)
        {
            long i = 0;
            foreach (GridViewRowInfo row in rows)
            {
                if (row is GridViewGroupRowInfo)
                {
                    i += GetVisibleRows(row.ChildRows);
                    continue;
                }
                i += 1;
            }
            return i;
        }

        private void UpdateProgressBar(int value)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new EventHandler(delegate
                {
                    if (value < 100)
                    {
                        this.radProgressBar.Value1 = value;
                    }
                    else
                    {
                        this.radProgressBar.Value1 = 100;
                    }
                }));
            }
            else
            {
                if (value < 100)
                {
                    this.radProgressBar.Value1 = value;
                }
                else
                {
                    this.radProgressBar.Value1 = 100;
                }
            }
        }
Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Julian Benkov
Telerik team
answered on 12 Oct 2012, 01:16 PM
Hello Scott,

Attached you can find a sample project with the desired functionality implemented.

I hope this helps. Let me know if you need some clarification.

Regards,
Julian Benkov
the Telerik team
You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.
0
Scott
Top achievements
Rank 1
answered on 12 Oct 2012, 03:40 PM
Julian,

Thanks for the code sample. 

This works great, I had one minor tweak, I had to change the (progress/rowcount) *100 to *10. 
With that change it seems to be accurate for groups, filtered, and unfiltered.

radProgressBar1.Value1 = Math.Min((int)((progress / rowCount) * 10), 100);


Thank you for your help.
Tags
GridView
Asked by
Scott
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Scott
Top achievements
Rank 1
Share this question
or