DataGrid的标题问题!

junes8250 2004-03-16 09:00:56
DataGrid的Dock=Fill,ShowHeader=true,可是就是显示不出来标题,
请指教!
...全文
105 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
junes8250 2004-03-16
  • 打赏
  • 举报
回复
更正应该是setdatabinding(),可是还是不行!
junes8250 2004-03-16
  • 打赏
  • 举报
回复
这个窗体是子窗体,我是在内存中创建了dataset,datatable,而且调用了setdatabing().
athossmth 2004-03-16
  • 打赏
  • 举报
回复
贴代码
qiume 2004-03-16
  • 打赏
  • 举报
回复
不会吧,只要指定了DataSource,不用做任何设置也会出来的
istring 2004-03-16
  • 打赏
  • 举报
回复
建议你重新依次放入控件ToolBar,DataGrid,再设置属性.
晕,.NET好像有个BUG,次序不一样效果就不同(标题显示不出).
试试吧!
junes8250 2004-03-16
  • 打赏
  • 举报
回复
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());
}
}
}
athossmth 2004-03-16
  • 打赏
  • 举报
回复
贴代码
junes8250 2004-03-16
  • 打赏
  • 举报
回复
是不是ToolBar的缘故?如果没有ToolBar就能显示标题!

111,093

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧