不会吧,只要指定了DataSource,不用做任何设置也会出来的

解决方案 »

  1.   

    这个窗体是子窗体,我是在内存中创建了dataset,datatable,而且调用了setdatabing().
      

  2.   

    更正应该是setdatabinding(),可是还是不行!
      

  3.   

    是不是ToolBar的缘故?如果没有ToolBar就能显示标题!
      

  4.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;namespace WindowsApplication
    {
    /// <summary>
    /// Form1 的摘要说明。
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
    private System.Windows.Forms.DataGrid dataGrid1;
    private System.Windows.Forms.ToolBar toolBar1;
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null; public Form1()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    } /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if (components != null) 
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    } #region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    this.dataGrid1 = new System.Windows.Forms.DataGrid();
    this.toolBar1 = new System.Windows.Forms.ToolBar();
    ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
    this.SuspendLayout();
    // 
    // dataGrid1
    // 
    this.dataGrid1.CaptionText = "rgsrh";
    this.dataGrid1.DataMember = "";
    this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
    this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
    this.dataGrid1.Name = "dataGrid1";
    this.dataGrid1.Size = new System.Drawing.Size(292, 266);
    this.dataGrid1.TabIndex = 0;
    // 
    // toolBar1
    // 
    this.toolBar1.AccessibleRole = System.Windows.Forms.AccessibleRole.ColumnHeader;
    this.toolBar1.DropDownArrows = true;
    this.toolBar1.Name = "toolBar1";
    this.toolBar1.ShowToolTips = true;
    this.toolBar1.Size = new System.Drawing.Size(292, 25);
    this.toolBar1.TabIndex = 1;
    this.toolBar1.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
    // 
    // Form1
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    this.ClientSize = new System.Drawing.Size(292, 266);
    this.Controls.AddRange(new System.Windows.Forms.Control[] {
      this.toolBar1,
      this.dataGrid1});
    this.Name = "Form1";
    this.Text = "Form1";
    ((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
    this.ResumeLayout(false); }
    #endregion /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 
    {
    Application.Run(new Form1());
    }
    }
    }
      

  5.   

    建议你重新依次放入控件ToolBar,DataGrid,再设置属性.
    晕,.NET好像有个BUG,次序不一样效果就不同(标题显示不出).
    试试吧!