Help with DataGrid...

  • Thread starter Thread starter Maqsood Ahmed
  • Start date Start date
M

Maqsood Ahmed

Hello!
There is a DataGrid on a form that is populated through DataTable and
filters have been applied to through DataView. The DataTable gets
updated through some events and obviously it also reflects at the
datagrid. Now problem arises, that whenever a new record is being
inserted in the datagrid, It scrolls waywardly, that distracts the
user's view. Is there any solution that this should not happen.
Points to note:
- DataGrid is not editable.
- I am also doing blinking for some records (to show error, or a new
record).
Waiting for an early responce.

Maqsood Ahmed
Kolachi Advanced Technologies
 
Hi Maqsood,

This usually happens because of the sort set in the datagrid. For example, a
new record will probably be initially displayed at the bottom of the
datagrid. But when the user enters data in the column which is sorted, as
soon as the focus lost, the datagrid jumbles so as to maintain the sort.

You could avoid this problem
1. while inserting, set the datagrid to a 'default' sort. But this is not a
good method, because the datagrid will 'shiver' just before insertion
2. make sure that insertions happen @ some specific point only - like always
on top/bottom, or just below the current row. You could do this by
implementing your own 'background' sorting. Add a new column for the
datatable (which you will not show in the datagrid) in which you will store
the sort order. When the user sorts the datagrid, you will change the values
in this column so as to replicate the datagrid's row order. When the user
inserts data, you could set the new row's value as the max value or min value
(so as to put it in the bottom or top respectively).

And Maqsood, by blinking, do you mean you are using the error control?

HTH,
Rakesh Rajan
 
Back
Top