Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Casting errors should be caught during compiling, right?
Message
De
21/11/2004 17:31:41
 
 
À
21/11/2004 16:25:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Divers
Thread ID:
00963257
Message ID:
00963362
Vues:
7
Cetin,

It looks to me like this is happening when you get to the point in the grid when you're adding a new row. Everything is NULL and this sample code is obviously not doing any kind of special handling for NULLs. That's where the error message is coming from. NULLs can be a real pain sometime, but they are a special case that need special handling.

~~Bonnie



>>Cetin,
>>
>>I haven't run the code sample ... which part of it is the part that you're questioning?
>>
>>UPDATE: Now I *have* run the sample code. There are no errors when it's run. What problem did you have with it?
>>
>>~~Bonnie
>>
>>>Type safety and casting as I thought are closely coupled and if a type can't be casted to another type it should be caught during compilation. Or to put it another way could a method return some other type than what it's instructed to do?
>>>To reproduce what I mean try MSDN code sample under:
>>>System.Windows.Forms\Binding class
>>>Cetin
>
>Bonnie,
>Wrong sample. Search using "datetimepicker datagrid". It'd be listed 2nd with a datetipicker control in datagrid sample. Run it and soon you'd get:
>
>
>System.InvalidCastException: Specified cast is not valid.
>   at DataGridTimePickerColumn.Edit(CurrencyManager source, Int32 rowNum, Rectangle bounds, Boolean readOnly, String instantText, Boolean cellIsVisible)
>   at System.Windows.Forms.DataGrid.Edit(String instantText)
>   at System.Windows.Forms.DataGrid.Edit()
>   at System.Windows.Forms.DataGrid.set_CurrentCell(DataGridCell value)
>   at System.Windows.Forms.DataGrid.set_CurrentRow(Int32 value)
>   at System.Windows.Forms.DataGrid.ProcessGridKey(KeyEventArgs ke)
>   at System.Windows.Forms.DataGrid.ProcessKeyPreview(Message& m)
>   at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
>   at System.Windows.Forms.Control.WmKeyChar(Message& m)
>   at System.Windows.Forms.Control.WndProc(Message& m)
>   at System.Windows.Forms.DateTimePicker.WndProc(Message& m)
>   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
>   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
>   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
>
>PS: Casting to object is special case and not the thing here. It doesn't occur if you use only mouse.
>Cetin
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform