本帖最后由 bulls5988 于 2011-11-09 10:48:06 编辑

解决方案 »

  1.   

    public DataGridView userlist_load(DataGridView u_data)
    {
    ....
    }
    这里面问题。
    这种NullReference问题,他提示你的地方设个断点调试就知道!
      

  2.   

    这个填充DGV和保存修改数据 都没问题。都不会报错,只有这个刷新窗体才保存
      

  3.   

     这个填充DGV和保存修改数据 都没问题。都不会报错,只有这个刷新窗体才报错
      

  4.   

    你在其它地方调用窗体的load事件处理函数?那个事件没有触发,那当然是null值。引用肯定出错啊。
      

  5.   

    你应该调用refresh.formload()而不是refresh.form_load()吧
      

  6.   


    并不是这样的,我这样写,public void form_load()
            {
                m_userlist users = new m_userlist();
                users.userlist_load(d_userlist);
            }也照样是提示: 未处理 System.NullReferenceException
      Message="未将对象引用设置到对象的实例。"
      Source="中影会员卡"
      StackTrace:
           在 中影会员卡.m_useredit.b_save_Click(Object sender, EventArgs e) 位置 C:\middlemovie\中影会员卡\m_useredit.cs:行号 172
           在 System.Windows.Forms.Control.OnClick(EventArgs e)
           在 System.Windows.Forms.Button.OnClick(EventArgs e)
           在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           在 System.Windows.Forms.Control.WndProc(Message& m)
           在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
           在 System.Windows.Forms.Button.WndProc(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
           在 System.Windows.Forms.Form.ShowDialog()
           在 中影会员卡.m_usermange.b_edit_Click(Object sender, EventArgs e) 位置 C:\middlemovie\中影会员卡\m_usermange.cs:行号 51
           在 System.Windows.Forms.Control.OnClick(EventArgs e)
           在 System.Windows.Forms.Button.OnClick(EventArgs e)
           在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           在 System.Windows.Forms.Control.WndProc(Message& m)
           在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
           在 System.Windows.Forms.Button.WndProc(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Application.Run(Form mainForm)
           在 中影会员卡.Program.Main() 位置 C:\middlemovie\中影会员卡\Program.cs:行号 29
           在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           在 System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
      

  7.   

    找到啦,调用时少了:edit.Owner = this;
      

  8.   

    我说的是你在m_useredit.cs中应该调用refresh.formload()而不是refresh.form_load()。你在m_usermange.cs中把
    public void form_load()
            {
                formload();
            }
    改成
    public void form_load()
      {
      m_userlist users = new m_userlist();
      users.userlist_load(d_userlist);
      }
    那不是跟没改一样么。关键是你在m_useredit.cs中不能调用m_usermange.cs中的load事件处理函数