Hi,
Can anyone tell me how to setup an event handler for the ValueChanged event that I think is required to change the Text property when the TextStyle of a CellStyle = ProgressBar cell is set to Custom. I don''t want to display the % or the value (i.e. 100/200), just the ProgressValue integer value itself.
If so, please include a C# or C++ code sample to first setup the event for a cell (since I don''t see ValueChanged as an event in the Designer) and the event code itself which should be able to extract the ProgressValue property and display it through the Text property. And, if a Handled flag needs to be set, please include that code in the event as well. Thanks.
DW
Dean Wittmann
December 23, 2004 10:11 PM
It seems my previous post message was cut up.
I will try it again.
I just want to display the ProgressValue in
the Text field of a ProgressBar style cell.
In order to do so, I am under the impression
that I need to handle the ValueChanged event
for the cell. The ValueChanged event is not
any of the events listed in the Designer and
I''m not sure how to set one up without using
the Designer.
Please include a C# or C++ code sample of
how this might be done. Thanks.
AD
Administrator
Syncfusion Team
December 24, 2004 05:01 AM
Here is one way to get at this event.
1. Subscribed to the grid''s ControlAdded event.
this.gridControl1.ControlAdded += new ControlEventHandler(gridControl1_ControlAdded);
2. In teh ControlAdded handler, subscribe to the ValueChanged event if the control is a GridProgressBar.
private void gridControl1_ControlAdded(object sender, ControlEventArgs e)
{
GridProgressBar bar = e.Control as GridProgressBar;
if(bar != null)
bar.ValueChanged += new ProgressBarValueChangedEventHandler(bar_ValueChanged);
}
DW
Dean Wittmann
December 27, 2004 07:08 PM
Thank you. It is working now.
DW
Dean Wittmann
January 3, 2005 08:17 PM
Well, it use to work. I am getting into the ControlAdded event for both a ProgressBar and a TextBox control. It seems that I am hooking up the ValueAdded event to both controls. How do I tell whether the Control is a ProgressBar or a TextBox? And what would be a reason why the ValueAdded event isn''t called after hooking up the ValueAdded event for the ProgressBar?
The ProgressBar ValueAdded Event is hooked up first, followed by the TextBox ValueAdded Event. This is done because I don''t know how to programmatically decipher between the ProgressBar and the TextBox control.
The ProgressBar CellTypes are currently Enabled, Not ReadOnly, Clickable, Text is Viewable, etc. When the ProgressValue changes, the ProgressBar moves, but the ValueAdded event is not being called and thus the Text field is not being displayed.
DW
Dean Wittmann
January 3, 2005 08:21 PM
Sorry, I got my event names mixed up in the previous post. I meant to say ValueChanged where it says ValueAdded.
AD
Administrator
Syncfusion Team
January 4, 2005 01:25 AM
I may not understand what you are describing, but this code should only subscribe to the progress bar event and skip the textbox.
GridProgressBar bar = e.Control as GridProgressBar;
if(bar != null)
bar.ValueChanged += new ProgressBarValueChangedEventHandler(bar_ValueChanged);
DW
Dean Wittmann
January 4, 2005 09:33 AM
Unfortunately, it doesn''t skip when you code this in C++. C# may be different.
AD
Administrator
Syncfusion Team
January 4, 2005 09:34 AM
Check e.Control.Name to see if that differentiates the controls.
AD
Administrator
Syncfusion Team
January 4, 2005 09:36 AM
You can also check e.Control.GetType().
DW
Dean Wittmann
January 4, 2005 09:57 AM
I just figured out how to do it similar to the syntax of C#.
Instead of using static_cast(e->Control) or dynamic_cast(e->Control), only __try_cast(e->Control) catches the exception. But, you need a try {} catch (...) {}; around the cast. Here is the code I used:
try {
GridProgressBar* pProgressBar = __try_cast(e->Control);
if (pProgressBar != NULL) {
pProgressBar->ValueChanged += new ProgressBarValueChangedEventHandler(this, GridProgressBar_ValueChanged);
}
}
catch (...) {
}
Thanks for the help. I just need to figure out why the ValueChanged event is not being triggered when I change the ProgressValue.
DW
Dean Wittmann
January 4, 2005 10:01 AM
There is missing arguments to the static_cast, dynamic cast, and __try_cast in the above code. It seems that posting a message with something in less than and greater than characters is removed from the posted message. The contents of the __try_cast are:
__try_cast, followed by the less than character, followed by GridProgressBar*, followed by the greater than character.
DW
Dean Wittmann
January 4, 2005 10:27 AM
It seems that the ValueChanged event gets superceded by possibly another ValueChanged event when I change the CellType of a cell to NumericUpDown, the cell that I change is within the same column where the ProgressBar''s reside. And the column has a default CellType of ProgressBar.
Any ideas?
AD
Administrator
Syncfusion Team
January 4, 2005 11:50 AM
Normally, subscribing to an event on one control does not step on any event handle for another control. Event if you use the same event handler for two different controls, the event is norammly triggerred OK. In you event handler code, are you checking sender to see what control is sending the event?
Do you have code that unsubscribes to events?
Is the grid inside some splitter window like a GridRecordNavigationControl? If so, there is special event handling you need to do to take into account the new grids that are created when a pane is created, etc.
DW
Dean Wittmann
January 4, 2005 11:55 AM
No, I''m not currently checking the sender in the ValueChanged event handler, but I will put some code in to do so.
And, no, I don''t have any code that unsubscribes to any events.
I''ll try to figure out what''s going on.
RM
Rolando Miranda
replied to Administrator
February 17, 2018 06:51 AM
I may not understand what you are describing, but this code should only subscribe to the progress bar event and skip the textbox.
GridProgressBar bar = e.Control as GridProgressBar;
if(bar != null)
bar.ValueChanged += new ProgressBarValueChangedEventHandler(bar_ValueChanged);
REQUIERO EL CODIGO FUENTE
MG
Mohanraj Gunasekaran
Syncfusion Team
February 19, 2018 02:47 PM
Hi Rolando,
Thanks for using Syncfusion product.
By default, you can get the control details in ControlAdded event while adding the new control, then you can identify that control using type cast the controls. And, TextChanged evet has triggered while changing the textbox value and ValueChanged has triggered when changing the value of progressbar. Please refer to the below code example and the sample,
Code example
this.gridControl1.ControlAdded += gridControl1_ControlAdded;
void gridControl1_ControlAdded(object sender, ControlEventArgs e)
{
if (e.Control is GridTextBoxControl)
{
GridTextBoxControl textBoxControl = e.Control as GridTextBoxControl;
textBoxControl.TextChanged += textBoxControl_TextChanged;
}
else if (e.Control is GridProgressBar)
{
GridProgressBar porgressBar = e.Control as GridProgressBar;
porgressBar.ValueChanged += porgressBar_ValueChanged;
}
}
void porgressBar_ValueChanged(object sender, Syncfusion.Windows.Forms.Tools.ProgressBarValueChangedEventArgs e)
{
//Triggered when progressbar value changed
}
void textBoxControl_TextChanged(object sender, EventArgs e)
{
//Triggerd when textbox value changed
} |
Please let us know if you have any concerns.
Regards,
Mohanraj G