PC Review


Reply
Thread Tools Rate Thread

datagrid width doesn't apply

 
 
.nLL
Guest
Posts: n/a
 
      6th Mar 2009
Hi, below works perfectly fine

DataTable myTable = new DataTable();
DataColumn myNameColumn = new DataColumn("agenre_Text");
myNameColumn.DataType = System.Type.GetType("System.String");
myNameColumn.DefaultValue = "default string";
myTable.Columns.Add(myNameColumn);
genreGrid.DataSource = myTable;

DataGridTableStyle tableStyle = new DataGridTableStyle();
DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn();
tbcName.Width = 300;
tbcName.MappingName = "agenre_Text";
tbcName.HeaderText = "a";
tableStyle.GridColumnStyles.Add(tbcName);

genreGrid.TableStyles.Clear();
genreGrid.TableStyles.Add(tableStyle);


but this doesn't get the width


DataTable myTable = new DataTable();
myTable = new
LoadGenres().Load(strFullPathToMyFile).Tables["genre"];
genreGrid.DataSource = myTable;

DataGridTableStyle tableStyle = new DataGridTableStyle();
DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn();
tbcName.Width = 300;
tbcName.MappingName = myTable.Columns[0].ColumnName.ToString();
tbcName.HeaderText = myTable.Columns[0].ColumnName.ToString();
tableStyle.GridColumnStyles.Add(tbcName);

genreGrid.TableStyles.Clear();
genreGrid.TableStyles.Add(tableStyle);


only difference is data source. What am i doing wrong? BW this is my first
ever windows mobile project

 
Reply With Quote
 
 
 
 
.nLL
Guest
Posts: n/a
 
      6th Mar 2009
got it with

DataTable myTable = new DataTable();
myTable = new
LoadGenres().Load(strFullPathToMyFile).Tables["genre"];
genreGrid.DataSource = myTable;
DataGridTableStyle tableStyle = new DataGridTableStyle();
tableStyle.MappingName = myTable.TableName.ToString();
DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn();
tbcName.Width = 300;
tbcName.MappingName = myTable.Columns[0].ColumnName.ToString();
tbcName.HeaderText = myTable.Columns[0].ColumnName.ToString();
tableStyle.GridColumnStyles.Add(tbcName);
genreGrid.TableStyles.Clear();
genreGrid.TableStyles.Add(tableStyle);



".nLL" <(E-Mail Removed)> wrote in message
news:6Lgsl.43441$%(E-Mail Removed)2...
> Hi, below works perfectly fine
>
> DataTable myTable = new DataTable();
> DataColumn myNameColumn = new DataColumn("agenre_Text");
> myNameColumn.DataType = System.Type.GetType("System.String");
> myNameColumn.DefaultValue = "default string";
> myTable.Columns.Add(myNameColumn);
> genreGrid.DataSource = myTable;
>
> DataGridTableStyle tableStyle = new DataGridTableStyle();
> DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn();
> tbcName.Width = 300;
> tbcName.MappingName = "agenre_Text";
> tbcName.HeaderText = "a";
> tableStyle.GridColumnStyles.Add(tbcName);
>
> genreGrid.TableStyles.Clear();
> genreGrid.TableStyles.Add(tableStyle);
>
>
> but this doesn't get the width
>
>
> DataTable myTable = new DataTable();
> myTable = new
> LoadGenres().Load(strFullPathToMyFile).Tables["genre"];
> genreGrid.DataSource = myTable;
>
> DataGridTableStyle tableStyle = new DataGridTableStyle();
> DataGridTextBoxColumn tbcName = new DataGridTextBoxColumn();
> tbcName.Width = 300;
> tbcName.MappingName = myTable.Columns[0].ColumnName.ToString();
> tbcName.HeaderText = myTable.Columns[0].ColumnName.ToString();
> tableStyle.GridColumnStyles.Add(tbcName);
>
> genreGrid.TableStyles.Clear();
> genreGrid.TableStyles.Add(tableStyle);
>
>
> only difference is data source. What am i doing wrong? BW this is my first
> ever windows mobile project


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column Width-Apply to whole workbook =?Utf-8?B?SmVubnk=?= Microsoft Excel Setup 1 30th Dec 2005 01:05 AM
Setting column width to datagrid doesn't work ejsanchez@gmail.com Microsoft Dot NET Framework Forms 2 28th Jul 2005 12:25 AM
Added CheckBox to a DataGrid Doesn't work with DataGrid.Enabled=False Amar Microsoft ASP .NET 0 6th Apr 2004 11:14 AM
Datagrid col width Prateek Microsoft Dot NET 5 9th Jan 2004 01:05 AM
DataGrid width Prateek Microsoft ASP .NET 0 8th Jan 2004 04:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:43 AM.