all groups > dotnet windows forms > february 2005 >
You're in the

dotnet windows forms

group:

specified cast is not valid.


specified cast is not valid. Ansari
2/14/2005 11:12:43 AM
dotnet windows forms:
hi all,

I have a windows application which is developed in VB.NET.
I have used some bitmaps and set image property of button.
Some time I load form programmaticaly.. following error pops up

1) Specified Cast is not valid
it is on the following line of code.
Me.Button1.Image = CType(resources.GetObject("Button1.Image"),
System.Drawing.Bitmap).

To sovle this problem I CUT the button and paste it again and save project
next time i run it work fine....

What is the problem?



Ansari

RE: specified cast is not valid. Phil Williams
2/15/2005 7:51:02 AM
Ansari,
Do you enable XP styles? If you do, check you have called DoEvents(). In
C#, something like this:

static void Main()
{
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new MainForm());
}

Regards,
Phil.

[quoted text, click to view]
AddThis Social Bookmark Button