Click here to Skip to main content
15,887,474 members
Home / Discussions / C#
   

C#

 
GeneralRe: Mysterious error dialog on exit.... Pin
alexey N24-Apr-06 18:23
alexey N24-Apr-06 18:23 
AnswerRe: Mysterious error dialog on exit.... Pin
alexey N24-Apr-06 18:32
alexey N24-Apr-06 18:32 
GeneralRe: Mysterious error dialog on exit.... Pin
CherezZaboro25-Apr-06 8:54
CherezZaboro25-Apr-06 8:54 
Questionhow create a xor bar? Pin
Susuko24-Apr-06 7:31
Susuko24-Apr-06 7:31 
AnswerRe: how create a xor bar? Pin
Josh Smith24-Apr-06 7:36
Josh Smith24-Apr-06 7:36 
GeneralRe: how create a xor bar? Pin
Susuko24-Apr-06 9:00
Susuko24-Apr-06 9:00 
GeneralRe: how create a xor bar? Pin
Josh Smith24-Apr-06 9:13
Josh Smith24-Apr-06 9:13 
QuestionUnable to cast object of type 'X' to type 'X' Pin
Pink Floyd24-Apr-06 6:46
Pink Floyd24-Apr-06 6:46 
Hi and THANKS a lot in advance.

I'm getting this error in a different scenario, and I'm in a big urge to get this done, so please MS people and guys of the forum, any help is greatly appreciated.

I'll use a simplified scenario of my case, but the error happens the same. I'm creating a new User Control, I add a DataGridView to it, that's the only control in it. I then create a public property called "Columns" to expose the DataGridView Columns property so I can access the property to the Designer Editor. I do that this way:

namespace WindowsApplication3
{
public partial class myUC : UserControl
{
public myUC()
{
InitializeComponent();
}

[Editor("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[MergableProperty(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DataGridViewColumnCollection Columns
{
get { return this.dataGridView1.Columns; }
}
}
}


I took all that Attributes code from the System.Windows.Forms.DataGridView metadata, just as the Columns property appears in it.

Then, I add a Windows Forms item to my application and drag&drop one MyUC control from the toolbox into it. Then I click the MyUC and go to its properties page to modify the Columns properties just as with an ordinary DataGridView. The property is there but when clicking on its "..." button to open de Edit Columns Dialog I get the mentioned error. Something like this:

"Unable to cast object of type 'WindowsApplication3.myUC" to type "System.Windows.Forms.DataGridView".

I really really need the Columns property to be accesible in Design Time this way. I don't know how to work this out.

As I said, I get this error with an almost blank project. Just add a User Control Item, put a DataGridView into it. Ade the code above to make the Columns property visible and then try to access the property in the Property page.

Thank you so much in advance.

F.

PD: I'm using the shipped VS.NET 2005.


-- modified at 12:47 Monday 24th April, 2006
AnswerRe: Unable to cast object of type 'X' to type 'X' Pin
Josh Smith24-Apr-06 7:04
Josh Smith24-Apr-06 7:04 
GeneralRe: Unable to cast object of type 'X' to type 'X' Pin
Pink Floyd24-Apr-06 8:10
Pink Floyd24-Apr-06 8:10 
GeneralRe: Unable to cast object of type 'X' to type 'X' Pin
Josh Smith24-Apr-06 8:37
Josh Smith24-Apr-06 8:37 
GeneralRe: Unable to cast object of type 'X' to type 'X' Pin
Pink Floyd24-Apr-06 10:38
Pink Floyd24-Apr-06 10:38 
GeneralRe: Unable to cast object of type 'X' to type 'X' Pin
Josh Smith24-Apr-06 14:56
Josh Smith24-Apr-06 14:56 
GeneralRe: Unable to cast object of type 'X' to type 'X' Pin
Pink Floyd25-Apr-06 7:04
Pink Floyd25-Apr-06 7:04 
GeneralRe: Unable to cast object of type 'X' to type 'X' Pin
Pink Floyd25-Apr-06 9:52
Pink Floyd25-Apr-06 9:52 
QuestionApplication Servers compared to Middlewares Pin
Den2Fly24-Apr-06 6:16
Den2Fly24-Apr-06 6:16 
AnswerRe: Application Servers compared to Middlewares Pin
J4amieC24-Apr-06 7:41
J4amieC24-Apr-06 7:41 
GeneralRe: Application Servers compared to Middlewares Pin
Den2Fly24-Apr-06 11:04
Den2Fly24-Apr-06 11:04 
Questione-mail through with Outlook Redemption library... Pin
Vasya - dragon24-Apr-06 5:19
Vasya - dragon24-Apr-06 5:19 
AnswerRe: e-mail through with Outlook Redemption library... Pin
Aaron Dilliard25-Apr-06 4:06
Aaron Dilliard25-Apr-06 4:06 
GeneralRe: e-mail through with Outlook Redemption library... Pin
Vasya - dragon25-Apr-06 11:07
Vasya - dragon25-Apr-06 11:07 
QuestionVar Scope Pin
Ashraf zia24-Apr-06 4:55
Ashraf zia24-Apr-06 4:55 
AnswerRe: Var Scope Pin
Rob Philpott24-Apr-06 5:26
Rob Philpott24-Apr-06 5:26 
AnswerRe: Var Scope Pin
Guffa24-Apr-06 6:04
Guffa24-Apr-06 6:04 
QuestionReacting on MDI parent menu click Pin
Denis Shamanin24-Apr-06 4:54
Denis Shamanin24-Apr-06 4:54 

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.