|
-
Jul 5th, 2003, 08:01 AM
#1
Thread Starter
Hyperactive Member
how to programmatically change the Width to 15 of column number 6 on Datagrid1 and th
Gentlemen:
Can anyone tell me how to programmatically change the Width to 15 of column number 6 on Datagrid1 and the format to currency?
Thanks
Andy
-
Jul 5th, 2003, 08:46 AM
#2
Frenzied Member
You should add a DatagridTableStlye to your datagrid and then the datagridtextboxcolumns and datagridboolcolumns. Then you can set the width and format. As an alternative you can format the data at dataset level but i am afraid there is no other way to set the width of the columns as the properties of default DatagridTableStyle of datagrid (that is created when you just set the datagrid datasource) is not accessible. Dont know if that means anything to you, and please ppl correct me if i am wrong.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Jul 5th, 2003, 08:53 AM
#3
Thread Starter
Hyperactive Member
Could you please tell me if this is what you mean?
Code:
Dim dgStyle as DataGridTableStyle
Dim dgTableStyle As New DataGridTableStyle()
Me.DataGrid1.TableStyles.Clear()
Dim colStyle1 As New DataGridTextBoxColumn()
With colStyle1
.Alignment = HorizontalAlignment.Left
.HeaderText = "Name"
.MappingName = "EmployeeName"
.Width = 50
End With
dgTableStyle.GridColumnStyles.Add(colStyle1)
dgTableStyle.MappingName = "tblEmployees"
Me.DataGrid1.TableStyles.Add(dgTableStyle)
-
Jul 5th, 2003, 09:00 AM
#4
Frenzied Member
Yes. But i think you dont need this :
Me.DataGrid1.TableStyles.Clear() if you set the datagrid datasource at last. However not sure about it.
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
-
Jul 5th, 2003, 09:05 AM
#5
Thread Starter
Hyperactive Member
How do you set the format to $Currency?
Lunatic3:
How do you set the format of this column to Currency$
Code:
Dim dgStyle as DataGridTableStyle
Dim dgTableStyle As New DataGridTableStyle()
Me.DataGrid1.TableStyles.Clear()
Dim colStyle1 As New DataGridTextBoxColumn()
With colStyle1
.Alignment = HorizontalAlignment.Left
.HeaderText = "Cost"
.MappingName = "ItemCost"
.Width = 20
End With
dgTableStyle.GridColumnStyles.Add(colStyle1)
dgTableStyle.MappingName = "tblEmployees"
Me.DataGrid1.TableStyles.Add(dgTableStyle)
-
Jul 5th, 2003, 09:12 AM
#6
Frenzied Member
VB Code:
With colStyle1
.Format("c")
'
c represents the local currency format. Look here for details.
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003APR.1033/cpref/html/frlrfsystemwindowsformsdatagridtextboxcolumnclassformattopic.htm
'Heading for the automatic overload'
Marillion, Brave, The Great Escape, 1994
'How will WE stand the FIRE TOMORROW?'
Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|