Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TypeConverter.GetStandardValues

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
Matthys



Joined: 23 Nov 2007
Posts: 4

PostPosted: Fri Nov 23, 2007 12:51 pm    Post subject: TypeConverter.GetStandardValues Reply with quote

Hello,

I am implementing a TypeConverter to use in VirtualTree.

In my TypeConverter I override ,

Code:
 StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)


, however when VirtualTree calls the GetStandardValues() method in my TypeConverter the context variable is received as 'null'.

This is not what I expect to happen, since I would like to return standard values based on the Instance of the value I am converting/editing.

Is it correct to receive the context as a 'null' value?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Nov 23, 2007 9:55 pm    Post subject: Reply with quote

If you look at the MSDN documentation for TypeConverter.GetStandardValues you will see it says the following:

Quote:
context
An ITypeDescriptorContext that provides a format context that can be used to extract additional information about the environment from which this converter is invoked. This parameter or properties of this parameter can be a null reference (Nothing in Visual Basic).


Currently the UniversalEditBox calls the overloaded parameterless version of TypeConverter.GetStandardValues() - which calls the method you are overriding with null for the context parameter to indicate the default context should be used.

So if the list of values you wish to display is not constant then you may need to look at an alternative approach. I can see two possibilities:

The first is to use a standard combo box and set the DataSource programmatically (see other threads on this forum about using combo boxes as editors).

The second is to provide a constructor for your custom TypeConverter that takes some parameter (for instance the column) that determines the StandardValues that will be returned. Then handle the GetCellData event to programmatically set the CellData.TypeConverter eg

Code:
private void _virtualTree_GetCellData(object sender, GetCellDataEventArgs e)
{
    // get the default binding for the given row and use it to populate the cell data
    //
    RowBinding binding = _virtualTree.GetRowBinding(e.Row);
    binding.GetCellData(e.Row, e.Column, e.CellData);

    if (e.CellData.Value is MyType)
    {
         e.CellData.TypeConverter = new MyTypeConverter(e.Column);
    }   
}

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Matthys



Joined: 23 Nov 2007
Posts: 4

PostPosted: Mon Nov 26, 2007 7:27 am    Post subject: Reply with quote

Thank you very much.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
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