Hi,
I m displaying a ultraprogressbar in a Ultragrid cell.My problem is that the progress bar depends on data from other column of grid.The maximum property of ultraprogress bar should be assigned a value through loop.i.e. i wish to assign different value to maximum when looping through each row of grid.
My code is
For Each row In UltraGrid1.Rows
UltraProgressBar1.Maximum = row.Cells("Planned Hours").Value
Next
But here the maximum takes the last value in the loop.But I need to assign a different value at each iteration of the loop.Is it possible???????
Please Help me...................
You need to create a different progress bar for each cell.
Change this:
To:
UltraProgressBar bar = new UltraProgressBar()
bar.Maximum = row.Cells("Planned Hours").Value
row.Cells("Percentage").EditorControl = bar
Two more tips:
1. Don't enumerate rows. Use InitializeRow event and get the row from e.Row. Thsi event occurs also when a cell value is changed.
2. Set the progress bar text to "[Value] / [Maximum]"
Thank u Amiram Thanx a lot...................
The code u gave worked well..................Thanx again.
Thanx a lot Matt for ur reply.............
Yes I had already set UseOsThemes property to false.
Yes I also think that it is not possible to show text along with progressbar.Bcoz I researched a lot for this but no results.............But still if someone thinks that it is possible then let me know.
Thnx again Matt.
Thanx a lot Amiram for ur reply................
Actually I was doing a mistake.I was binding ultraprogressbar with editor control before PercentageSettings.But when I binded it after Percentage Settings It worked.Now my code is as follows........
'Checking condition to avoid the negative percenatge.If "Remained Hours" are more then the percenatge will be zero only.
If (row.Cells("Planned Hours").Value > row.Cells("Remained Hours").Value) Then
End If
'Setting the maximum property of UltraProgressBar with value of "Planned Hour" for that row.
'Code to set the color of ProgressBar according to percentage ranges.
bar.PercentSettings.Add(1).FillAppearance.BackColor = Color.Red
bar.PercentSettings.Add(25).FillAppearance.BackColor = Color.Red
bar.PercentSettings.Add(26).FillAppearance.BackColor = Color.Blue
bar.PercentSettings.Add(50).FillAppearance.BackColor = Color.Blue
bar.PercentSettings.Add(51).FillAppearance.BackColor = Color.Orange
bar.PercentSettings.Add(75).FillAppearance.BackColor = Color.Orange
bar.PercentSettings.Add(76).FillAppearance.BackColor = Color.Green
bar.PercentSettings.Add(100).FillAppearance.BackColor = Color.Green
Now it is working fine...........
Actually I have shown progressbar in a column that have some text in it.When progressbar is shown then the text in that cell get overrided by the percentage value of the ultraprogressbar.So my question was that is it possible to show the text in that column along with the progressbar?.(My 'behind' meant this).I researched a lot for this.But know I think that may be it is not possible.
Try setting the UseOSThemes property of the progress bar to false.
As for the question about showing text in addition to the progress bar, no, I don't think this is possible, since the EditorControl is resonsible for rendering the cell's contents, and the UltraProgressBar doesn't support the string datatype. In fact, if you set this as the EditorControl of a string column, your application may be running slower because there would be a lot of FormatExceptions thrown in the code when the progress bar tries to convert the strings to numeric types.
-Matt
Actually I tried to do it myself but no luck. I use app stylist so maybe it override my color settings. When I print the grid I can see the colors I set (Do you too?)
About the text you want to show, what do you mean by "behind"? Do you want to show the cell value? then setting
bar.Text = "[Value] / [Maximum]"
should be enough
The code u gave worked fine...................
But now I wish to change the color of progressbar according to the percentage.........I also used PercentageSettings property for this purpose but it is not reflecting any changes.I m still getting the blue progressbar.
I wrote
bar.PercentSettings.Add(75).FillAppearance.BackColor = Color.Yellow
But no changes can be seen .....................
pls help...........Thanx in advance.......
Also is it possible that the column in which we are displaying ultraprogressbar if that column has some text data then we can also see that text at run time behind the progressbar?