Windows Mobile应用程序中DataGrid的列宽

我在尝试调整数据网格列的宽度时遇到问题。 我使用了这里发布的答案,但我无法解决。

我正在使用对象列表作为数据源。 在这个简单的例子中,我刚刚创建了一个智能设备应用程序,并且刚刚添加了一个数据网格。 然后我的代码就是这个:

public Form1() { InitializeComponent(); List lista = new List(); lista.Add(new Prueba("uno", "dos")); lista.Add(new Prueba("tres", "cuatro")); dataGrid1.DataSource = lista; DataGridTableStyle tableStyle = new DataGridTableStyle(); tableStyle.MappingName = lista.GetType().ToString(); DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn(); tbcName.Width = 4000; tbcName.MappingName = "UNO"; tbcName.HeaderText = "UNO"; tableStyle.GridColumnStyles.Add(tbcName); dataGrid1.TableStyles.Clear(); dataGrid1.TableStyles.Add(tableStyle); } } public class Prueba { public string UNO { get; set; } public string DOS { get; set; } public Prueba(string uno, string dos) { this.UNO = uno; this.DOS = dos; } } 

宽度保持不变。 你有线索吗? 谢谢!

改变这一行

 tableStyle.MappingName = lista.GetType().ToString(); 

 tableStyle.MappingName = lista.GetType().Name; 

哦,4000对于手机来说有点大,但我认为这是一个错字。