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
AD
Administrator
Syncfusion Team
December 4, 2002 07:06 PM UTC
> 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
AD
Administrator
Syncfusion Team
December 4, 2002 07:59 PM UTC
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
AD
Administrator
Syncfusion Team
December 4, 2002 08:39 PM UTC
> 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
AD
Administrator
Syncfusion Team
December 4, 2002 09:08 PM UTC
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
AD
Administrator
Syncfusion Team
December 5, 2002 02:02 PM UTC
Hi Stefan,
ClearCells() and Paste() worked.
thanks,
- Reddy