|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error changing Icon for ErrorProviderWhen I do so and call SetError(thisControl, "msg") I receive an IndexOutOfRangeException. Code snippet: .... Assembly _assembly = Assembly.GetExecutingAssembly(); Stream _icon = _assembly.GetManifestResourceStream("MyNameSpace.checkmark.ico"); thisErrorProvider.Icon = new Icon(_icon); thisErrorProvider.SetError(thisControl, "Checked"); .... To cover the obvious, yes, the Build Action Property of checkmark.ico is Embedded Resource. Here is the exception stacktrace: System.IndexOutOfRangeException was unhandled Message="Index was outside the bounds of the array." Source="System.Windows.Forms" StackTrace: at System.Windows.Forms.ErrorProvider.IconRegion.get_Region() at System.Windows.Forms.ErrorProvider.ErrorWindow.Update(Boolean timerCaused) at System.Windows.Forms.ErrorProvider.ErrorWindow.Add(ControlItem item) at System.Windows.Forms.ErrorProvider.ControlItem.AddToWindow() at System.Windows.Forms.ErrorProvider.ControlItem.set_Error(String value) at System.Windows.Forms.ErrorProvider.SetError(Control control, String value) .... I'm digging through msdn now. Any advice is appreciated. Many Thanks, Eric For anyone interested, I found the problem. The default icon is 16x16
pixels, but checkmark.ico was 14x14. Recreating the checkmark.ico at 16x16 resolved the problem. Cheers. On May 10, 11:24 am, Eric <erickeph***@gmail.com> wrote: Show quote > I am attempting to change at runtime the Icon for an ErrorProvider. > When I do so and call SetError(thisControl, "msg") I receive an > IndexOutOfRangeException. > > Code snippet: > ... > Assembly _assembly = Assembly.GetExecutingAssembly(); > Stream _icon = > _assembly.GetManifestResourceStream("MyNameSpace.checkmark.ico"); > thisErrorProvider.Icon = new Icon(_icon); > thisErrorProvider.SetError(thisControl, "Checked"); > ... > > To cover the obvious, yes, the Build Action Property of checkmark.ico > is Embedded Resource. > > Here is the exception stacktrace: > System.IndexOutOfRangeException was unhandled > Message="Index was outside the bounds of the array." > Source="System.Windows.Forms" > StackTrace: > at System.Windows.Forms.ErrorProvider.IconRegion.get_Region() > at > System.Windows.Forms.ErrorProvider.ErrorWindow.Update(Boolean > timerCaused) > at > System.Windows.Forms.ErrorProvider.ErrorWindow.Add(ControlItem item) > at System.Windows.Forms.ErrorProvider.ControlItem.AddToWindow() > at > System.Windows.Forms.ErrorProvider.ControlItem.set_Error(String value) > at System.Windows.Forms.ErrorProvider.SetError(Control control, > String value) > ... > > I'm digging through msdn now. Any advice is appreciated. > > Many Thanks, > Eric |
|||||||||||||||||||||||