Click here to Skip to main content
15,898,020 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Questioncannot convert from 'System::Data::DataSet ^' to 'System::Data::DataSet error Pin
m_mun31-Mar-10 0:31
m_mun31-Mar-10 0:31 
AnswerRe: cannot convert from 'System::Data::DataSet ^' to 'System::Data::DataSet error Pin
Andreoli Carlo31-Mar-10 3:34
professionalAndreoli Carlo31-Mar-10 3:34 
GeneralRe: cannot convert from 'System::Data::DataSet ^' to 'System::Data::DataSet error Pin
m_mun31-Mar-10 5:37
m_mun31-Mar-10 5:37 
QuestionSide-by-side configuration errors Pin
Lucidation30-Mar-10 10:21
Lucidation30-Mar-10 10:21 
AnswerRe: Side-by-side configuration errors Pin
Andreoli Carlo30-Mar-10 20:33
professionalAndreoli Carlo30-Mar-10 20:33 
GeneralRe: Side-by-side configuration errors Pin
Lucidation31-Mar-10 7:17
Lucidation31-Mar-10 7:17 
GeneralRe: Side-by-side configuration errors Pin
dybs3-Apr-10 18:06
dybs3-Apr-10 18:06 
QuestionExpandable Property in Win Forms Property Grid Pin
zeos626-Mar-10 12:04
zeos626-Mar-10 12:04 
Hi ,

I am new to VC++/CLI and have been struggling with creating an expandable property in the property grid. I can create an expandbale property with an ExpabdableObjectConverter and I can even customize its vaklue field by overriding the ToString() method but where I run into problems is with TypeConverter. I want to create a simple expandable property, say Person, that has subproperties LastName, FirstName and ID - ID is an int. I can't seem to understand if I need CanConvertFrom, ConvertFrom, CanConvertTo and ConvertTo. I am finding TypeConverter very difficult and would appreciate any help you may be able to provide. Would anyone kindly direct me to some info or an example on how to do this? Thank you very much in advance.
Regards,
Paul

The code I have so far is

ref class CustomPersonConverter;

[TypeConverter(CustomPersonConverter::typeid)]
ref class CustomPerson {
private:
String^ _FirstName;
String^ _LastName;
int _ID;

public:
CustomPerson(void) {}

[DisplayName("Person's first name")]
[Description("First Name"), Category("rcGroupBox Custom Parameters")]
[System::ComponentModel::NotifyParentProperty(true)]
property String^ FirstName {
String^ get() {return _FirstName;}
void set(String^ new_FirstName) {_FirstName=new_FirstName;}
}

[Description("Last Name"), Category("rcGroupBox Custom Parameters")]
[System::ComponentModel::NotifyParentProperty(true)]
property String^ LastName {
String^ get() {return _LastName;}
void set(String^ new_LastName) {_LastName=new_LastName;}
}

[Description("ID"), Category("rcGroupBox Custom Parameters")]
[System::ComponentModel::NotifyParentProperty(true)]
property int ID {
int get() {return _ID;}
void set(int new_ID) {_ID=new_ID;}
}

[System::Security::Permissions::PermissionSet(System::Security::
Permissions::SecurityAction::Demand, Name = "FullTrust")]
ref class CustomPersonConverter : public TypeConverter {
public:

virtual bool GetPropertiesSupported(ITypeDescriptorContext^ context) override {
return true;
}

virtual PropertyDescriptorCollection^ GetProperties(ITypeDescriptorContext^
context, Object^ value, array<Attribute^>^ attributes) override
{
return TypeDescriptor::GetProperties(CustomPerson::typeid);
}

virtual bool CanConvertFrom(ITypeDescriptorContext^ context, Type^ sourceType)
override {
if ( sourceType == String::typeid | sourceType == InstanceDescriptor::typeid )
{
return true;
}

return TypeConverter::CanConvertFrom( context, sourceType );
}

virtual bool CanConvertTo( ITypeDescriptorContext^ context, Type^
destinationType ) override {
if ( destinationType == String::typeid | destinationType ==
InstanceDescriptor::typeid )
{
return true;
}

return TypeConverter::CanConvertTo( context, destinationType );
}

/* This code performs the actual conversion from a Person to an InstanceDescriptor. */
virtual Object^ ConvertTo( ITypeDescriptorContext^ context, CultureInfo^ culture,
Object^ value, Type^ destinationType ) override {
if ( destinationType == InstanceDescriptor::typeid )
{
return;
}
return TypeConverter::ConvertTo( context, culture, value, destinationType );

}
};
};
QuestionWhat is this message telling me? Pin
Bert Fegyverneki26-Mar-10 6:00
Bert Fegyverneki26-Mar-10 6:00 
AnswerRe: What is this message telling me? Pin
Ghydo26-Mar-10 7:34
Ghydo26-Mar-10 7:34 
GeneralRe: What is this message telling me? Pin
Bert Fegyverneki26-Mar-10 9:22
Bert Fegyverneki26-Mar-10 9:22 
GeneralRe: What is this message telling me? Pin
Ghydo26-Mar-10 10:25
Ghydo26-Mar-10 10:25 
QuestionDisplay current time in Label control Pin
Lucidation26-Mar-10 5:30
Lucidation26-Mar-10 5:30 
AnswerRe: Display current time in Label control Pin
Luc Pattyn26-Mar-10 5:54
sitebuilderLuc Pattyn26-Mar-10 5:54 
GeneralRe: Display current time in Label control Pin
Lucidation26-Mar-10 6:28
Lucidation26-Mar-10 6:28 
GeneralRe: Display current time in Label control Pin
Luc Pattyn26-Mar-10 6:44
sitebuilderLuc Pattyn26-Mar-10 6:44 
GeneralRe: Display current time in Label control Pin
Lucidation26-Mar-10 7:07
Lucidation26-Mar-10 7:07 
GeneralRe: Display current time in Label control Pin
Ghydo26-Mar-10 7:37
Ghydo26-Mar-10 7:37 
GeneralRe: Display current time in Label control Pin
Lucidation26-Mar-10 7:44
Lucidation26-Mar-10 7:44 
QuestionChange text color Pin
jashimu25-Mar-10 4:14
jashimu25-Mar-10 4:14 
AnswerRe: Change text color Pin
Andreoli Carlo25-Mar-10 6:01
professionalAndreoli Carlo25-Mar-10 6:01 
AnswerRe: Change text color Pin
Richard MacCutchan25-Mar-10 6:01
mveRichard MacCutchan25-Mar-10 6:01 
QuestionWindows XP Problems since updating from VS2005 to VS2008 Pin
Joschwenk66623-Mar-10 11:07
Joschwenk66623-Mar-10 11:07 
AnswerRe: Windows XP Problems since updating from VS2005 to VS2008 Pin
T210224-Mar-10 19:18
T210224-Mar-10 19:18 
QuestionProblem : Converting a System::String^ to char[512] Pin
vidasco18-Mar-10 1:07
vidasco18-Mar-10 1:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.