View previous topic :: View next topic |
Author |
Message |
Harri Guest
|
Posted: Tue May 10, 2005 11:24 am Post subject: Cannot edit using UniversalEditBox |
|
|
Hello Support,
Im trying to get the UniversalEditBox to work as editor for my cell(-values). When I use a normal textbox as control all works fine (all value's are editied as strings). Using an UniversalEditBox however, I cannot edit my cell-values at all: the value in the cell is displayed and selected when I click on it but it does not react on any user-input (key-strokes).
The following code shows what I do (I don't use the 'Edit Virtual Tree'-designer functionality):
Code: |
// In the InitializeComponent() of a derived class from VirtualTree :
// Using a textbox, editing works
// this._cellEditorControl = new TextBox();
// Using a UniversalEditBox, editing does not work yet
this._cellEditorControl = new Infralution.Controls.UniversalEditBox();
this._cellEditorControl.Location = new System.Drawing.Point(0, 0);
this._cellEditorControl.Name = "_cellEditorControl";
this._cellEditorControl.Size = new System.Drawing.Size(195, 24);
this._cellEditorControl.TabIndex = 0;
this._cellEditorControl.TabStop = false;
this._cellEditor = new CellEditor(this._cellEditorControl);
this._cellEditor.DisplayMode = CellEditorDisplayMode.Always;
// CellBinding: object.Value<->Value column
ObjectCellBinding valueExceptionCellBinding = new ObjectCellBinding();
valueExceptionCellBinding.Column = this._columnValue;
valueExceptionCellBinding.Field = "Value";
// Set the editor for this cellbinding
valueExceptionCellBinding.Editor = this._cellEditor;
|
I'm sure I must be missing something but I cannot find out what.
Can you help me out?
Thank you in advance
Harri |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue May 10, 2005 10:47 pm Post subject: |
|
|
What is the type of the object you are displaying in the cell? The UniversalEditBox uses the TypeConverter associated with the type to determine how to display values and convert strings back to typed values - if there is no TypeConverter or the TypeConverter does not support conversion from string then you won't be able to edit the value. If it is your own type you can define a TypeConverter and associate it with the type using the TypeConverter attribute.
Try puting a UniversalEditBox on a form and setting the UniversalEditBox value directly to the type you want to edit to check out the behaviour. _________________ Infralution Support |
|
Back to top |
|
|
Harri Guest
|
Posted: Wed May 11, 2005 2:31 pm Post subject: |
|
|
Thank you for your suggestions.
The property to which the cellBinding binds is the "Value"-property.
This "value"-property is defined in an interface and is of the type object.
Several classes implement this interface; the actual Value can be anything (depending on the class that implements the interface, e.g. integer, double, boolean, array, object... etc)
I've discovered that if the cellbinding binds to a property that is of the type object, the UniversalEditBox does not let me to edit the values. As soon as I bind to a 'strongly-typed' property (i.e. string or int...) of the type object, I can edit the value.
I guess I need to derive from ObjectCellBinding, and override the GetCellData; in here I should set the cellData.TypeConverter ?
Thank you in advance,
Harri |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed May 11, 2005 10:39 pm Post subject: |
|
|
Yes that's probably the solution. Because the property is not strongly typed the ObjectCellBinding cannot set the TypeConverter property of the CellData and so the UniversalEditBox does not know how to edit the values. _________________ Infralution Support |
|
Back to top |
|
|
|