In the WinGrid sample explorer for Infragistics 7.1 version, a sample named "Flood Fill" (located in "Extensibility Samples")demonstrate how progress bar can be included in cells.
I have studied the source code and seen that this functionality in not a built-in one, but uses the DrawElement method to paint a rectangle in each cell. I have also remarked that for long bounded tables (ie with a lot of rows), rectangles take some time to draw (we can see each rectangle to be drawn).
I would like to know if this functionality is now included in the component or if it will be in the futur. If not, are there some possible code optimisations to do to increase draw performance?
Thanks in advance.
Rico
Hi Rico,
That sample is pretty old and there is a new, better way.
You can now use the UltraProgressBar control for this. Just put one on the form with the grid and assign the column's EditorControl property to the ProgressBar. You will probably want to set the MinValue and MaxValue on the grid column, as well, to give the progress bar the correct range of values.
Thanks Mike,
You're right, the method you give here is much more simple than drawing a rectangle for each cell in the DrawElement event handler ; and it does not hurt display performances, so it is the solution I adopted.
For others that have the same needs, here is a sample code on how to achieve my goal on the 'colName' column:
Dim col As Infragistics.Win.UltraWinGrid.UltraGridColumn
col = Me.UltraGrid1.DisplayLayout.Bands(0).Columns(colName)
' Set column min & max values
Dim dv As New Data.DataView(Me.UltraGrid1TableDatasource) dv.Sort = colName + " DESC"
col.MinValue = dv(dv.Count - 1)(colName) col.MaxValue = dv(0)(colName) Dim upb As New Infragistics.Win.UltraWinProgressBar.UltraProgressBar upb.Visible = False upb.UseFlatMode = Infragistics.Win.DefaultableBoolean.True
' Set SupportThemes to false to allow Continuous progress bar Me.UltraGrid1.UseOsThemes = Infragistics.Win.DefaultableBoolean.False
upb.Style = Infragistics.Win.UltraWinProgressBar.ProgressBarStyle.Continuous Me.Controls.Add(upb) col.EditorControl = upb col.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Center
Thanks again for your answer.
Hi,
After implementing the solution, I met a problem - maybe a bug - when adding a progressbar control in a calculated column (column with a Formula defined and an UltraCalcManager on the form).
The problem is that the displayed progressbar values are 0 for all rows in my ultraGrid, as if the progressbar control wasn't able to get the calculated value. When I remove the Progressbar control from the EditorControl, all values are displayed. After debugging, I noticed that the Progressbar.Value property throws an exception (UltraGrid1.Rows(0).Cells(1).EditorResolved.Value {"Object reference not set to an instance of an object."} Object).
An other problem is a huge performance penality when setting the UltraProgressBar to the column's editor control property, even for small datasource (2 columns & 5 rows) : all actions on the form freezes it for several seconds.
ricoledaouf said:An other problem is a huge performance penality when setting the UltraProgressBar to the column's editor control property, even for small datasource (2 columns & 5 rows) : all actions on the form freezes it for several seconds.
Do you mean that this happens in the calculated column? Or for other columns as well?
It sounds to me like the ProgressBar is throwing an exception based on the value it's getting from the grid. This explains both why it's not displaying the value and the slowdown - exception handling is very performance-intensive.
What's the DataType of the calculated column? If this is an unbound column, then it will default to String, which might explain the issue, since the progress bar can't handle a string (it needs a numeric value).
Hi Mike,
The problem I described happens only for 'calculated' columns (ie a column with a Formula defined). I thought the same for performance problem explanation (exception handling hurt performances).
My added column (unbound) is of Single datatype and displays only an other column value (which is of Single type too). The datasource table contains one column (called 'Number') and 5 rows (values are between 0 and 103). Here is a short code snippet on how I added the progressBar column:
Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout dim col as Infragistics.Win.UltraWinGrid.UltraGridColumn col = UltraGrid1.DisplayLayout.Bands(0).Columns.Add("Calculated") col.DataType = gettype(Single) col.Formula = "[Number]" col.MinValue = 0 col.MaxValue = 103 Dim upb As New Infragistics.Win.UltraWinProgressBar.UltraProgressBar upb.Visible = False Me.Controls.Add(upb) Col.EditorControl = upb
End Sub
CalcManager typically likes to work with doubles (rather than singles), so you might try changing the data type of the column to double and see if that helps.
That seems unlikely to be the problem, though - I would think the conversion from double to single would be easy enough and not cause an exception unless the value was too large.
Have you tried setting the IDE to break on all exceptions and see if any are occurring?
If that doesn't help, I think you should probably create a small sample project that demonstrates the problem and submit the issue to Infragistics DeveloperSupport so they can investigate. Get Help
Hello,
Did you find a solution for this problem? I have the same issue: impossible to use Progressbar on computed columns (I am using the 9.1 release of WinForms);
Unfortunatelly, setting to 'Single' datatype on both columns produce the same results (performance drop and nullReference exception at Infragistics.Win.UltraWinProgressBar.ProgressBarEditor.get_Value()).
Setting break on all exceptions did not bring any program break, so as no more details can be found, I would send a sample program to the Developer Support to let them investigate the problem.
Thanks for your recommendations.
Rico.