DataGridView DataView Grunting
DataGridView DataView Grunting
DataGridView DataView Grunting
DataGridView DataView Grunting
DataGridView DataView Grunting
DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting
DataGridView DataView Grunting DataGridView DataView Grunting
DataGridView DataView Grunting
Go Back  Xtreme Visual Basic Talk > > > DataGridView DataView Grunting


Reply
 
Thread Tools Display Modes
  #1  
Old 02-18-2014, 06:41 PM
Gruff's Avatar
GruffDataGridView DataView Grunting Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default DataGridView DataView Grunting


I am experiencing big time sorting issues the with the a dataview

When I sort the dataview it works fine however when I retrieve a value from the dataview it appears to be from the unsorted table.

Can anyone shed some light on the topic?

Edit:
The other odd thing is that the sort does not appear to be a one time
reorder. Editing a value on the sorted column after the sort still sorts.
It also seems buggy. Sometimes instead of honoring the sort it move the
changed record to the bottom of the grid. Really weird.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 02-19-2014 at 12:03 PM.
Reply With Quote
  #2  
Old 02-19-2014, 03:37 PM
Gruff's Avatar
GruffDataGridView DataView Grunting Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

Okay, Figured out the jump to bottom issue. All my cells in the sorted column started with a space. When I edited a cell I typing the data straight in. (No space)
Of course the row would go to the bottom.

Removed the spaces when I fill the datatable. No jumping.

However when I try to access a dataview cell it is still the original unsorted data.
(The dataview and the datagridview cells to not match by coordinate.)

I even tried turning off all sorting and creating a new sorted datatable using linq manually.
Amazingly when bound to the datagridview it goes into sort mode!
The table itself appears to be unsorted.
Weird yet again.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #3  
Old 02-19-2014, 07:04 PM
Gruff's Avatar
GruffDataGridView DataView Grunting Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

Okay I finally have a work around. This allows me to sort the driving dataview
only when I want. Edits do not force re-sorting.

The dataview and datagridview are in sync.
(Basically I am doing a lot of manipulating of the dataview)

'ohAlias' is the column I am sorting on that requires editing.
Code:
Private Sub Sample_Sort() With OnHandGrid .DataSource = Nothing oDV_Mat = SortDataView(oDV_Mat, "ohAlias") .DataSource = oDV_Mat ' Reset the datagridview column settings For Each Col As DataGridViewColumn In OnHandGrid.Columns Col.SortMode = DataGridViewColumnSortMode.NotSortable Col.ReadOnly = True Col.Width = 80 Next .Columns("ohAlias").ReadOnly = False .Columns("ohAlias").Width = 150 .Columns("ohMaterial").Width = 150 .Columns("ohBlank").Width = 40 End With End Sub Private Function SortDataView(oDV As DataView, ColumnName As String) As DataView 'Create new datatable and fill with sorted rows Dim oDT As DataTable = oDV.Table.Clone Dim RowArray() As DataRow = oDV_Mat.Table.Select(Nothing, ColumnName, DataViewRowState.CurrentRows) For i = 0 To RowArray.Count - 1 oDT.Rows.Add(RowArray(i).ItemArray) Next oDV = oDT.DefaultView Return oDV End Function
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
DataGridView DataView Grunting
DataGridView DataView Grunting
DataGridView DataView Grunting DataGridView DataView Grunting
DataGridView DataView Grunting
DataGridView DataView Grunting
DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting DataGridView DataView Grunting
DataGridView DataView Grunting
DataGridView DataView Grunting
 
DataGridView DataView Grunting
DataGridView DataView Grunting
 
-->