将UserControl添加到DevExpress的图片编辑控件后,我能够成功将其放在某个位置并保存更改。
重新打开应用程序后,当我使用图像填充PictureEdit然后将UserControl添加到pictureEdit控件集合时,错误图像将显示在PictureEdit中,同时显示消息“对象引用未设置为对象的实例” - > 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)
但是,如果我没有将UserControl添加到控件集合中,则图像会完美显示,但我失去了对PictureEdit的用户控制权。
任何建议?
答案 0 :(得分:1)
以防万一对别人有帮助:
强制创建你的控件。
picEdit.CreateControl();