日期:2014-05-20  浏览次数:20812 次

DataGridView控件的问题
DataGridView控件从数据库读得了一张表,
把数据库的列名也原样显示了出来 例如:EquipmentID,EquipmentName,都原样显示在控件列名上,但是软件的客户并一定都认识英文,因此用什么属性或是方法在控件中覆盖掉原英文列名,换成中文?
有些列里包含数据较长,如何设置初始最小列宽,以免每次用户要用鼠标拖动更改列宽?
请问以上都用DataGridView的什么属性和方法,请列明 谢谢

------解决方案--------------------
Column1.HeaderText = "中文";
------解决方案--------------------
Column1.MinimumWidth = 60;

也可以在属性窗中设置
------解决方案--------------------
namespace StudyMain
{
public partial class SubForm2 : Form
{
public SubForm2()
{
InitializeComponent();
DoSet();
}

private void DoSet()
{
// Create two DataTables.
DataTable tCust = new DataTable("Customers");
// Create two columns, and add them to the first table.
DataColumn cCustID = new DataColumn("CustID", typeof(int));
DataColumn cCustName = new DataColumn("CustName");
DataColumn cCurrent = new DataColumn("Current", typeof(bool));
tCust.Columns.Add(cCustID);
tCust.Columns.Add(cCustName);
tCust.Columns.Add(cCurrent);

DataRow newRow1;
// Create three customers in the Customers Table.
for (int i = 1; i < 4; i++)
{
newRow1 = tCust.NewRow();
newRow1["custID"] = i;
newRow1["CustName"] = "我是中文我是中文我是中文我是中文我是中文我是中文我是中文我是中文";
// Add the row to the Customers table.
tCust.Rows.Add(newRow1);
}
dataGridView1.DataSource = tCust;
dataGridView1.Columns[1].HeaderText = "我是中文";
dataGridView1.Columns[1].MinimumWidth = 20;[b][/b]
}
}
}
------解决方案--------------------
对这datagridView控件点右键选编辑列。里面有很多属性,自己好好研究一下,试一试就都知道了。
别人说的都不一定能信,自己操作看
HeaderText写中文
用wigth字的可该,就是设置单元格宽度的
还有很多。希望你自己去试一试