Help with Creating Progress Bar column

8 posts, 0 answers
  1. Michael
    Michael avatar
    1 posts
    Member since:
    Oct 2010

    Posted 03 Aug 2011 Link to this post

    First off, I'd like to mention that I am a complete noob when it comes to C#. It's a steep hill to climb. :)

    In any case, I'm creating an addin class for Microsoft Dynamics NAV, that will display a list of data using the Telerik gridview control. In one of those columns I'd like to show a progress bar. I've seen how you can add code to the cell formatting event trigger, but I don't know how to do that when I do not have an interface in my solution. All the examples I've seen reference form controls.

    Any help is extremely appreciated. For reference, this is my code below. It works great for what i need with exception of the progress bar column. the grid is being populated from teh contents of a published web service.

    namespace AddInSamples
    {
        using System.ComponentModel;
        using System.Drawing;
        using System.Windows.Forms;
        using Microsoft.Dynamics.Framework.UI.Extensibility;
        using Microsoft.Dynamics.Framework.UI.Extensibility.WinForms;
        using Telerik.WinControls;
        using Telerik.WinControls.UI;
        using WorkCenterRef;
     
        [ControlAddInExport("WorkCenterStatusListTelerik")]
        public class StaticNoCaptionAddIn : WinFormsControlAddInBase
        {
            private WorkCenterRef.WorkCenter_Service workCenterList;
            private WorkCenterRef.WorkCenter[] workCenters;
     
            private Telerik.WinControls.UI.RadGridView dataGrid;
     
            protected override Control CreateControl()
            {
                dataGrid = new RadGridView();
     
                GridViewTextBoxColumn column1 = new GridViewTextBoxColumn("No.");
                GridViewTextBoxColumn column2 = new GridViewTextBoxColumn("Name");
                GridViewDecimalColumn column3 = new GridViewDecimalColumn("% Capacity");
                GridViewTextBoxColumn column4 = new GridViewTextBoxColumn("ProgressBar");
     
                column4.DataType = typeof(int);
     
                column1.Width = 100;
                column2.Width = 100;
                column3.Width = 100;
                column4.Width = 100;
     
                this.dataGrid.Columns.Add(column1);
                this.dataGrid.Columns.Add(column2);
                this.dataGrid.Columns.Add(column3);
                this.dataGrid.Columns.Add(column4);
     
                workCenterList = new WorkCenter_Service();
                workCenterList.UseDefaultCredentials = true;
                workCenters = workCenterList.ReadMultiple(null, null, 0);
     
                this.dataGrid.TableElement.BeginUpdate();
     
                this.dataGrid.AllowAddNewRow = false;
                this.dataGrid.AllowDeleteRow = false;
                this.dataGrid.AllowEditRow = false;
                this.dataGrid.AllowDragToGroup = false;
     
                column4.ReadOnly = true;
     
                foreach (WorkCenterRef.WorkCenter workCenter in workCenters)
                {
                    this.dataGrid.Rows.Add(workCenter.No, workCenter.Name, workCenter.Percent_Capacity);               
                }
     
                this.dataGrid.TableElement.EndUpdate();
                 
                return dataGrid;
            }
     
            /// <summary>
            /// Gets a values indicating whether the control shall show a caption.
            /// Overrides the implementation of StringControlAddInBase for IWinFormsControlAddIn.AllowCaptionControl
            /// </summary>
            public override bool AllowCaptionControl
            {
                get
                {
                    return false;
                }
            }
        }
    }

  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    717 posts

    Posted 05 Aug 2011 Link to this post

    Hi Michael,

    Thank you for writing and for the code snippet.

    The best way to add a column with RadProgressBars to the RadGridView is using a custom column with custom cells. You can refer to the following help article which demonstrates how to add a progress bar column to the grid: Creating custom cells.

    I hope this will help you. If you have further questions, I would be glad to help.

    All the best,
    Ivan Petrov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
  3. Reyniel
    Reyniel avatar
    1 posts
    Member since:
    Dec 2012

    Posted 03 Dec 2012 Link to this post

    Hi Ivan,

    thank you for the link on how to create a progress bar column,
    another thing is how to set the Label for the progress bar inside the row?
    Like for the regular progressbar you can just access it by using the .Text method, how can i simply do that in the progressbar column?

    Thanks in advance.
  4. Ivan Petrov
    Admin
    Ivan Petrov avatar
    717 posts

    Posted 06 Dec 2012 Link to this post

    Hello Reyniel,

    Thank you for writing.

    In the example RadProgressBarElement is added to the cells. To change the text of the progress bar element you can access its TextElement and set the text to its Text property. You can use the SetContentCore method from the example to change the text.

    I hope this is useful. Feel free to write back with any further questions.

    Kind regards,
    Ivan Petrov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  5. Maulik
    Maulik avatar
    1 posts
    Member since:
    Apr 2016

    Posted 25 Apr 2016 Link to this post

    Hi Ivan,

    Creating Custom cells Helped me creating new column with progress bar. 

    But I stuck on how to change the min and max value of progress bar. 

    Can you please help me with this issue ? 

    Thanks 

    Maulik Panchal

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3833 posts

    Posted 25 Apr 2016 Link to this post

    Hello Maulik,

    Thank you for writing.

    In the CreateChildElements of the ProgressBarCellElement you can specify the Minimum and Maximum properties of the RadProgressBarElement:
    private RadProgressBarElement radProgressBarElement;
     
    protected override void CreateChildElements()
    {
        base.CreateChildElements();
     
        radProgressBarElement = new RadProgressBarElement();
        radProgressBarElement.Minimum = 0;
        radProgressBarElement.Maximum = 10;
        this.Children.Add(radProgressBarElement);
    }

    I hope this information helps. Should you have further questions I would be glad to help.

     Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  7. Tamás
    Tamás avatar
    4 posts
    Member since:
    Dec 2013

    Posted 21 May Link to this post

    Hi All!

    So i created the progressbar custom column and added to my radgridview successfully. All data is comming from an entity framework query and at the last step i am inserting the column to the right position. Unfortunately i do not know how to set value for the progressbar inside the cell... 

    Can you give me a hint? 

    Thanks!

  8. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3833 posts

    Posted 26 May Link to this post

    Hello, Tamás,   

    I would recommend you to have a look at the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/cells/creating-custom-cells 

    The SetContentCore method of the custom cell is the appropriate place to synchronize the cell's Value with the value of the inner elements, e.g. RadProgressBarElement in this case. In case the cell's Value doesn't actually store the numeric value, you can extract it from the RowInfo.DataBoundItem.  

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top