This is a migrated thread and some comments may be shown as answers.

Bindable property on custom control

3 Answers 43 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael Bakker
Top achievements
Rank 2
Michael Bakker asked on 01 Sep 2015, 12:52 PM

To meet some layout requirements for displaying a currency value i created a custom control that inherits from a Telerik.Reporting.Panel.
I added two textboxes to it, one left aligned with the currency symbol, one right aligned containing the actual value.
I added a Value (String) property to this custom control that merely gets/sets the Value property on the right aligned textbox inside the panel.

This works nicely, except when i add a binding. An error message states that the path 'Value' is not supported for binding.
I tried to solve this by adding a Bindable(True) attribute to the property declaration, but that doesn't help.

How can i make the Value property on this custom control be bindable?

3 Answers, 1 is accepted

Sort by
0
Michael Bakker
Top achievements
Rank 2
answered on 01 Sep 2015, 01:14 PM
I solved it by relaying the 'Bindings' property of the Panel to the Bindings property of the textbox, which' value must be bound.
Public Shadows ReadOnly Property Bindings as BindingCollection
 Get
     return txtValue.Bindings
 End get
End Property

I think there might be a more elegant solution though.   
0
Accepted
Michael Bakker
Top achievements
Rank 2
answered on 07 Sep 2015, 01:39 PM

And there is a better solution: the 'Alignment component' of the format string.

See: https://msdn.microsoft.com/en-us/library/txafckwd(v=vs.110).aspx

E.g:  € {0,15:N0}

This will display a left aligned € symbol and a right aligned 15 character long value, padded by spaces.


 
 
0
Michael Bakker
Top achievements
Rank 2
answered on 09 Sep 2015, 11:51 AM
Rember to use a fixed-width font!
Tags
General Discussions
Asked by
Michael Bakker
Top achievements
Rank 2
Answers by
Michael Bakker
Top achievements
Rank 2
Share this question
or