奇怪了,
我这样
private void button2_Click(object sender, System.EventArgs e)
{
this.dataGrid1.TableStyles["Date_Bill"].GridColumnStyles[0].Width = 0;
}保存表名:Date_Bill是没错的啊。
出错信息为:未将对象引用到实例:有关调用实时(JIT)调试而不是此对话框的详细信息,
请参阅此消息的结尾。************** 异常文本 **************
System.NullReferenceException: 未将对象引用设置到对象的实例。
   at OA.LOG.button2_Click(Object sender, EventArgs e) in f:\liang\oa\log.cs:line 290
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** 已加载的程序集 **************
mscorlib
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
OA
    程序集版本: 1.0.1579.25376
    Win32 版本: 1.0.1579.25376
    基本代码: file:///F:/liang/OA/bin/Debug/OA.exe
----------------------------------------
System.Windows.Forms
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Data
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
System.Xml
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
Accessibility
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------
mscorlib.resources
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/assembly/gac/mscorlib.resources/1.0.5000.0_zh-chs_b77a5c561934e089/mscorlib.resources.dll
----------------------------------------
System.Windows.Forms.resources
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/assembly/gac/system.windows.forms.resources/1.0.5000.0_zh-chs_b77a5c561934e089/system.windows.forms.resources.dll
----------------------------------------
System.resources
    程序集版本: 1.0.5000.0
    Win32 版本: 1.1.4322.573
    基本代码: file:///c:/windows/assembly/gac/system.resources/1.0.5000.0_zh-chs_b77a5c561934e089/system.resources.dll
----------------------------------------************** JIT 调试 **************
计算机的配置文件(machine.config)的 
 system.windows.forms 节中必须设置 jitDebugging 值。
编译应用程序时还必须启用\r\n调试。\r\n\r\n例如: \r\n\r\n<configuration>\r\n    <system.windows.forms jitDebugging="true" />\r\n</configuration>\r\n\r\n启用 JIT 调试后,任何未处理的异常\r\n都将被发送到此计算机上注册的 JIT 调试器,\r\n而不是由此对话框处理。\r\n

解决方案 »

  1.   

    这1点我要了 :)
    你设置DataGridColumnStyle给DataGrid就可以.你上面的代码没有影射到DataGrid的列.
      

  2.   

    runnercn() 
    不明白啊,如何做?
      

  3.   


    你设置DataGridColumnStyle给DataGrid就可以.你上面的代码没有影射到DataGrid的列.
    是什么意思?快些回答我好吗?谢谢你了。
      

  4.   

    你设置DataGridColumnStyle给DataGrid就可以.你上面的代码没有影射到DataGrid的列.
    是什么意思?快些回答我好吗?谢谢你了。
      

  5.   


    DataGrid1.Columns[1].Visiabled=false;