|
Infralution Support Support groups for Infralution products
|
View previous topic :: View next topic |
Author |
Message |
Jimmy Guest
|
Posted: Fri Dec 09, 2005 9:33 am Post subject: CustomTypeEditor |
|
|
Guys,
Trying to use the CustomTypeEditor example to use progamitic data binding..
ie.)
private void _virtualTree_GetCellData(object sender, GetCellDataEventArgs e)
{
Part part = e.Row.Item as Part;
if (e.Column == this.colMain)
{
e.CellData.Value = part.Name;
}
if (e.Column == this.colStockLevel)
{
e.CellData.Value = part.StockLevel;
e.CellData.Editor = this._stockEditor;
e.CellData.DrawPreviewBorder = false;
e.CellData.ShowPreview = true;
e.CellData.ShowText = false;
}
}
However I am not having any luck in getting this to work. Can you explain what I am doing wrong, as I do not understand how when you declare as a CellEditor..
private Infralution.Controls.VirtualTree.CellEditor _stockEditor;
that it acutally uses the StockLevelEditor : UITypeEditor class. Where is the 'association' made..
Hope the above question is clear.. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Dec 09, 2005 10:51 am Post subject: |
|
|
I assume you have set up the _stockEditor as it was in the sample project to use the UniversalEditBox as the control to edit. You can check this by looking in the VirtualTree editor at the Editors.
The UniversalEditBox can use the standard UITypeEditor associated with a property or type to perform editing on it. When you use Object Bindings (as the sample project does) they automatically pass the UITypeEditor associated with the Part.StockLevel property (using the Editor attribute) to the UniversalEditBox via the CellData by setting the CellData.TypeEditor property. Since you are doing this programatically you will have to set
Code: | e.CellData.TypeEditor = new StockLevelEditor(); |
when setting the other cell data properties. _________________ Infralution Support |
|
Back to top |
|
|
Jimmy Guest
|
Posted: Mon Dec 12, 2005 10:30 am Post subject: CustomTypeEditor |
|
|
Thanks for that guys,
I have changed the MainForm
private void _virtualTree_GetCellData(object sender, GetCellDataEventArgs e)
{
if (e.Row.Item is ProductSupplier)
{
if (e.Column == this.colMain)
{
ProductSupplier obj = (ProductSupplier)e.Row.Item;
e.CellData.Value = obj.Supplier;
e.CellData.Editor = this._stockEditor;
e.CellData.TypeEditor = new StockLevelEditor();
e.CellData.DrawPreviewBorder = false;
e.CellData.ShowPreview = true;
e.CellData.ShowText = true;
}
}
}
I currently have the StockLevelForm appearing now once I click on the cell I wish to edit.(I have modified this StockLevelForm which contains a VirtualTee of 'Suppliers'. When I select a 'Supplier' and close this form (ok button) I return the 'checked Supplier' to the MainForm...
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService editorService;
editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
StockLevelForm form = new StockLevelForm();
form.Supplier = context.Instance as Supplier;
editorService.ShowDialog(form);
if (form.DialogResult == DialogResult.OK)
return (Supplier)form.SupplierTree.CheckedSuppliers[0];
return value;
}
In the Mainfom the 'Supplier' now appears in the cell I edited..However when I click on another cell, the cell I just edited reverts back to its original value...
The only other code that I have changed from the original example was in the PaintValue Method of the StockLevelEditor class, as follows..
public override void PaintValue(PaintValueEventArgs e)
{
Rectangle barBounds = e.Bounds;
barBounds.X += 3;
barBounds.Y += 3;
barBounds.Width -= 6;
barBounds.Height -= 6;
if (_theme.Supported)
{
_theme.DrawThemeBackground(e.Graphics, e.Bounds, (int)XpTheme.ProgressParts.Bar, 0);
_theme.DrawThemeBackground(e.Graphics, barBounds, (int)XpTheme.ProgressParts.Chunk, 0);
}
else
{
e.Graphics.DrawRectangle(Pens.Black, e.Bounds);
e.Graphics.FillRectangle(Brushes.Blue, barBounds);
}
}
Any idea what I need to do to get the above to function correctly.. If you require any further clarification on the above please let me know.. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Dec 12, 2005 9:57 pm Post subject: |
|
|
Since you are handling the binding yourself programmatically you will also need to handle the SetCellValue event to change the value in the your data source when the user makes a change. _________________ Infralution Support |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|