the position of new added row in datagrid

B

Bamse

hi, i have this problem:

at runtime i add rows to a grid (actually to a datatable, that the grid is
binded to)
but the row is added down, after the existing rows and i want it to be the
first shown in grid;

i tried with dataview.sort = "<field> DESC"; but it didn't work
i tried using

dv.ListChanged += new
System.ComponentModel.ListChangedEventHandler(DataView_ListChanged);
protected virtual void DataView_ListChanged(object sender,
System.ComponentModel.ListChangedEventArgs args)
{
if ( (args.ListChangedType == ListChangedType.ItemAdded) |
(args.ListChangedType == ListChangedType.ItemDeleted) )
{
CurrencyManager cm = (CurrencyManager)this.BindingContext[DataSet,
the Relation];
DataView dv = (DataView)cm.List;
dv.Sort = "Position DESC";
cm.refresh();
this.grid.SetDataBinding(null, null);
this.grid.SetDataBinding(DocDataSet, "theRelation");
}

but that didn't worked either

what's wrong?

Thank you,
Daniel
 
G

Guest

In order to counter this and some connected problems in one of my projects, I added a new field which held row positions. When a new row is added, I set the field's value to the least interger amongst the rows which makes appear on top of the datagrid. If you want I could post the code

HTH
fbhca
 
B

Bamse

i thought of this too, but i wanted to use less user-code; what's the .NET
good at, after all? ;)
thanks

fbhcah said:
In order to counter this and some connected problems in one of my
projects, I added a new field which held row positions. When a new row is
added, I set the field's value to the least interger amongst the rows which
makes appear on top of the datagrid. If you want I could post the code.
 
G

Guest

..NET is not just a datagrid ;).

It's a whole new WORLD with loads of renovations and revolutions


----- Bamse wrote: ----

i thought of this too, but i wanted to use less user-code; what's the .NE
good at, after all? ;
thank

fbhcah said:
In order to counter this and some connected problems in one of m
projects, I added a new field which held row positions. When a new row i
added, I set the field's value to the least interger amongst the rows whic
makes appear on top of the datagrid. If you want I could post the code
 

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