社区
C#
帖子详情
关于DataGridTextBoxColumn的问题
myblueeye
2003-10-20 02:02:57
对于DataGrid控件中,通过设置DataGridTextBoxColumn的Alignment属性为System.Windows.Forms.HorizontalAlignment.Center,结果显示数据过程中,仅仅是被设置的这个列中的数据信息按要求居中显示了,可是该列的标题,也就是myDataCol.HeaderText属性所对应的列标题不能同样的居中显示。请问该如何操作,可以满足上面的要求呢?
谢谢指教!!
...全文
20
3
打赏
收藏
关于DataGridTextBoxColumn的问题
对于DataGrid控件中,通过设置DataGridTextBoxColumn的Alignment属性为System.Windows.Forms.HorizontalAlignment.Center,结果显示数据过程中,仅仅是被设置的这个列中的数据信息按要求居中显示了,可是该列的标题,也就是myDataCol.HeaderText属性所对应的列标题不能同样的居中显示。请问该如何操作,可以满足上面的要求呢? 谢谢指教!!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
myblueeye
2003-10-21
打赏
举报
回复
呵呵,知道了:)
saucer
2003-10-21
打赏
举报
回复
it seems like a bug, but see
Henry手记—从Datagrid的标题居中说起
http://www.csdn.net/Develop/read_article.asp?id=17053
ruanyuping
2003-10-21
打赏
举报
回复
UP
“System.Windows.Forms.
DataGrid
TextBox
Column
”并不包含“Format”的定义
“System.Windows.Forms.
DataGrid
TextBox
Column
”并不包含“Format”的定义的解决办法
C#窗体控制程序电话本
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace AddressList { ///
/// Form1 的摘要说明。 ///
public class AddressList : System.Windows.Forms.Form { private System.Windows.Forms.GroupBox AddInfo; private System.Windows.Forms.Label lblName; private System.Windows.Forms.Label lblHomePhone; private System.Windows.Forms.Label lblOfficePhone; private System.Windows.Forms.Label lblHandSet; private System.Windows.Forms.Label lblTouchAddress; private System.Windows.Forms.Label lblPostalcode; private System.Windows.Forms.Label lblEmail; private System.Windows.Forms.
TextBox
txtName; private System.Windows.Forms.
TextBox
txtHomePhone; private System.Windows.Forms.
TextBox
txtOfficePhone; private System.Windows.Forms.
TextBox
txtHandSet; private System.Windows.Forms.
TextBox
txtTouchAddress; private System.Windows.Forms.
TextBox
txtPostalCode; private System.Windows.Forms.
TextBox
txtEmail; private System.Windows.Forms.Button btnAdd; private System.Windows.Forms.GroupBox ExtendOperation; private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Button btnModify; private System.Windows.Forms.Button btnDelete; private System.Windows.Forms.Button btnSelect; private System.Windows.Forms.Label lblNote; private System.Windows.Forms.
DataGrid
dataGrid
1; ///
/// 必需的设计器变量。 ///
private System.ComponentModel.Container components = null; public AddressList() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TOD 在 InitializeComponent 调用后添加任何构造函数代码 // } ///
/// 清理所有正在使用的资源。 ///
protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } ///
/// 应用程序的主入口点。 ///
[STAThread] static void Main() { Application.Run(new AddressList()); } private void btnAdd_Click(object sender, System.EventArgs e) { AddInfo add=new AddInfo(); int ret=add.Add(this.txtName.Text,this.txtHomePhone.Text,this.txtOfficePhone.Text,this.txtHandSet.Text,this.txtTouchAddress.Text,this.txtPostalCode.Text,this.txtEmail.Text); if(ret>0) { MessageBox.Show("恭喜你,添加成功!"); bind(); } else { MessageBox.Show("添加失败!原因可能是你输入了重复的名称!"); } this.txtName.Text=""; this.txtHomePhone.Text=""; this.txtOfficePhone.Text=""; this.txtHandSet.Text=""; this.txtTouchAddress.Text=""; this.txtPostalCode.Text=""; this.txtEmail.Text=""; } private void AddressList_Load(object sender, System.EventArgs e) { bind();
DataGrid
TableStyle ts1= new
DataGrid
TableStyle(); ts1.MappingName="BasicInfo";
DataGrid
Column
Style cs = new
DataGrid
TextBox
Column
(); cs.Alignment=HorizontalAlignment.Center; cs.MappingName="SName"; cs.HeaderText="姓名"; cs.Width=80; ts1.Grid
Column
Styles.Add(cs);
DataGrid
Column
Style cs1 =new
DataGrid
TextBox
Column
(); cs1.Alignment=HorizontalAlignment.Center; ; cs1.MappingName="HomePhone"; cs1.HeaderText="住宅电话"; cs1.Width=80; ts1.Grid
Column
Styles.Add(cs1);
DataGrid
Column
Style cs2 =new
DataGrid
TextBox
Column
(); cs2.Alignment=HorizontalAlignment.Center; ; cs2.MappingName="OfficePhone"; cs2.HeaderText="办公电话"; cs2.Width=80; ts1.Grid
Column
Styles.Add(cs2);
DataGrid
Column
Style cs3 = new
DataGrid
TextBox
Column
(); cs3.Alignment=HorizontalAlignment.Center; cs3.MappingName="HandSet"; cs3.HeaderText="手机号码"; cs3.Width=80; ts1.Grid
Column
Styles.Add(cs3);
DataGrid
Column
Style cs4 = new
DataGrid
TextBox
Column
(); cs4.Alignment=HorizontalAlignment.Center; cs4.MappingName="TouchAddress"; cs4.HeaderText="通信地址"; cs4.Width=200; ts1.Grid
Column
Styles.Add(cs4);
DataGrid
Column
Style cs5 = new
DataGrid
TextBox
Column
(); cs5.Alignment=HorizontalAlignment.Center; cs5.MappingName="PostalCode"; cs5.HeaderText="邮政编码"; cs5.Width=60; ts1.Grid
Column
Styles.Add(cs5);
DataGrid
Column
Style cs6 = new
DataGrid
TextBox
Column
(); cs6.Alignment=HorizontalAlignment.Center; cs6.MappingName="Email"; cs6.HeaderText="电子邮件"; cs6.Width=150; ts1.Grid
Column
Styles.Add(cs6); this.
dataGrid
1.TableStyles.Add(ts1); } public void bind() { SearchInfo result = new SearchInfo(); DataSet view = result.GetAddInfo(); this.
dataGrid
1.DataSource=view; this.
dataGrid
1.DataMember="BasicInfo"; } private void btnModify_Click(object sender, System.EventArgs e) { UpdateBasicInfo update=new UpdateBasicInfo(); int ret=update.Update(this.txtName.Text,this.txtHomePhone.Text,this.txtOfficePhone.Text,this.txtHandSet.Text,this.txtTouchAddress.Text,this.txtPostalCode.Text,this.txtEmail.Text); if(ret>0) { bind(); MessageBox.Show("修改成功,请核对!"); } else { MessageBox.Show("修改失败!"); } } private void
dataGrid
1_Click(object sender, System.EventArgs e) { this.btnModify.Enabled=true; this.btnDelete.Enabled=true; int row=this.
dataGrid
1.CurrentCell.RowNumber; this.txtName.Text=this.
dataGrid
1[row,0].ToString(); this.txtHomePhone.Text=this.
dataGrid
1[row,1].ToString(); this.txtOfficePhone.Text=this.
dataGrid
1[row,2].ToString(); this.txtHandSet.Text=this.
dataGrid
1[row,3].ToString(); this.txtTouchAddress.Text=this.
dataGrid
1[row,4].ToString(); this.txtPostalCode.Text=this.
dataGrid
1[row,5].ToString(); this.txtEmail.Text=this.
dataGrid
1[row,6].ToString(); } private void btnDelete_Click(object sender, System.EventArgs e) { DeleteBasicInfo del= new DeleteBasicInfo(); int ret = del.deleteInfo(this.txtName.Text); if (ret==0) { MessageBox.Show("删除失败!"); } else { bind(); MessageBox.Show("删除成功!"); } } private void btnSelect_Click(object sender, System.EventArgs e) { SearchInfo search=new SearchInfo(); DataSet result=search.searchInfo(this.txtName.Text); this.
dataGrid
1.DataSource=result; this.
dataGrid
1.DataMember="BasicInfo"; } } }
C#开发和使用中的23个技巧
1.怎样定制VC#
DataGrid
列标题?
DataGrid
TableStyle dgts = new
DataGrid
TableStyle();
dgts.MappingName = "myTable"; //myTable为要载入数据的DataTable
DataGrid
TextBox
Column
dgcs = new
DataGrid
TextBox
Column
();
dgcs.MappingName = "title_id";
dgcs.HeaderText = "标题ID";
dgts.Grid
Column
Styles.Add(dgcs);
。。。
dataGrid
1.TableStyles.Add(dgts);
12.怎样把数据库表的二个列合并成一个列Fill进DataSet里?
dcChehao = new Data
Column
("new
Column
Name", typeof(string));
dcChehao.Expression = "
column
Name1+
column
Name2";
dt.
Column
s.Add(dcChehao);
Oracle:
select col1||col2 from table
sql server:
select col1+col2 from table
继承重写 System.Windows.Forms.
DataGrid
TextBox
Column
类
/*********************************************************** * 概要:继承重写 System.Windows.Forms.
DataGrid
TextBox
Column
类 * 创建人:王晓光 * 创建时间:2009/3/27 **********************************************************
DataGrid
TextBox
Column
Class
DataGrid
TextBox
Column
Class
DataGrid
TextBox
Column
Classhttp://msdn.microsoft.com/en-us/library/system.windows.forms.
datagrid
textbox
column
.aspxCustomizing the Windows Forms
DataGrid
http://msdn.microsoft
C#
110,499
社区成员
642,576
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章