Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
163
Problem in Pasting Data in Grid
posted

Hi All,

I have a situation in code, where the UltraGrid is being used in Load on Demand mode (Virtual Mode) by using the Ultra Data Source where the underlying source is a Data Table.

Now the total rows returned by the source DB are near 2000. I have implemented a functionality where the user can jump to a cell down in grid by using a small tool "Go To" just as in Excel. I copied the content of the first cell in first column ( this  columns contains date data) and then used the "Go To" tool to jumped to Column 0 and Row 1360 in Grid. I did so by using the following code:

<Code>

private void ActivateCell(int RowIndex, string ColName) 

        this.resultsGrid.ActiveRowScrollRegion.ScrollPosition = RowIndex;
        this.resultsGrid.ActiveRow = this.resultsGrid.Rows[RowIndex];
        this.resultsGrid.ActiveCell = this.resultsGrid.Rows[RowIndex].Cells[ColName];
        this.resultsGrid.Rows[RowIndex].Cells[ColName].Activate();
        this.resultsGrid.Rows[RowIndex].Cells[ColName].Selected = this.resultsGrid.Rows[RowIndex].Cells[ColName].Activate();

</Code> 

 Now the real problem is that as I copied the contents of the first cell and now when I try to paste it in the zero(th) cell in 1360th row, it jumps back to the first cell. The paste command is being used by UltraGrid.PerformAction(UltraGridAction.Paste). I also stepped through the code here that which cell was the active on before PerformAction line o code and it was the 1360th Row and its zero cell.

Can anyone guide me where am I wrong or if there is some other way to handle this?

 

Due Regards,

Talha Muhammad 

 

Parents
  • 469350
    Offline posted

     I'm a little puzzled by the last line of code you have here. You are activating the cell twice... are you sure the second time is returning true? Maybe it returns false since the cell was already active and so the second call to Activate doesn't do anything. 

    The paste action deals with the Selected cell(s) in the grid and only works if AllowMultiCellOperation is on. So if you are pasting a value from one cell into another, you might be better off just setting the cell's Value. 

    I'm not sure why the grid is jumping back to the first row. Perhaps the grid is processing this code asynchronously and not updating the active cell until after the grid paints. Is the paste being performed synchronously in code or is the user taking some other action (like clicking a button) to do it? 

Reply Children