Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

DataGrid - Sorting Columns

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dennis - 22 Oct 2004 01:59 GMT
How do I sort a DataGrid Column in code without clicking on the column header?
Signature

Dennis in Houston

W.G. Ryan eMVP - 22 Oct 2004 02:16 GMT
Bind to a dataview and set it's Sort property to whatever field you want.

Signature

W.G. Ryan MVP (Windows Embedded)

TiBA Solutions
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com

> How do I sort a DataGrid Column in code without clicking on the column header?
scorpion53061 - 22 Oct 2004 04:50 GMT
Sorry Bill I had not seen you post your answer yet.

> Bind to a dataview and set it's Sort property to whatever field you
> want.
Dennis - 22 Oct 2004 23:49 GMT
Thanks.

> Bind to a dataview and set it's Sort property to whatever field you want.
>
> > How do I sort a DataGrid Column in code without clicking on the column
> header?
scorpion53061 - 22 Oct 2004 02:22 GMT
You can use one line of code to create a dataview from the datatable.

Dim dv as DataView = WhateverDataTable.DefaultView

Now, bind the grid to the view instead of the table.  All of your
current
functionality will still be in tact.

You can call Sort on any field in the dataview and sort it which will
cause
the grid to sort.You could offer this via a context menu for instance,
if
for some reason you didn't want to allow sorting based on the grid
headers.

http://www.knowdotnet.com/articles/dataviewsort.html

> How do I sort a DataGrid Column in code without clicking on the column
> header?
Dennis - 23 Oct 2004 01:03 GMT
Is there someother way such as sending a message to the DAtaGrid via WinProc
to sort a column?  I don't see where the DataView works with DataSets.

> You can use one line of code to create a dataview from the datatable.
>
[quoted text clipped - 15 lines]
> > How do I sort a DataGrid Column in code without clicking on the column
> > header?
William LaMartin - 24 Oct 2004 17:57 GMT
Not tested, but how about something like this:

dim dv As New DataView
dv = ds.Tables(0).DefaultView  'where ds is the dataset in question
dv.Sort = "Order" 'where Order is the column name by which you want to sort
Me.DataGrid1.DataSource = dv
Me.DataGrid1.Refresh()

> Is there someother way such as sending a message to the DAtaGrid via
> WinProc
[quoted text clipped - 19 lines]
>> > How do I sort a DataGrid Column in code without clicking on the column
>> > header?
Martin - 26 Oct 2004 05:02 GMT
Talkin about dataview object. Recently I tried to edit some row like this
... dr(indexcolumn) (indexrow) = "... "  .. it was applied to the dataset,
But it didn't update to the datasource when i call
DataAdapter.update(Dataset,"TableName") { this with assumtion that
commandbuilder had been generated }. And also a mistake when i tried to
delete row using dataview object. But it didn't show any error message when
i put the -update method- in try ... catch ... endtry ....
Felling frustated with dataview object .. i used datatable object to edit
and delete row. ... Did u guys have this kind of problems before ?

Martin

> Not tested, but how about something like this:
>
[quoted text clipped - 27 lines]
> >> > How do I sort a DataGrid Column in code without clicking on the column
> >> > header?
Frank - 26 Oct 2004 07:31 GMT
Yes I did. I added beginedit and endedit and the problems were gone. I
thought begin/endedit was optional but it looks like it is obliged.
Frank

> Talkin about dataview object. Recently I tried to edit some row like this
> ... dr(indexcolumn) (indexrow) = "... "  .. it was applied to the dataset,
[quoted text clipped - 41 lines]
> column
> > >> > header?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.