Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Open Points: 250 Time: 13:01 - Apr 08, 2009  

mkarkoukli

how to sort datagridview in vb.net? my control is not bound.

I have a vb.net form with datagridview control that bound programmatically. The data source for this control is coming from a SQL query, I want to take advantage of the sorting capabilities that are part of the datagridview. How can i accomplish the column sorting. I want to give the user the ability to sort by clicking on any of the columns.

Here is how I'm supplying the datasource:

TicketList = TicketsDB.GetTickets("Open")

DataGridViewTickets.DataSource = TicketList

Answer Discussion
Tutorials

 

thiruhitech

Date:: Apr 13, 2009

Time:: 06:20

use this code


Public Overrides Function Equals(ByVal obj As Object) As Boolean
If obj Is Nothing Or Not Me.GetType() Is obj.GetType() Then
Return False
End If
Dim d As duplicates = CType(obj, duplicates)
Return Me.account = d.account
End Function


'Errant code below

conn.Open()

Dim reader As SqlDataReader = cmd.ExecuteReader()
If reader.HasRows Then
'Create array to hold entries for accounts tracked more than once per LOB
Dim arrResults As New ArrayList
Dim dupEntries As New duplicates
While reader.Read
With arrResults
.Add(

New duplicates(reader.GetValue(0), reader.GetValue(1), reader.GetValue(2), _
reader.GetValue(3), reader.GetValue(4), reader.GetValue(5), reader.GetValue(6), _

reader.GetValue(7), reader.GetValue(8), reader.GetValue(9), reader.GetValue(10), _

reader.GetValue(11), reader.GetValue(12), reader.GetValue(13), reader.GetValue(14)))

End With
End While
reader.Close()

Dim first As duplicates
Dim last As duplicates
Dim i As Integer
For i = 0 To arrResults.Count - 1
first =

CType(arrResults.Item(i), duplicates)
Trace.Warn(arrResults.LastIndexOf(first.account))

last = arrResults.Item(arrResults.LastIndexOf(first.account))

Trace.Warn(

"first date" & first.tDate)
Trace.Warn(

"last date " & last.tDate)
Next
End If

thiruhitech

Date:: Apr 13, 2009

Time:: 06:42

to see this link
thiruhitech.blogspot.com

admin

Date:: May 05, 2009

Time:: 07:22

The question looks to be abandoned by the user who asked it. If no action is taken within 2 days, a Quomon Moderator will consider closing the question and distributing the points.

The Quomon Team

mkarkoukli

Date:: May 05, 2009

Time:: 15:33

Thank you guys for your help, I ended up using a combo box and customized SQL query ..

mkarkoukli

Date:: May 05, 2009

Time:: 15:34

Yes thank you :)

rajimathew02

Date:: Apr 04, 2011

Time:: 01:50

thanks

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Tutorials cannot be submitted until the Answer Discussion is complete.

Submit answers in the Answer Discussion area

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10279

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es