We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How can I have progressbar cells in a GridDataBoundGrid?

 

In a GDBG, you cannot directly bind the value coming from your datasource to the progressbar's value. You would have to handle Model.QueryCellInfo and provide the progress value dynamically in this event.

The reason is that the grid does not maintain any cell specific type information other than the cell value (which is mapped back to the datasource). It does not track text color, backcolor, or any other cell specific properties (like progress value) in a GridDataBoundGrid. So you would have to maintain your own datastore of these values (like the progress value) and provide them on demand either in Model.QueryCellInfo or PrepareViewStyleInfo.

C#

private void GridQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

{

if(e.RowIndex > 0 && this.gridDataBoundGrid1.Binder.NameToColIndex("Col3") == e.ColIndex)

{

int col = this.gridDataBoundGrid1.Binder.NameToColIndex("Val");

string s = this.gridDataBoundGrid1[e.RowIndex, col].Text;

int val = s.Length == 0 ? 0 : int.Parse(s);

GridProgressBarInfo progressBar = e.Style.ProgressBar;

progressBar.ProgressValue = val;

}

}

VB

Private Sub GridQueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)

If e.RowIndex > 0 AndAlso Me.gridDataBoundGrid1.Binder.NameToColIndex("Col3") = e.ColIndex Then

Dim col As Integer = Me.gridDataBoundGrid1.Binder.NameToColIndex("Val")

Dim s As String = Me.gridDataBoundGrid1(e.RowIndex, col).Text

Dim val As Integer = IIf(s.Length = 0, 0, Integer.Parse(s))

Dim progressBar As GridProgressBarInfo = e.Style.ProgressBar

progressBar.ProgressValue = val

End If

Here is the link with both CS and VB samples: http://websamples.syncfusion.com/samples/KB/Grid.Windows/GDBGProgressBar/main.htm

Article ID: Published Date: Last Revised Date: Platform: Control:
483 04/30/2011 07/10/2014 Windows Forms GridDataBoundGrid(Classic)
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.