English 中文(简体)
c# 窗口应用程序中的一组数据网宽
原标题:Set cell width of a Datagrid in a c# windows application

我在“玻璃窗”应用中有一个数据网,我的代码是

private void BindGrid(SmsPdu pdu)
 {
   DataRow dr=dt.NewRow();
   SmsDeliverPdu data = (SmsDeliverPdu)pdu;
   dr[0]=data.OriginatingAddress.ToString();
   dr[1]=data.SCTimestamp.ToString();
   dr[2]=data.UserDataText;
   dt.Rows.Add(dr);
   dataGrid1.DataSource=dt;
  }

And my datagrid looks like this alt text http://www.freeimagehosting.net/uploads/c368f82e0e.jpg

  • How to set width of all three columns sender,time,Message?
最佳回答

简单方式:使用自动化

否则,使用Columns收集确定每个栏目的大小

ADDENDUM:

抱歉,我假定你正在使用数据GridView,因为它取代了2.0NET中的数据Grid。

就数据组而言,数据组比较复杂,但从全方位来看!

http://www.syncfusion.com/faq/windowsforms/search/1004.aspx

问题回答

藏匿处有一只妻子:

DataGridView1.Columns (X). Width = Y

如果X是该栏的名称或指数,Y是宽度





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签