473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Implement Icomparable

Jim
Creating a datagridView with a dataReader. Why do I get this message
when I click on the column header (some, but not all the column
headers) to sort??

sqlDR = sqlCMD.ExecuteReader
Dim intCol As Integer

With sqlDR
If .HasRows Then
DataGridViewProducts.Rows.Clear()
For intCol = 0 To .FieldCount - 1
DataGridViewProducts.Columns.Add(.GetName(intCol),
..GetName(intCol))
Next

DataGridViewProducts.AutoSizeColumnsMode =
DataGridViewAutoSizeColumnsMode.ColumnHeader
While .Read
Dim objCells(intCol) As Object
.GetValues(objCells)
DataGridViewProducts.Rows.Add(objCells)

End While
.Close()
End If
End With
Dec 16 '06 #1
2 1683
Hi Jim, I guess it's because for some types you have there isn't a
default comparer (like you have, for instance, for most numerical types
and strings ).

What do those columns contain (what's the datatype) ?

-T

Jim ha scritto:
Creating a datagridView with a dataReader. Why do I get this message
when I click on the column header (some, but not all the column
headers) to sort??

sqlDR = sqlCMD.ExecuteReader
Dim intCol As Integer

With sqlDR
If .HasRows Then
DataGridViewProducts.Rows.Clear()
For intCol = 0 To .FieldCount - 1
DataGridViewProducts.Columns.Add(.GetName(intCol),
.GetName(intCol))
Next

DataGridViewProducts.AutoSizeColumnsMode =
DataGridViewAutoSizeColumnsMode.ColumnHeader
While .Read
Dim objCells(intCol) As Object
.GetValues(objCells)
DataGridViewProducts.Rows.Add(objCells)

End While
.Close()
End If
End With
Dec 17 '06 #2
Jim
Thats what makes this so confusing. I can sort an int column, a
varchar(200) column, but varchar(10) gives me the Implement
Icomparable error message. Being new to .NET this stuff is really
confusing, and any help would be greatly appreciated. There also
doesn't appear to be any way to turn off sorting in the datagridView.

On 16 Dec 2006 17:12:10 -0800, "to**************@uniroma1.it"
<To**************@gmail.comwrote:
>Hi Jim, I guess it's because for some types you have there isn't a
default comparer (like you have, for instance, for most numerical types
and strings ).

What do those columns contain (what's the datatype) ?

-T

Jim ha scritto:
>Creating a datagridView with a dataReader. Why do I get this message
when I click on the column header (some, but not all the column
headers) to sort??

sqlDR = sqlCMD.ExecuteReader
Dim intCol As Integer

With sqlDR
If .HasRows Then
DataGridViewProducts.Rows.Clear()
For intCol = 0 To .FieldCount - 1
DataGridViewProducts.Columns.Add(.GetName(intCol),
.GetName(intCol))
Next

DataGridViewProducts.AutoSizeColumnsMode =
DataGridViewAutoSizeColumnsMode.ColumnHeader
While .Read
Dim objCells(intCol) As Object
.GetValues(objCells)
DataGridViewProducts.Rows.Add(objCells)

End While
.Close()
End If
End With
Dec 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Cybertof | last post by:
Hello, Could someone please explain me the difference between the 2 interfaces IComparable and IComparer ? In which cases use one or the other ? Are they dedicated to own classes or built-in...
1
by: raffelm | last post by:
In the first class below, I get an error that AnotherClientBaseDataRecord does not implement IComparable.CompareTo(object)...yet the second class below is implemented identicially and it does get...
2
by: preport | last post by:
Hopefully someone can clarify some of this for me. I am confused on what classes I should implement if I want to utilize the List<>.BinarySearch() and Sort() My class currently looks like: ...
5
by: Disccooker | last post by:
and i'm lost. any ideas? It's an object with a public property that is an Int. i receive an Array of these objects and copy them to an arraylist. i need to sort it based on this property and i...
8
by: fniles | last post by:
I have a collection inside a class, sometimes when I add to the collection, I get the error "At least one object must implement IComparable". What does the error mean ? Thanks. Public Class...
1
by: Brett Romero | last post by:
What are the reasons to use one over the other? SortedList implements IComparer.Compare(). Why would you also want to create a SortedList class that implements IComparable.CompareTo()? I know...
2
by: John Devlon | last post by:
Hi, Could somebody please tell me how to use Icomparable in a .NET project? Like I was a 5 year old? I'm trying to sort an array of objects and I can't get it to work .... How do I modify the...
3
by: Samuel R. Neff | last post by:
You can you program against generic interfaces generically? For example, how can I make the following code which works for the non-generic interface also work for the generic counterparts? ...
0
by: soni2926 | last post by:
hi, I have a class called orders, which has a DateTime dateCreated property, telling me when each order was created. I get the orders returned to me in a collection, as an array. but now i need...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.