Q: DataGrid Sort

G

G .Net

Hi

I have a question which I hope you can help with.

I am setting the DataSource of a DataGrid to be a DataView. I am sorting the
DataView by various fields which include a Date.

When I create a new row in the DataGrid and set the date to me within the
current sort range, the newly created row "jumps" to its correct position in
the grid. This obviously makes sense because it is following the sort rule.

However, I would like to be able to achive the following:

(1) Display the DataView in the DataGrid initially sorted using the rules
specified.
(2) New rows can be added to the DataGrid BUT no sorting will occur.
(3) If a button is pressed, then the grid will re-sort using the sort rule
specified initially.

I don't know if it makes any difference but the DataView I am using is
global to the form.

I hope somebody can help.

Many thanks in advance

G
 
C

Cor Ligthert [MVP]

Hi,

Be aware that this acts probably different in versions 2002/2003 and 2005

The dataview should be dynamic but is that not always in 2002/2003

As well is there a bug that put a newly added datarow at the end in some
situations of the datagrid. Exactly in fact as you want.

But making use of that bug is not the best thing to do.

I hope that you understand because of this that your question is difficult
answer

Cor
 
G

G .Net

Hi Cor

I'm using VS 2003.

I think I understand what you mean, however, just to clarify, are you saying
what I want to do is impossible?

G
 
C

Cor Ligthert [MVP]

G,

You can forever add an extra column and set in that a default value.

When you add it you set this column to a vale which is higer than the
default value.
You take that your dataview as first sort key.
If the button is pressed than you can change that column in the last datarow
in the datatable again to the default value..

The last row is datatable.rows(datatable.rowcount-1)

Not that difficult in my opinion and as far as I can see now will that work
forever.

I hope this helps,

Cor
 
G

G .Net

Thanks Cor

G

Cor Ligthert said:
G,

You can forever add an extra column and set in that a default value.

When you add it you set this column to a vale which is higer than the
default value.
You take that your dataview as first sort key.
If the button is pressed than you can change that column in the last
datarow in the datatable again to the default value..

The last row is datatable.rows(datatable.rowcount-1)

Not that difficult in my opinion and as far as I can see now will that
work forever.

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top