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.
Unfortunately, activation email could not send to your email. Please try again.

How to add a handler for the ValueChanged event for a ProgressBar cell?

Thread ID:

Created:

Updated:

Platform:

Replies:

22838 Dec 23,2004 10:04 PM Feb 19,2018 02:47 PM Windows Forms 16
loading
Tags: GridControl
Dean Wittmann
Asked On December 23, 2004 10:04 PM

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.

Dean Wittmann
Replied On 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.

Administrator [Syncfusion]
Replied On 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); }

Dean Wittmann
Replied On December 27, 2004 07:08 PM

Thank you. It is working now.

Dean Wittmann
Replied On 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.

Dean Wittmann
Replied On 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.

Administrator [Syncfusion]
Replied On 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);

Dean Wittmann
Replied On January 4, 2005 09:33 AM

Unfortunately, it doesn''t skip when you code this in C++. C# may be different.

Administrator [Syncfusion]
Replied On January 4, 2005 09:34 AM

Check e.Control.Name to see if that differentiates the controls.

Administrator [Syncfusion]
Replied On January 4, 2005 09:36 AM

You can also check e.Control.GetType().

Dean Wittmann
Replied On 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.

Dean Wittmann
Replied On 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.

Dean Wittmann
Replied On 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?

Administrator [Syncfusion]
Replied On 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.

Dean Wittmann
Replied On 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.

Rolando Miranda
Replied On 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

Mohanraj Gunasekaran [Syncfusion]
Replied On 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 
} 
 
Sample link: GridControl 
 
Please let us know if you have any concerns. 
 
Regards, 
Mohanraj G 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;