Question

After adding a UserControl to Picture Edit control of DevExpress, i was able to successfully place it over a location and save the changes.

After reopening the application, when i populate the PictureEdit with the image and then add the UserControl to pictureEdit controls collection, error image is displayed in the PictureEdit along with message "Object Reference not set to instance of an object" -> null reference.

System.NullReferenceException: Object reference not set to an instance of an object.
   at DevExpress.XtraEditors.PictureEditScrollers.SetScrollBarValues()
   at DevExpress.XtraEditors.PictureEditScrollers.DisplayScrollBars()
   at DevExpress.XtraEditors.PictureEditScrollers.TryDisplayScrollBars(Boolean force)
   at DevExpress.XtraEditors.PictureEdit.UpdateViewInfo(Graphics g)
   at DevExpress.XtraEditors.BaseControl.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.Control.PaintTransparentBackground(PaintEventArgs e, Rectangle rectangle, Region transparentRegion)
   at System.Windows.Forms.Control.PaintTransparentBackground(PaintEventArgs e, Rectangle rectangle)
   at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor, Point scrollOffset)
   at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle)
   at System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent)
   at System.Windows.Forms.ScrollableControl.OnPaintBackground(PaintEventArgs e)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   at System.Windows.Forms.Control.WmEraseBkgnd(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

But if I ndo not add UserControl to controls collection the the image is displayed perfectly but then i am missing my user control over the PictureEdit.

Any suggesstions?

Était-ce utile?

La solution

Just in case helpful to others:

Force create your control.

picEdit.CreateControl();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top