Skip to content

How to customize the ProgressBarColumn text in WinForms DataGrid (SfDataGrid)?

Notifications You must be signed in to change notification settings

SyncfusionExamples/how-to-customize-the-progressbar-column-text-in-winforms-datagrid-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to customize the ProgressBarColumn text in WinForms DataGrid?

This sample illustrates how to customize the ProgressBarColumn text in WinForms DataGrid (SfDataGrid).

By default, the DataGrid GridProgressBarColumn have maximum value as 100, you can change the this by overriding the OnRender method in GridProgressBarColumnCellRenderer class.

this.sfDataGrid.CellRenderers.Remove("ProgressBar");
this.sfDataGrid.CellRenderers.Add("ProgressBar", new GridProgressBarColumnExt(new ProgressBarAdv()));

public class GridProgressBarColumnExt : GridProgressBarCellRenderer
{
    ProgressBarAdv ProgressBar;

    public GridProgressBarColumnExt(ProgressBarAdv progressBar) : base(progressBar)
    {
        ProgressBar = progressBar;
    }

    protected override void OnRender(Graphics paint, Rectangle cellRect, string cellValue, CellStyleInfo style, DataColumnBase column, RowColumnIndex rowColumnIndex)
    {
        ProgressBar.CustomText = cellValue + "%";
        ProgressBar.TextStyle = ProgressBarTextStyles.Custom;
        decimal decimalvalue = decimal.Parse(cellValue);
        var intvalue = decimal.ToInt32(decimalvalue);
        cellValue = intvalue.ToString();
        base.OnRender(paint, cellRect, cellValue, style, column, rowColumnIndex);
    }
}

DataGrid showing customized ProgressBarColumn text

Requirements to run the demo

Visual Studio 2015 and above versions

About

How to customize the ProgressBarColumn text in WinForms DataGrid (SfDataGrid)?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages