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
close icon

Display element''s position in the grid/ edit functions

In the following loop of code: foreach(Element theElement in grid.Table.DisplayElements) { if(theElement is CustomCaptionRow) { \\some action} } Is it possible to make that element the current row of the grid (move the grid cursor to that element and highlight the row)? A second question.... How can a user copy the values in a grid cell (either a record row or a summary row) and paste them to either another cell in the grid or another application? Thanks.

15 Replies

AD Administrator Syncfusion Team March 22, 2005 09:25 PM UTC

Hi Anthony, you should be able to call if(theElement is CustomCaptionRow) { theElement.ParentTable.CurrentRecordManager.NavigateTo(theElement); } Does that not work for you? In order to highlight the row you might need to handle TableControlPrepareViewStyleInfo. There you can check if the style.TableCellIdentity.DisplayElement is the the CurrentElement and then change the back color of the style. I can create a sample if needed. WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? Accross multiple rows is much trickier. Do you need that? Stefan >In the following loop of code: > >foreach(Element theElement in grid.Table.DisplayElements) > { > if(theElement is CustomCaptionRow) > { \\some action} >} > >Is it possible to make that element the current row of the grid (move the grid cursor to that element and highlight the row)? > >A second question.... >How can a user copy the values in a grid cell (either a record row or a summary row) and paste them to either another cell in the grid or another application? > >Thanks. >


AA Anthony Avella March 23, 2005 02:27 PM UTC

Please create samples for all mentioned. Thanks much. >Hi Anthony, > >you should be able to call > >if(theElement is CustomCaptionRow) >{ >theElement.ParentTable.CurrentRecordManager.NavigateTo(theElement); >} > >Does that not work for you? > >In order to highlight the row you might need to handle TableControlPrepareViewStyleInfo. There you can check if the style.TableCellIdentity.DisplayElement is the the CurrentElement and then change the back color of the style. > >I can create a sample if needed. > >WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? > >Accross multiple rows is much trickier. Do you need that? > >Stefan > > > > >>In the following loop of code: >> >>foreach(Element theElement in grid.Table.DisplayElements) >> { >> if(theElement is CustomCaptionRow) >> { \\some action} >>} >> >>Is it possible to make that element the current row of the grid (move the grid cursor to that element and highlight the row)? >> >>A second question.... >>How can a user copy the values in a grid cell (either a record row or a summary row) and paste them to either another cell in the grid or another application? >> >>Thanks. >>


AA Anthony Avella March 23, 2005 02:45 PM UTC

ps theElement.ParentTable.CurrentRecordManager.NavigateTo(theElement); does not work >Hi Anthony, > >you should be able to call > >if(theElement is CustomCaptionRow) >{ >theElement.ParentTable.CurrentRecordManager.NavigateTo(theElement); >} > >Does that not work for you? > >In order to highlight the row you might need to handle TableControlPrepareViewStyleInfo. There you can check if the style.TableCellIdentity.DisplayElement is the the CurrentElement and then change the back color of the style. > >I can create a sample if needed. > >WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? > >Accross multiple rows is much trickier. Do you need that? > >Stefan > > > > >>In the following loop of code: >> >>foreach(Element theElement in grid.Table.DisplayElements) >> { >> if(theElement is CustomCaptionRow) >> { \\some action} >>} >> >>Is it possible to make that element the current row of the grid (move the grid cursor to that element and highlight the row)? >> >>A second question.... >>How can a user copy the values in a grid cell (either a record row or a summary row) and paste them to either another cell in the grid or another application? >> >>Thanks. >>


AD Administrator Syncfusion Team March 23, 2005 03:19 PM UTC

You didn''t answer my question ... >> >>WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? >> >>Accross multiple rows is much trickier. Do you need that? >> What are your requirements? Thanks, Stefan


AA Anthony Avella March 23, 2005 04:42 PM UTC

Sorry, my anwser should''ve been clearer... I''d like to copy/paste across both multiple cells and rows. >You didn''t answer my question ... > >>> >>>WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? >>> >>>Accross multiple rows is much trickier. Do you need that? >>> > >What are your requirements? > >Thanks, >Stefan


AA Anthony Avella March 23, 2005 05:13 PM UTC

My requirements: 1- To copy a single cell value (detail, summary or group caption cell) to another cell. 2- To copy multiple cell values (one or many whole column''s worth of cells, or multiple rows of cells) and paste them to another app (notepad, textpad, etc...). >You didn''t answer my question ... > >>> >>>WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? >>> >>>Accross multiple rows is much trickier. Do you need that? >>> > >What are your requirements? > >Thanks, >Stefan


AA Anthony Avella March 24, 2005 07:29 PM UTC

Hi. What is the status of these issues? >My requirements: > >1- To copy a single cell value (detail, summary or group caption cell) to another cell. > >2- To copy multiple cell values (one or many whole column''s worth of cells, or multiple rows of cells) and paste them to another app (notepad, textpad, etc...). > >>You didn''t answer my question ... >> >>>> >>>>WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? >>>> >>>>Accross multiple rows is much trickier. Do you need that? >>>> >> >>What are your requirements? >> >>Thanks, >>Stefan


AD Administrator Syncfusion Team March 28, 2005 03:30 PM UTC

WRT to the NavigateTo problem. I added these lines to the sample: foreach (Element el in this.gridGroupingControl1.Table.DisplayElements) { if (el is ExtraSection) { el.ParentTable.CurrentRecordManager.NavigateTo(el); break; } } This seems to work find. What are you doing different? Can you modify the attached sample to show the problem? CS.zip I still need to work on a copy/paste sample. I will get back as soon as I have this. Stefan >Hi. What is the status of these issues? > >>My requirements: >> >>1- To copy a single cell value (detail, summary or group caption cell) to another cell. >> >>2- To copy multiple cell values (one or many whole column''s worth of cells, or multiple rows of cells) and paste them to another app (notepad, textpad, etc...). >> >>>You didn''t answer my question ... >>> >>>>> >>>>>WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? >>>>> >>>>>Accross multiple rows is much trickier. Do you need that? >>>>> >>> >>>What are your requirements? >>> >>>Thanks, >>>Stefan


AD Administrator Syncfusion Team April 1, 2005 06:24 AM UTC

>>>My requirements: >>> >>>1- To copy a single cell value (detail, summary or group caption cell) to another cell. >>> >>>2- To copy multiple cell values (one or many whole column''s worth of cells, or multiple rows of cells) and paste them to another app (notepad, textpad, etc...). >>> To be able to paste text into cells you could handle the PasteCellText event together with AllowSelection = GridSelectionFlags.Any. I assume you already implemented IGridTableCellStyleChanged.RaiseTableCellStyleChanged for those caption summary cells that you allow users to modify. The RaiseTableCellStyleChanged will be called after the PasteCellText event was raised. So, you could either save the pasted value in your store in the PasteCellText event or do it in your RaiseTableCellStyleChanged implementation. Stefan this.gridGroupingControl1.TableModel.PasteCellText += new GridPasteCellTextEventHandler(TableModel_PasteCellText); this.gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Any; private void TableModel_PasteCellText(object sender, GridPasteCellTextEventArgs e) { Console.WriteLine("TableModel_PasteCellText: " + e.ToString()); GridTableCellStyleInfo style = (GridTableCellStyleInfo) e.Style; Element el = style.TableCellIdentity.DisplayElement; if (el is CaptionRow || el is CaptionSection) { Group g = el.ParentGroup; Console.WriteLine("Save text for grop {0} into storage for group summaries that you should have provided when you implemented IGridTableCellStyleChanged.RaiseTableCellStyleChanged", g.ToString()); } } Sample is here: CS.zip Stefan


AA Anthony Avella April 4, 2005 07:42 PM UTC

WRT navigation: The call to el.ParentTable.CurrentRecordManager.NavigateTo(el); doesn''t highlight this display element for me. >WRT to the NavigateTo problem. I added these lines to the sample: > > > foreach (Element el in this.gridGroupingControl1.Table.DisplayElements) > { > if (el is ExtraSection) > { > el.ParentTable.CurrentRecordManager.NavigateTo(el); > break; > } > } > > >This seems to work find. What are you doing different? Can you modify the attached sample to show the problem? > >CS.zip > >I still need to work on a copy/paste sample. I will get back as soon as I have this. > >Stefan > >>Hi. What is the status of these issues? >> >>>My requirements: >>> >>>1- To copy a single cell value (detail, summary or group caption cell) to another cell. >>> >>>2- To copy multiple cell values (one or many whole column''s worth of cells, or multiple rows of cells) and paste them to another app (notepad, textpad, etc...). >>> >>>>You didn''t answer my question ... >>>> >>>>>> >>>>>>WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? >>>>>> >>>>>>Accross multiple rows is much trickier. Do you need that? >>>>>> >>>> >>>>What are your requirements? >>>> >>>>Thanks, >>>>Stefan


AD Administrator Syncfusion Team April 4, 2005 09:33 PM UTC

Ok, I assume you are using AllowSelection mode. With that mode you can manully force highlight a record by doing this: int rowIndex = el.ParentTable.DisplayElements.IndexOf(el); grid.TableModel.Selections.Add(GridRangeInfo.Row(rowIndex); Now the row should be drawn highlighted. Stefan >WRT navigation: >The call to el.ParentTable.CurrentRecordManager.NavigateTo(el); > doesn''t highlight this display element for me. > > >>WRT to the NavigateTo problem. I added these lines to the sample: >> >> >> foreach (Element el in this.gridGroupingControl1.Table.DisplayElements) >> { >> if (el is ExtraSection) >> { >> el.ParentTable.CurrentRecordManager.NavigateTo(el); >> break; >> } >> } >> >> >>This seems to work find. What are you doing different? Can you modify the attached sample to show the problem? >> >>CS.zip >> >>I still need to work on a copy/paste sample. I will get back as soon as I have this. >> >>Stefan >> >>>Hi. What is the status of these issues? >>> >>>>My requirements: >>>> >>>>1- To copy a single cell value (detail, summary or group caption cell) to another cell. >>>> >>>>2- To copy multiple cell values (one or many whole column''s worth of cells, or multiple rows of cells) and paste them to another app (notepad, textpad, etc...). >>>> >>>>>You didn''t answer my question ... >>>>> >>>>>>> >>>>>>>WRT to the copy/paste I''ll create a sample. Should this support pasting accross multiple rows or only multiple cells within one record? >>>>>>> >>>>>>>Accross multiple rows is much trickier. Do you need that? >>>>>>> >>>>> >>>>>What are your requirements? >>>>> >>>>>Thanks, >>>>>Stefan


LJ Luis Javier Mompart June 21, 2005 04:02 PM UTC

hi, and many thanks both works really fine !!! ( i was just having a problem activating extrasection ) would you please tell me howto navigate through grid rows to the next extrasection I am using TableControl_QueryNextCurrentCellPosition to handle my movements.


AD Administrator Syncfusion Team June 21, 2005 08:34 PM UTC

Hi Luis, try to handle the QueryAllowArrowKeyNavigateTo event. In your event handler you can check if e.Element is ExtraSection and in that case set e.AllowNavigateTo = true Stefan >hi, and many thanks both > >works really fine !!! ( i was just having a problem activating extrasection ) > >would you please tell me howto navigate through grid rows to the next extrasection >I am using TableControl_QueryNextCurrentCellPosition to handle my movements. > >


LJ Luis Javier Mompart June 22, 2005 06:42 AM UTC

seems works fine, but iam using enter key to move from one section to another, is it another event to hook?, or am i have to work around this?


AD Administrator Syncfusion Team June 24, 2005 07:14 PM UTC

Hi Luis, the QueryAllowArrowKeyNavigateTo event still needs to be handled. In addition to that you could handle the CurrentCellKeyDown, e.g. private void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e) { if (e.Inner.KeyCode == Keys.Enter) { Console.WriteLine("Enter"); e.Inner.Handled = true; Element current = e.TableControl.Table.CurrentElement; int index = e.TableControl.Table.DisplayElements.IndexOf(current); if (index != -1) { int count = e.TableControl.Table.DisplayElements.Count; while (++index < count) { Element el = e.TableControl.Table.DisplayElements[index]; // search for the next CustomSectionRow if (el is CustomSectionRow) { e.TableControl.CurrentCell.MoveTo(index, e.TableControl.CurrentCell.ColIndex); e.TableControl.InvalidateElement(el); return; } } } } } Stefan >seems works fine, but iam using enter key to move from one section to another, is it another event to hook?, or am i have to work around this?

Loader.
Live Chat Icon For mobile
Up arrow icon