ZeroEffect Posted August 6, 2008 Posted August 6, 2008 (edited) I know if I use the following line that my data set will be sorted by the column I want. dsEvents.Tables("Events").DefaultView.Sort = "RunTime" Here is how I am getting the data tbEventName.Text = dsEvents.Tables("Events").Rows(DataGridView.CurrentRow.Index).Item("EventName") tbCommand.Text = dsEvents.Tables("Events").Rows(DataGridView.CurrentRow.Index).Item("Command") dtpTime.Text = dsEvents.Tables("Events").Rows(DataGridView.CurrentRow.Index).Item("RunTime") cmbBox.Text = dsEvents.Tables("Events").Rows(DataGridView.CurrentRow.Index).Item("ComPort") Days(dsEvents.Tables("Events").Rows(DataGridView.CurrentRow.Index).Item("Days")) Then the DatagridView Displays the data correctly. If the user changes the sort in the DataGridView the Data I want to retrieve from the DataGridView is messed up. So I have two questions. 1. How can I sort my DataSet when the sort changes on the DataGridView 2. How do I disable the sort on the DataGridView Thanks ZeroEffect Edited August 6, 2008 by ZeroEffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
Puiu Posted August 12, 2008 Posted August 12, 2008 I don't know for the first question, but for the second this might help: For i As Integer = 0 To datagridview.Columns.Count - 1 datagridview.Columns(i).SortMode = DataGridViewColumnSortMode.NotSortable Next Quote
ZeroEffect Posted August 13, 2008 Author Posted August 13, 2008 Thanks PUIU that helped. Now I have figured out how to get data from a DataGridView row. DataGridView.Rows(DataGridView.CurrentRow.Index).Cells(i).Value 'i is the number of the column starting with 0 So this is good I have my data loaded into the DGV and sorted the way I want. Now I have a new issue. When I go to update a row in the Dataset the wrong row is updating. I have tried resorting by ID which should put the DS back into it orignal order. Then sort back after the changes have been made. But if I have the DS sorted by a different column then loaded shouldn't that change the row index to? example rows before sort are 4 (index 0) 1 3 2 (index 3) After sort 1 (index 0) 2 3 4 (index 3) After my sort the orignal index number seems to follow the rows. Is this how this works or am I missing something? Thanks for any help you may provide. ZeroEffect Quote If you can't find it, Build It. There is no place Like 127.0.0.1 also don't forget 1 + 1 = 10
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.