hi i have a datagrid all set up, i just need to know how to sort on one of the columns, for example supplierName...
I've put my code below to show you how i have it set up.
Cheers, al
I've put my code below to show you how i have it set up.
Cheers, al
VB.NET:
dtAudits = ds.Tables("audits")
' present data
With dgAudits
.DataSource = dtAudits
.ReadOnly = True
' Set DataGrid Data Binding to Machines table
.SetDataBinding(ds, "audits")
' Set DataGrid Background Color
.BackgroundColor = System.Drawing.Color.Gray
' Set DataGrid Caption Background Color
.CaptionBackColor = System.Drawing.Color.DarkBlue
' Set DataGrid Caption Foreground Color
.CaptionForeColor = System.Drawing.Color.White
' Set DataGrid Parent Rows Background Color
.ParentRowsBackColor = System.Drawing.Color.DarkBlue
' Set DataGrid Parent Rows Foreground Color
.ParentRowsForeColor = System.Drawing.Color.SlateBlue
' Set DataGrid Caption Text
.CaptionText = "Audits Results"
' Clear DataGrid Table Styles
.TableStyles.Clear()
End With
' Set up data grid Table Style
Dim tableStyle As New DataGridTableStyle
tableStyle.MappingName = "audits"
' Set data grid Table Style
Dim TblStyle As New DataGridTableStyle
With TblStyle
.MappingName = "audits"
.BackColor = System.Drawing.Color.White
.AlternatingBackColor = Color.LightBlue
.ForeColor = System.Drawing.Color.DarkSlateBlue
.GridLineColor = System.Drawing.Color.MediumSlateBlue
.HeaderBackColor = System.Drawing.Color.Lavender
.HeaderForeColor = System.Drawing.Color.Black
.RowHeaderWidth = 10
' Set column styles
With .GridColumnStyles
.Add(New DataGridTextBoxColumn)
With .Item(0)
.MappingName = "auditId"
.HeaderText = "Audit ID"
.Width = 0
.NullText = String.Empty
End With
.Add(New DataGridTextBoxColumn)
With .Item(1)
.MappingName = "supplierName"
.HeaderText = "Supplier"
.Width = 190
.NullText = String.Empty
End With