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. Image for the cookie policy date

Problem with Updating Multiple Columns with ProgressBar''s

When I had just one column with ProgressBar''s and the TextStyle was set to Custom and I added the ValueChanged event through the ControlAdded event, everything worked fine. Now, I added two more columns with ProgressBar''s that have their TestStyle''s set to Custom. The ControlAdded event is only fired once for each type of control added to the grid. So their is only one ValueChanged event added. This is fine. But, now, when I update the text in a ProgressBar in one column, it seems to redraw the other ProgressBar columns with the same Text data that I just changed. I can''t seem to figure out why this is happening. I also needed to get the current row and column of the cell being serviced in the ValueChanged event. Please look at the included code and tell me if I''m doing it right. Here is the entire ValueChanged event handler: private: Void GridProgressBar_ValueChanged(Object* sender, ProgressBarValueChangedEventArgs* e) { try { GridProgressBar* pProgressBar = __try_cast(sender); if (pProgressBar != NULL) { Int32 Row, Col; Point CellPoint; CellPoint.X = pProgressBar->Bounds.X; CellPoint.Y = pProgressBar->Bounds.Y; pProgressBar->ParentCell->Grid->PointToRowCol(CellPoint, &Row, &Col); if (Col == m_iDevColumn) { e->Text = static_cast(gridIO->Item[Row][ROW_HEADER]->Tag)->dDevValue.ToString(szDoubleFormat); } else if (Col == m_iEngColumn) { e->Text = static_cast(gridIO->Item[Row][ROW_HEADER]->Tag)->dEngValue.ToString(szDoubleFormat); } else { e->Text = pProgressBar->Value.ToString(); } e->Handled = true; } } catch (...) { } }

10 Replies

DW Dean Wittmann January 7, 2005 03:02 AM UTC

The ROW_HEADER value is 0, indicating that I am only using the Tag properties in the Row Headers. Here is the declaration of the Tag for the Row Headers: typedef __gc struct Row_Tag { CIODevice* pDev; char* szDevTrueState; char* szDevFalseState; double dDevValue; double dEngValue; } RowTag; For the Dev (Device) column and Eng (Engineering) column, the required values to be display are doubles. The szDoubleFormat string is "0.0#". The m_iDevColumn and m_iEngColumn variables are used to track the location of these columns. The third column is also tracked, but this column is the default fall-through else-clause. And it''s Text value is being set to the value of the progress bar itself and displays as an integer. In all cases, the e->Handled flag is being set to true. I hope these comments help in understanding this code.

DW Dean Wittmann January 7, 2005 03:23 AM UTC

Also, I handle the CellMouseHoverEnter and CellMouseHoverLeave events to set the CellAppearance property of the ProgressBar''s to Raised and Flat, respectively. This gives the user an indication that they can click on this cell. The resulting visual is similar to a PushButton CellType when the mouse goes over a PushButton cell. When each ProgressBar cell is redrawn because of the CellAppearance property change, the Text property of the GridProgressBar is used from a previous call to the ValueChanged event. This, in effect, will update each ProgressBar cell (that the mouse hovers over) with the last Text string that I set for the last ProgressBar updated through the ValueChanged event. I know that I am only using one ProgressBar control and thus there is only one Text property for all ProgressBars. I don''t know if the ValueChanged event is being fired prior to redrawing each ProgressBar cell. If not, this would explain why this phenomenon is happening.

AD Administrator Syncfusion Team January 7, 2005 05:28 AM UTC

If things works the way you want with a single progressbar column, then you might try registering new progressbar cellmodels for the two additional columns by calling the same CellModels.Add method you used to register the first progressbar celltype, but pass in new celltype names and cellmodel instances. This way each column can have its own progressbar and have its own event handler.

DW Dean Wittmann January 7, 2005 08:55 PM UTC

I''ve been trying all day to decipher (in the ControlAdded event) how to tell the difference in the CellModels and/or CellType Names so that I can add different ValueChanged events to each column. The ControlAdded event is being called 3 times, once for each ProgressBar column. So, at least that part is working. I have added new CellModel''s with CellType names of "RawProgressBar", "DevProgressBar", and "EngProgressBar". With only one column, I didn''t have to Add a new CellModel because it was the only column with ProgressBars. Can you enlighten me?

AD Administrator Syncfusion Team January 7, 2005 10:14 PM UTC

Here is some code that I think will pick out the different progressbars for you.
private void gridControl1_ControlAdded(object sender, ControlEventArgs e)
	GridProgressBar bar = e.Control as GridProgressBar;
	if(bar != null)
		else if(bar.ParentCell.Model.Equals(this.gridControl1.CellModels["DevProgressBar"]))
		else if(bar.ParentCell.Model.Equals(this.gridControl1.CellModels["RawProgressBar"]))

DW Dean Wittmann January 7, 2005 11:19 PM UTC

You are the man!!! It worked. You''ve saved my butt several times and I just want to say "Thank you very much."

DW Dean Wittmann January 9, 2005 07:03 AM UTC

I need help once again. Now I have three separate ValueChanged Events. The RawValueChanged event can use the GridProgressBar''s Value property to fill in the e->Text information to be displayed. This column of Progress Bars was the original column and was and is still working correctly. However, the other two events: DevValueChanged and EngValueChanged don''t use the Value property to display the text, because the actual text to be displayed is a double value and not an integer. This double value is stored in a structure pointed to by the original GridStyleInfo->Tag field for the Row Header Cell. But, I can also point to this same structure in each GridProgressBar''s Grid[Row][Col]->Tag property, where Grid[Row][Col] is the original Cell''s GridStyleInfo object. I need to know either the current RowIndex that is used for the currently called ValueChanged event. Or, I could also use the original GridStyleInfo->Tag property for the ValueChanged events current cell. I have tried to use the ParentCell->RowIndex property. I have tried to use the GridProgressBar->Bounds and the Grid''s PointToRowCol function in order to extract the RowIndex. I have tried to use the ParentCell->CurrentStyle->Tag property to get the original GridStyleInfo->Tag property. In each case, the RowIndex was invalid or the Tag field was undefined. Can you tell me how to get the current cell''s RowIndex or, preferably, how to get the current cell''s original GridStyleInfo->Tag field within the ValueChanged event for a GridProgressBar?

AD Administrator Syncfusion Team January 9, 2005 08:24 AM UTC

The grid.CurrentCell is not necessarily related to the cell being drawn, so just accessing the CurrentCell info will not be sufficient. Here is one way you can do it. Subscribe to the DrawCell event and set a class member to hold the column bening drawn.
private int drawingCol = -1;
private void gridControl1_DrawCell(object sender, GridDrawCellEventArgs e)
	this.drawingCol = e.ColIndex;

private void bar_ValueChanged(object sender, Syncfusion.Windows.Forms.Tools.ProgressBarValueChangedEventArgs e)


DW Dean Wittmann January 11, 2005 05:35 AM UTC

That helped. Thank you again. Now I have another problem related to ProgressBar updates that do not call the ValueChanged event. As I had mentioned in an earlier posting, I am handling the MouseHoverEnter and MouseHoverLeave events and changing the CellAppearance of the cells where the ProgressBars reside. On MouseHoverEnter, the CellAppearance is being set to Raised. On MouseHoverLeave, the CellAppearance is set back to Flat. This gives the appearance fairly equivalent to the PushButton raising when the mouse hovers over the cell. The problem is that the cell needs to be redrawn and is not calling the ValueChanged event because the Value hasn''t changed. The Text used to redraw the ProgressBar cell seems to be taken from a previous cell depending upon the direction the mouse enters the cell. I know I could resolve this issue by not handling these events for the visual effect. But I want to have some sort of visual effect that indicates to the user that a particular cell can be clicked. I am using the ProgressBar cell as an indicator of the current analog values for analog devices that the program is monitoring. In addition, the user can click on the cell to change the analog value, which will be sent to the device after some validation of the value''s range. The ProgressBar cell itself is not used for text input. Instead, another Form is shown for text input. Is there a way to get to the Text property that will be used to redraw a ProgressBar cell prior to the Text being redrawn? I need to make sure that what is drawn in the cell is related to that particular cell and not a neighboring cell. Currently, I can scan the mouse up and down a column of ProgressBars and duplicate Text up and down the column. The Text duplicated comes from one of the neighboring cells and not the cell being drawn. I''m sure the ProgressBar values have not changed and therefore the ValueChanged event is not firing. Maybe I could use the DrawCell, Paint, or Invalidated event(s) to make sure that the contents of a ProgressBar cell are drawn with the correct Text. I''m assuming that the Text being drawn comes from the GridProgressBar.Text field, which is inherited for the ProgressBarAdv control.

AD Administrator Syncfusion Team January 11, 2005 06:34 AM UTC

Try this. When the mouse enters your progressbar cell, try calling grid.Model.ResetVolatileData to see if this will zap any cached values for the cell.

Live Chat Icon For mobile
Up arrow icon