zoukankan      html  css  js  c++  java
  • Datawindow.net 子数据窗口出错

    devexpress通过标签页面打开用户控件,数据窗口嵌入用户控件中。当点击数据窗口含下拉数据窗口字段时出现如下错误:

    未处理 System.NullReferenceException

    Message="未将对象引用设置到对象的实例。"
    Source="DataWindowInterop"
    StackTrace:
    在 DataWindowInterop.DW_Events.CatchNotify(Int32 given_HWND, UInt32 Message, UInt32 wParam, Int32 lParam, Void* VM_Object)
    在 System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
    在 System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
    在 System.Windows.Forms.Control.DefWndProc(Message& m)
    在 System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
    在 System.Windows.Forms.Control.WndProc(Message& m)
    在 Sybase.DataWindow.DataWindowControl.WndProc(Message& msg)

    分析可能原因:

    (1) 可能是子数据窗口找不到窗口句柄导致出错。

    (2) 数据窗口taborder第一个的字段带有子数据窗口。

    解决方法:继承Sybase.DataWindow.DataWindowControl,覆盖重写WndProc并捕捉异常,让错误不再传递到数据窗口控件外层。

    补充:

    经过多次不断测试及代码排查终于发现问题所在:

    原来是数据窗口的ItemFocusChanged引发的System.NullReferenceException异常。

    private void dwCard_ItemFocusChanged(object sender, ItemFocusChangedEventArgs e)
    {
    string colname = e.ColumnName.ToUpper();

    dwCard.CurrentEdit.SelectText(0, (short)(dwCard.CurrentEdit.TextLength)); //选择已有的数据

    }

    如果第一个字段是带下拉数据窗口就会出现如下异常:

    dwCard.CurrentEdit.TextLength = “dwCard.CurrentEdit.TextLength”引发了“System.NullReferenceException”类型的异常

  • 相关阅读:
    mysql查看所有触发器以及存储过程等操作集合【转】
    Hutool之Http工具类使用
    SpringCloud之Sentinel
    SpringCloud之Gateway
    com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
    [AWS DA Guru] SQS
    [AWS DA Guru] Kinesis
    [AWS DA Guru] SNS & SES
    [Typescript] Prevent Type Widening of Object Literals with TypeScript's const Assertions
    [AWS] Updating Elastic Beans Talks & RDS
  • 原文地址:https://www.cnblogs.com/janehlp/p/4927715.html
Copyright © 2011-2022 走看看