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.
Unfortunately, activation email could not send to your email. Please try again.

How do I clear grid data and styles

Thread ID:

Created:

Updated:

Platform:

Replies:

1924 Dec 4,2002 11:03 AM Dec 5,2002 09:02 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 4, 2002 11:03 AM

Hi, I am using GridControl. I have some styles (borders, interior, text color etc.) set to some of the cells. How do I clear all the data in my grid and the cell styles? Another question: When the user tries to copy some text containing tabs in the text, GridControl automagically adds new columns (one per tab character). When the user hits Ctrl+V, I want to paste the text with tabs, newline chars or whatever chars they have in the clipboard into the current cell. I tried: grid.Model.CutPaste.ClipboardFlags = GridDragDropFlags.Text | GridDragDropFlags.NoAppendCols | GridDragDropFlags.NoAppendRows; It no longer adds rows, columns. But unfortunately the clipboard text is chopped off at the first tab. How do I paste all the text? Thanks, - Reddy

Administrator [Syncfusion]
Replied On December 4, 2002 02:06 PM

> Hi, > > I am using GridControl. > > I have some styles (borders, interior, text color etc.) set to some of the cells. How do I clear all the data in my grid and the cell styles? > > Another question: > When the user tries to copy some text containing tabs in the text, GridControl automagically adds new columns (one per tab character). When the user hits Ctrl+V, I want to paste the text with tabs, newline chars or whatever chars they have in the clipboard into the current cell. > > I tried: > grid.Model.CutPaste.ClipboardFlags = GridDragDropFlags.Text | GridDragDropFlags.NoAppendCols | GridDragDropFlags.NoAppendRows; > > It no longer adds rows, columns. But unfortunately the clipboard text is chopped off at the first tab. > How do I paste all the text? > > Thanks, > - Reddy > Hi Reddy, to clear and remove the rows you can call RemoveRows or set RowCount = 0. If you just want to empty the cells then call ClearCells(range); whereas range can be GridRangeInfo.Cells(row1, col1, row2, col2). Check out the ClipboardPaste event. There you can get the data from the clipboard and set them for the current cell. Don't forget to set e.Handled = true! The following line will get you the text in the clipboard: IDataObject iData = Clipboard.GetDataObject(); string psz = iData.GetData(DataFormats.Text) as string; Stefan

Administrator [Syncfusion]
Replied On December 4, 2002 02:59 PM

Hi Stefan, Regarding clearing of cells: Setting grid.RowCount = 0 does clear both styles and data. I tried the following to clear the styles: grid.Clear(true); grid.Clear(false); It does not work. It still remembers the old styles. Is there something I am missing? Regarding Paste: I tried the ClipboardPaste event and it works. But i think it is very odd to let the user paste values over a "Static" or "Header" type cell, which defeats the purpose. You may want to change it. Try pasting over different type of cells in "Cell Types" demo. Thanks for you help, - Reddy

Administrator [Syncfusion]
Replied On December 4, 2002 03:39 PM

> Hi Stefan, > > Regarding clearing of cells: > Setting grid.RowCount = 0 does clear both styles and data. I tried the following to clear the styles: > grid.Clear(true); > grid.Clear(false); > It does not work. It still remembers the old styles. Is there something I am missing? > > Regarding Paste: > I tried the ClipboardPaste event and it works. But i think it is very odd to let the user paste values over a "Static" or "Header" type cell, which defeats the purpose. You may want to change it. Try pasting over different type of cells in "Cell Types" demo. > > Thanks for you help, > - Reddy > Hi Stefan, There is a side affect for this paste event though. Here is my ClipboardPaste event handler: string str = Clipboard.GetDataObject().GetData(DataFormats.Text) as string; grid.CurrentCell.Renderer.ControlText = str; e.Handled = true; Now my cell's text is replaced with the pasted contents. I want to insert the pasted text at the current I-Beam location in the cell's textbox. How do I do that? thanks, - Reddy

Administrator [Syncfusion]
Replied On December 4, 2002 04:08 PM

Try ClearCells(), not Clear(). When you call Clear() you would first have to select the cells with a SelectRange() command (or with the mouse). You could call ClearCells passing GridRangeInfo.Table as argument. Re Clipboard - Try CurrentCell.Renderer.Paste Stefan

Administrator [Syncfusion]
Replied On December 5, 2002 09:02 AM

Hi Stefan, ClearCells() and Paste() worked. thanks, - Reddy

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;