moving rows in dataset

S

Sam

Hi,
I have a datagrid which datasource is a dataset.
I want to add a spin button to my form so that when the user click on
the up arrow, the selected row in the grid will be moved up by one
(same if the user click the down arrow). Has anybody done that before ?
Is it possible ? It seems quite hard, is the changes made to the
dataset going to be reflected to the grid ?


Thx
 
K

Ken Tucker [MVP]

Hi,

Maybe this will help
http://64.78.52.104/FAQ/WinForms/FAQ_c44c.asp#q832q

Ken
-------------------
Hi,
I have a datagrid which datasource is a dataset.
I want to add a spin button to my form so that when the user click on
the up arrow, the selected row in the grid will be moved up by one
(same if the user click the down arrow). Has anybody done that before ?
Is it possible ? It seems quite hard, is the changes made to the
dataset going to be reflected to the grid ?


Thx
 
C

Cor Ligthert

Sam,

You asked for a simple way.

When you want to use a difficult way, than I would use an extra datacolumn.
Loop in that a rownumber, set the defaultview on that, and swap the numbers.

And then use gridstyles to show the columns you want to show in the
datagrid.

Just my idea not tested,

Cor
 
S

Sam

sounds good. But I still prefer the method in the thread which i gave
the link above, it's more generic and easy to reuse for any grid.

thx
 
C

Cor Ligthert

Sam,
sounds good. But I still prefer the method in the thread which i gave
the link above, it's more generic and easy to reuse for any grid.
Now I see it, I thought he was swapping the rows, however he is swapping the
data inside it I see now. A clever method yes.

However, when you use this dataset to update, take than care by the way of
the rowstates because this will set now both swapped rows to changed and I
don't know if that is your goal. I assume that you can get as well get some
trouble with new rows or with rows with a rowstate deleted when those exist
in the dataset.

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