日期:2014-05-18  浏览次数:21295 次

wince datagrid改变列宽问题
str_sql = "SELECT jid,jname FROM JiBing " 
SqlCeDataAdapter da = new SqlCeDataAdapter(str_sql, SqlCeHelper.Fzzl2ConnectionString);
DataSet ds = new DataSet();
da.Fill(ds, "JiBing");

DataGridTableStyle myTableStyle = new DataGridTableStyle();
myTableStyle.MappingName = "JiBing";
DataGridColumnStyle col2 = new DataGridTextBoxColumn();
col2.MappingName = "jid";
col2.HeaderText = "列1";
col2.Width = 150;

DataGridColumnStyle col3 = new DataGridTextBoxColumn();
col3.MappingName = "jname";
col3.HeaderText = "列2";
col3.Width = 5000;

myTableStyle.GridColumnStyles.Add(col2);
myTableStyle.GridColumnStyles.Add(col3);

dataGrid1.TableStyles.Clear();
dataGrid1.TableStyles.Add(myTableStyle);

dataGrid1.DataSource = dt;


我的开发环境是 WINCE5.0 + VS2008(C#)


用上面的代码,改变不了

------解决方案--------------------
DataGridColumnStyle col2 = new DataGridTextBoxColumn();
LZ这个错误的呀,你自定义一个列,应该是这样子的啊
DataGridTextBoxColumn col2 = new DataGridTextBoxColumn();
哎,LZ以后细心点
------解决方案--------------------

可以参考一下:

http://www.cnblogs.com/godwar/archive/2008/04/02/1134717.html