473,729 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.allo wsorting = 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 2529
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*******@nosp am.com> wrote in message
news:OX******** ******@TK2MSFTN GP09.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.allo wsorting = 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********@com cast.nospam.net > wrote in message
news:%2******** ********@tk2msf tngp13.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*******@nosp am.com> wrote in message
news:OX******** ******@TK2MSFTN GP09.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.allo wsorting = 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*******@nosp am.com> wrote in message
news:OX******** ******@TK2MSFTN GP09.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.allo wsorting = 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******@tampa bay.rr.com> wrote in message
news:um******** ******@tk2msftn gp13.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*******@nosp am.com> wrote in message
news:OX******** ******@TK2MSFTN GP09.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.allo wsorting = 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*******@nosp am.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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******@tampa bay.rr.com> wrote in message
news:um******** ******@tk2msftn gp13.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*******@nosp am.com> wrote in message
news:OX******** ******@TK2MSFTN GP09.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.allo wsorting = 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
2389
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 field... This grid displayes results based on users search.. public static int numberDiv; private void Page_Load(object sender, System.EventArgs e) {
0
1641
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 reading round the newsgroups, it seems that a custom 'IComparer' is the answer, but I'm not quite sure how to do this. Really, how to get at the IComparer that the DataGrid/DataView uses for sorting. Can anyone point me towards a nice example...
2
945
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 datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
1
2059
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 to scroll the table up and down or from right to the left the content of the active cell will be selected as if for copy/paste. How can I deactivate such a behaviour?
3
3127
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 sorts twice because I inserted a messagebox in the dgMouse (MouseUp) event. Before ok is pressed, the table changes from the order it was loaded to ascending order. After ok is pressed, it goes to descending. The code is below. Any idea why...
1
2350
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 page. i.e. If I have: IntegerValue StringValue CurrencyValue 0 Item 0 0 1 Item 1 1.23
8
15167
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 that seems to work for 99% of the cases where I need to disable datagrid column sorting: Private Sub datagrid_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles datagrid.MouseDown Dim pt As New Point(e.X,...
0
2088
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 help........pls urgent ========================================================= <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
1
2177
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 (LoginName,UserName) 2. the datagridview sorting is set to automatic, so when i click on the column header is sorts well. 3. i put in an event handler for the CellEndEdit Event, so whenever the user of the program changes the content of a cell in the LoginName...
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.