We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridInCell Problem.

Hello! Again, I am here with a bit wierd problem that i am facing while implementing Grid in cell (Cell Embedded Grid). In the application, each child Grid is added as Main Grid''s control at runtime (Depending on requirement). I have a context menu associated with each child grid (Same ContextMenu for all grids) and I have hooked CellDoubleClick event for child grid. I am doing same operation on DoubleClick and ContextMenu Item click, that requires CurrentCell of the child grid. The problem: On double click, every thing is working fine but on Context Menu click, sometimes it returns currentcell as (-1,-1), which is not wht I want. - I am clearing Selections on Focus Lost and Add CurrentCell to Selections on Get Focus and it adds the Previous CurrentCell that is ok with me, Does it have any affect on ContextMenu Click?. - Both events call same method, so there is no way that I have messed up with one of the methods. - Every time, user clicks a button Parent Grid, reactivates and include child grid in it again. I have tried to Remove Previous child grids from Controls. But it didn''t help me again with ContextMenu thing. I need help in this regard.

4 Replies

MA Maqsood Ahmed July 9, 2004 01:48 AM UTC

One more thing: I have using Cell and Row Selection.

AD Administrator Syncfusion Team July 9, 2004 05:35 AM UTC

Instead of trying to get the current row and column from the currentcell, you might try to get it using
int row, col;
Point pt = this.grid.PointToClient(Control.MousePosition);
if(this.grid.PointToRowCol(pt, out row, outcol, -1))
    Control.WriteLine("row {0}, col {1}", row, col);
If you see -1, -1 returned from CurrentCell.RowIndex and CurrentCell.COlIndex, then that suggests the grid is in a state without a currentcell. So, maybe the grid has not finished moving the currentcell when the contextmenu is popped up in these cases (Maybe on teh initial click to an embedded cell).

MA Maqsood Ahmed July 9, 2004 06:48 AM UTC

More wierd problem :) I am preserving the MainGird (Parent Grid) such that GridControl preserveMainGrid = new GridControl(MainGrid.Model) and later when I need new grids from scratch.. I am doing: mainGrid = new GridControl(presreveMainGrid.Model) and then adding controls (CellEmbeddedGrids) to the mainGrid. Now, when I click on ANY of the grid, it disappearing from mainGrid''s Controls i-e. It is visible on screen but I can''t access it as mainGrid''s control. For example, I have 5 child grids as parent grid''s controls. and when I activate any of the grids, mainGrid.Controls.Count reduces by 1... any views? more over do we have Clone() method for GridControl?

AD Administrator Syncfusion Team July 9, 2004 07:21 AM UTC

With code like GridControl grid1 = new GridControl(grid.Model); grid and grid1 will be sharing the same GridModel class. Any changes done to one, will affect the other. Is this what you want in your code? If not, then you need to do more work. There is no Clone method for GridModel, but it is serializable so you can get a copy with code like System.IO.MemoryStream s = new System.IO.MemoryStream(); grid.SaveBinary(s); GridControl grid1 = new GridControl(GridModel.LoadBinary(s)); s.Close();

Live Chat Icon For mobile
Up arrow icon