I a beginner in Windows Mobile development and found that when I set the Width using a DataGridTextBoxColumn it does not affect the DataGrid column size.
Here is my code:
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = "MainStyle";
DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn();
tbcName.Width = 120;
tbcName.MappingName = "Name";
tbcName.HeaderText = "Name";
tableStyle.GridColumnStyles.Add(tbcName);
DataGridTextBoxColumn tbcValue = new DataGridTextBoxColumn();
tbcValue.Width = 200;
tbcValue.MappingName = "Value";
tbcValue.HeaderText = "Value";
tableStyle.GridColumnStyles.Add(tbcValue);
// dgUserAttributes is defined as a System.Windows.Forms.DataGrid
dgUserAttributes.TableStyles.Clear();
dgUserAttributes.TableStyles.Add(tableStyle);
Any ideas?
Copyright Notice:Content Author:「Zzub」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/558026/datagrid-width-has-no-affect-in-windows-mobile-c-sharp