Set value of Int32EditBox in Code

Editors for WPF Forum

Posted 1 year ago by Ernie Bahr
Version: 23.1.0
Avatar

I am trying to revive an old code base that heavily used Actipro WPF going back to release 10.  The last release we had used was 14.1.  I jumped from that to 23.1.0.0  Of course I have found many things have changed and I am slowly working my way through them.  One of the things that has stopped me dead in my tracks is setting the value of an Int32EditBox in code.  This poarticular code base is in VB.Net.

Here is an example...

txtMaxThreads.Value = ConnectionSettings.Instance.MaxBatchConcurrentThreads

The value of MaxBatchConcurrentThreads is an Integer

While this code worked perfectly in 14.1, in 23.1 it throws an InvalidCastException with the message 'Unable to cast object of type 'System.EventArgs' to type 'ActiproSoftware.Windows.PropertyChangedRoutedEventArgs`1[System.Nullable`1[System.Int32]]'.'

My question is...

Is there still a way to programatically set the value of an Int32EditBox or is the only option to use binding in XAML?  Any help you can provide will be greatly appreciated.  I am struggling to get my application running again.

Comments (2)

Posted 1 year ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Ernie,

You can still use that code, but the ValueChanged event now just takes EventArgs instead of PropertyChangedRoutedEventArgs<T>.  I suspect just changing the event args in your event handler will fix it.


Actipro Software Support

Posted 1 year ago by Ernie Bahr
Avatar

That worked!  Thank you.  I forgot that I had an event handler wired to the edit box.  I had to change the code inside the handler too to get the value using sender.Value instead of e.NewValue

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.