473,385 Members | 1,720 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,385 software developers and data experts.

Sorting in datagrid

DKC
Hi,

Using VB.NET.

I have a datagrid having a strongly typed array of objects as its data
source.
The data from the array of objects is displayed by means of a table style,
which is fine, but I cannot sort the data when I click on the column header.
I have set the tablestype.allowsorting = true, but this has no effect.

On the other hand, when I set the datasource to a data table, sorting works
on column header click.

What should I do to get the table sorting to wotk with the array of objects?

Thanks
DKC
Nov 20 '05 #1
5 2493
I'm not sure exactly what the problem is, but the grid is getting some
indication not to sort even though it sounds like a Single table bind.
There will be no functional difference whatsoever between binding to the
only table in a one table dataset and a dataset (what I mean is that you
won't lose anything) so go ahead an make the change. You may also want to
consider binding to a dataview, you can do quite a bit with them too without
losing any functionality.

HTH,

Bill
www.devbuzz.com
www.knowdotnet.com
"DKC" <an*******@nospam.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...
Hi,

Using VB.NET.

I have a datagrid having a strongly typed array of objects as its data
source.
The data from the array of objects is displayed by means of a table style,
which is fine, but I cannot sort the data when I click on the column header. I have set the tablestype.allowsorting = true, but this has no effect.

On the other hand, when I set the datasource to a data table, sorting works on column header click.

What should I do to get the table sorting to wotk with the array of objects?
Thanks
DKC

Nov 20 '05 #2
DKC
Hi Bill,

The datagrid sorts when I map it to a data table.
However, when I map the datagrid to an array of objects ( class[] ), I
cannot sort on column header click.

Regards,
DKC

"William Ryan eMVP" <do********@comcast.nospam.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm not sure exactly what the problem is, but the grid is getting some
indication not to sort even though it sounds like a Single table bind.
There will be no functional difference whatsoever between binding to the
only table in a one table dataset and a dataset (what I mean is that you
won't lose anything) so go ahead an make the change. You may also want to
consider binding to a dataview, you can do quite a bit with them too without losing any functionality.

HTH,

Bill
www.devbuzz.com
www.knowdotnet.com
"DKC" <an*******@nospam.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...
Hi,

Using VB.NET.

I have a datagrid having a strongly typed array of objects as its data
source.
The data from the array of objects is displayed by means of a table style, which is fine, but I cannot sort the data when I click on the column

header.
I have set the tablestype.allowsorting = true, but this has no effect.

On the other hand, when I set the datasource to a data table, sorting

works
on column header click.

What should I do to get the table sorting to wotk with the array of

objects?

Thanks
DKC


Nov 20 '05 #3
I find using DataViews as a data source for DataGrids works better for me
when I want to sort the DataGrid.

"DKC" <an*******@nospam.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...
Hi,

Using VB.NET.

I have a datagrid having a strongly typed array of objects as its data
source.
The data from the array of objects is displayed by means of a table style,
which is fine, but I cannot sort the data when I click on the column header. I have set the tablestype.allowsorting = true, but this has no effect.

On the other hand, when I set the datasource to a data table, sorting works on column header click.

What should I do to get the table sorting to wotk with the array of objects?
Thanks
DKC

Nov 20 '05 #4
DKC
Hi William,

My front-end screen calls an assembly that returns an array of structures.
I don't want to transfer the contents of the array into a
data-table/data-view, as it is an additional overhead that I would rather do
without.
Instead, I am using the array as the datasource to the datagrid. I have
mapped the table style for the datagrid to the class[], the datagrid gets
populated with the data. It works, except for the sort.
When I DO put the data in the array of structures into a datatable and I map
the tablestyle to the datatable name, the sorting works.

Why does it not work if I use the array of structures directly?

Regards,
DKC

"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:um**************@tk2msftngp13.phx.gbl...
I find using DataViews as a data source for DataGrids works better for me
when I want to sort the DataGrid.

"DKC" <an*******@nospam.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...
Hi,

Using VB.NET.

I have a datagrid having a strongly typed array of objects as its data
source.
The data from the array of objects is displayed by means of a table style, which is fine, but I cannot sort the data when I click on the column

header.
I have set the tablestype.allowsorting = true, but this has no effect.

On the other hand, when I set the datasource to a data table, sorting

works
on column header click.

What should I do to get the table sorting to wotk with the array of

objects?

Thanks
DKC


Nov 20 '05 #5
My guess is that you may save a bit on memory by using arrays, but I see no
way to sort using an array as the data source (that is not to say there
isn't one).

To be able to sort, if I had my data in an array, then I would convert it
to a DataTable and then create a DataView from that table, but then you are
right back where you don't want to be.
"DKC" <an*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi William,

My front-end screen calls an assembly that returns an array of structures.
I don't want to transfer the contents of the array into a
data-table/data-view, as it is an additional overhead that I would rather do without.
Instead, I am using the array as the datasource to the datagrid. I have
mapped the table style for the datagrid to the class[], the datagrid gets
populated with the data. It works, except for the sort.
When I DO put the data in the array of structures into a datatable and I map the tablestyle to the datatable name, the sorting works.

Why does it not work if I use the array of structures directly?

Regards,
DKC

"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:um**************@tk2msftngp13.phx.gbl...
I find using DataViews as a data source for DataGrids works better for me
when I want to sort the DataGrid.

"DKC" <an*******@nospam.com> wrote in message
news:OX**************@TK2MSFTNGP09.phx.gbl...
Hi,

Using VB.NET.

I have a datagrid having a strongly typed array of objects as its data
source.
The data from the array of objects is displayed by means of a table

style, which is fine, but I cannot sort the data when I click on the column

header.
I have set the tablestype.allowsorting = true, but this has no effect.

On the other hand, when I set the datasource to a data table, sorting

works
on column header click.

What should I do to get the table sorting to wotk with the array of

objects?

Thanks
DKC



Nov 20 '05 #6

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

Similar topics

12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
0
by: Chris Mayers | last post by:
I have a Windows Forms DataGrid that has a DataView as a datasource. My problem is that I want the datagrid to exhibit some special sorting properties when the header rows are clicked on. From...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: Sargas Atum | last post by:
Hi all, 1. I have a problem with cell selection in a table in a DataGrid. I dont want that anybody writes in the cells. That was not a problem I changed them to "read only", but if I am going...
3
by: melanieab | last post by:
Hi, I'm programatically sorting in a datagrid. When a column header is clicked, the sort happens twice for some reason, making it looks like it only sorts in descending order. I can tell it...
1
by: Jeremy | last post by:
I want my gird to sort only the items on the current page when I click on a column header. I wrote a little test app, but when I sort it pulls in items from other pages and places them on the current...
8
by: simchajoy2000 | last post by:
I thought the only thing I had to do to disable column sorting in VB.NET was to set datagrid.AllowSorting = False. Unfortunately this has never worked for me. I discovered another set of code...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.