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