View previous topic :: View next topic |
Author |
Message |
keesp Guest
|
Posted: Mon Aug 22, 2005 7:11 am Post subject: using format in Universal edit box |
|
|
Hi,
I want to format the strings that are displayed in the universal editbox (the provided data may be any object), so that, for instance, when the ToString() of an object I provide returns the string representation of a double like 0.12345678, I can just show 0.123.
What is the best way to tackle this?
Thanks
Kees |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Aug 23, 2005 9:56 am Post subject: |
|
|
There are two ways you could do this:
1. Write your own TypeConverter and associate it with the property being edited using the TypeConverterAttribute. Your type converter ConvertTo function would convert to a rounded string as you require.
2. Use a different editor control such as the standard NumericUpDown control that supports setting the format string. _________________ Infralution Support |
|
Back to top |
|
|
keesp Guest
|
Posted: Tue Aug 30, 2005 9:42 am Post subject: using typedescriptors in cell data |
|
|
Could it be possible to associate the custom type converter with the type converter property of the CellData? I have tried to influence the value of the universal editbox by applying a format to this value, but this results in a popup box that the value is 'not a valid string value' (which seems strange as string values should be pretty robust).
The problem is, that I need to be able to scan through all kinds of properties and fill in the correct format when needed. In a property grid, I can do this by creating property descriptors for each property and apply the formatting there. I take it that there is no equivalent for the universal text box, unless they too can handle property descriptors?
Thanks,
Kees |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Aug 30, 2005 10:33 am Post subject: |
|
|
If you set the TypeConverter property of the CellData to a custom TypeConverter it is passed to the UniversalEditBox editor for the cell (and used to convert the string value to a value).
If you are having problems with this try putting a UniversalEditBox on a form and testing it there by programatically setting the TypeConverter property. Sounds like your type converter is not quite right. If you want to send a sample project we can take a look for you. _________________ Infralution Support |
|
Back to top |
|
|
keesp Guest
|
Posted: Wed Oct 05, 2005 12:24 pm Post subject: A different solution |
|
|
Hi,
I have currently solved the formatting issue by creating a new universal textbox, derived from the standard one, and adding the formatting data to this textbox to set the TextBox.Text property. This works fine, except upon initial use.
In my cellbinding I perform a cellData.Editor = myFormatEditor
and then continue with a celldata.Value = someObject.Value.
I had thought that if I override the OnValueChanged method of the universaltextbox, that I could perform the formatting there, but apparently the textbox text is set at a later stage, so the default representation is shown. Which would be the best event to apply the format?
Thanks
Kees |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Oct 05, 2005 11:24 pm Post subject: |
|
|
Try overriding the GetTextForValue method. _________________ Infralution Support |
|
Back to top |
|
|
|