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
105
Excel Autofill option
posted

Hi

  I have one requirement  i.e Excel type auto fill option.For example 1 numeric in 1 st row 1 st cell in inftagustics win grid,when i selected that cell for auto fill option drag drown(like excel auto fill),below cell is filled with 2,3,4.................until where i stopped Drag.Same requirement i need in infragistics win grid.please let me know there is any option avaialble in Grid and suggest me any poss related to this requirement ,please post  related URl

Thanks

Durgaprasad.k

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    There's no functionality for auto-fill built into the grid. But you could implement this yourself very easily.

    What I would do is set up the grid to allow selecting ranges of cell. You do this using grid.DisplayLayout.Override.SelectTypeCell and also the CellClickAction property.

    Then you could use the grid's MouseUp event and trap for a right-click on the selected cells and give the user a context menu to auto-fill. Or you could use a button or a toolbar button or whatever UI you like to trigger the auto-fill.

    To perform the fill operation, you would do something like this:


                SelectedCellsCollection selectedCells = this.ultraGrid1.Selected.Cells;
                if (selectedCells.Count < 2)
                    return;
               
                // It would probably be a good idea to verify that all of the selected cells
                // belong to the same column here. Alternately, this could also be enforced using the
                // BeforeSelectChange event.

                // Sort the selected cells in the visible order
                selectedCells.Sort();

                // We are assuming the column is an integer
                int value = (int)selectedCells[0].Value;

                for (int index = 1; index < selectedCells.Count; index++)
                {
                    value++;
                    selectedCells[index].Value = value;
                }

Children
No Data