Euhh..... insulting your intelligence? Excuse me, that's not what i intended to mention.
Lets start over again. You are trying to view some table-data in a datagrid in a "windows application".
The data bound to the grid can be of different types. A dataset, a datatable, a dataview, a xml-file....you name it.....
If you use a dataset, you have to mention the datatable from the collection (
dataset.Tables()) by number or name:
For example dataset.tables(0) or dataset.tables("Customers") if you ever attached a name to the table.
Try this example, its a form with 1 datagridview & 1 button called cmdDataView. If you load the form it will show 10 records and after clicking the button "cmdDataView" it will reload the datagrid with a descending sorted view of the data.
In the example I create also a _DataSet which isn't used at this particular moment.....
Imports System.Data
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Create a new dataset
Dim _Dataset As DataSet = New DataSet
'Create a new datatable called "Customers"
Dim _DataTable As DataTable = New DataTable("Customers")
'Create some columns in the datatable
Dim _Column As DataColumn = New DataColumn
_Column.DataType = Type.GetType("System.Int32")
_Column.ColumnName = "ID"
_Column.AutoIncrement = True
_Column.AutoIncrementSeed = 1
_Column.AutoIncrementStep = 1
'add the column to the datatable
_DataTable.Columns.Add(_Column)
_Column = New DataColumn
_Column.DataType = Type.GetType("System.String")
_Column.ColumnName = "Name"
'add the column to the datatable
_DataTable.Columns.Add(_Column)
'add some rows to the datatable
For iCnt As Integer = 1 To 10
Dim _DataRow As DataRow = _DataTable.NewRow
_DataRow.Item("Name") = String.Format("Name {0}", iCnt.ToString)
_DataTable.Rows.Add(_DataRow)
Next
Me.DataGridView1.DataSource = _DataTable
End Sub
Private Sub cmdDataView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDataView.Click
Dim _DataTableTemp As New DataTable
_DataTableTemp = Me.DataGridView1.DataSource
Dim _DataView As DataView = _DataTableTemp.DefaultView
_DataView.Sort = "ID desc"
Me.DataGridView1.DataSource = _DataView
End Sub
End Class
hmmm.... slightly too late :=)