Thansk White.
If my DataGrid's name is "dataGrid1", how do I implement your function for
my datagrid?
"WhiteWizard" <(E-Mail Removed)> 撰寫於郵件新聞:4583DD1A-BDD1-431C-AA0D-(E-Mail Removed)...
> Jason,
>
> You have to create a DataStyle for the datagrid.
>
> Here is an example of one I use in my WinApp.
>
> private void ConfigureTestPointDatagrid()
> {
> DataGridTableStyle tsTP = new DataGridTableStyle();
> tsTP.MappingName = "TestPoints Table";
> tsTP.AlternatingBackColor = SystemColors.Control;
>
> /* Add a GridColumnStyle and set its MappingName
> to the name of a DataColumn in the DataTable.
> Set the HeaderText and Width properties. */
>
> DataGridTextBoxColumn aliasIDCol = new DataGridTextBoxColumn();
> aliasIDCol.MappingName = "aliasID";
> aliasIDCol.HeaderText = "Alias ID";
> aliasIDCol.Width = 80;
> tsTP.GridColumnStyles.Add(aliasIDCol);
>
> DataGridTextBoxColumn nameCol = new DataGridTextBoxColumn();
> nameCol.MappingName = "parameterName";
> nameCol.HeaderText = "Test Point Name";
> nameCol.Width = 375;
> tsTP.GridColumnStyles.Add(nameCol);
>
> DataGridTextBoxColumn fiCol = new DataGridTextBoxColumn();
> fiCol.MappingName = "Subsystem";
> fiCol.HeaderText = "Subsystem";
> fiCol.Width = 95;
> fiCol.NullText = "";
> tsTP.GridColumnStyles.Add(fiCol);
>
> DataGridColumnStyle idCol = new DataGridTextBoxColumn();
> idCol.MappingName = "ID";
> idCol.Width = 0;
> tsTP.GridColumnStyles.Add(idCol);
>
> testPointDatagrid.TableStyles.Add(tsTP);
> }
>
> HTH
>
>
> "Jason Huang" wrote:
>
>> Hi,
>>
>> In my C# Windows form project.
>> I am wondering can we manually define the width of a cell in a DataGrid?
>> Thanks for help.
>>
>>
>> Jason
>>
>>
>>
|