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

PasteCellText Event

I think i''ve asked this before but i cant find any reference to it if I have. Can you explain why the pastecelltext event only seems to fire in currency cells and not text cells(unless coming from excel) in the sample I''ve attached. If you click cell 1,1 and then ctrl-c, and then click cell 1,2 and hit ctrl-v. it gives u the the messagebox i told it to pop up. now if you click cell 1,2 and then ctrl-c and then click cell 1,1 and then ctrl-v it wont do anything. it never goes to the pastecelltext event and i cant figure out why. the odd thing is that if i go to excel and copy 1 cell of 3 x''s from one cell to cell 1,1 in the grid then it will go to the pastecelltext event. Is this how its suppose to work or am i missing something or doing something wrong? I will email the sample.

3 Replies

AD Administrator Syncfusion Team April 18, 2005 05:23 PM UTC

The cell renderer class has a virtual method, Paste(), that is given first crack at handling the Paste of 1x1 text into a cell. Both the TextBox cell type and the OriginalCellType actually have this Paste overridden at this point so it can activate the editing on the single cell and put the text into the cell renderer. If the cellrenderer.Paste returns false, the paste is passed onto the grid. This is what happens with the Currency cellrenderer. This renderer derives from the static cell renderer and does not override this Paste method so the grid ultimately handles 1-cell pastes into these cells, and that gives rise to the PasteCellText event. So for now if you want this behavior for the Text cells, you can derive the cell model and cell renderer classes. In the renderer class, override Paste and return false. This will forward the paste onto the grid. I think the reason you see the behavior from excel is that when you copy a cell in excel it puts linefeed after the copied text. You can see this if you paste the text from excel into say Notepad. The cursor ends under the text. If you type XXX into notepad and copy just teh XXX and not the newline, then pasting into the grid will miss the PasteCellText event. With Excel, one cell is really 1 cell + newline. So, this could be another work around without deriving the cell control. You could handle Copy in teh grid, and if it is a single cell being copied, add the newline. I think deriving teh cell control is the way to handle this. I will discuss this with Stefan to see if there is something we could do, but I really think tings are working as intended right now, maybe with the exception of the Currency celltype not handling Paste to make it behave like teh Text and OriginalTextBox cells.


AD Administrator Syncfusion Team April 18, 2005 07:50 PM UTC

Are there any good examples of this in VB?


AD Administrator Syncfusion Team April 18, 2005 09:01 PM UTC

Do a search for CellModels.Add in the sample folder we ship. You will find 20+ VB hits for this method which is how custom cell types are registered with the grid. Each use will be a sample of a custom cell. There is also a section in the grid user''s guide on deriving cell controls, Essential Grid\Features inDepth\Deriving a cell control. This is the sample discussed in the user''s guide: \Windows\Grid.Windows\Samples\CellTypes\LinkLabelCells

Loader.
Live Chat Icon For mobile
Up arrow icon