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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

programmatically calling the button click event in a cell of type pushbutton

Thread ID:

Created:

Updated:

Platform:

Replies:

16861 Jul 26,2004 01:31 PM UTC Jul 26,2004 03:56 PM UTC WinForms 5
loading
Tags: GridControl
Ted Osberg
Asked On July 26, 2004 01:31 PM UTC

How can I programmatically fire the Button click event on a cell that has a celltype of pushbutton? Not only would the event fire when the user clicks on the button, but I would also like the event to fire when the user presses the Enter/Return key while in the cell. Thanks!

Administrator [Syncfusion]
Replied On July 26, 2004 02:08 PM UTC

Here is one way you can do it by faking a click on the cell. //click cell 4,4 this.gridControl1.Focus(); Point pt = this.gridControl1.ViewLayout.RowColToPoint(4, 4, true, GridCellSizeKind.ActualSize); pt.Offset(3,3); //move it a little Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(this.gridControl1, pt);

Ted Osberg
Replied On July 26, 2004 03:00 PM UTC

Actually, I made a mistake. The celltype is actually EllipsesText (from your example) and only takes up the last 20 pixels of the column width. I tried your example and it doesn''t work, even when I offset the point n pixels. I get a round circle with line thru it whenever I hit the enter or return key. Any suggestions on this one? Thanks!

Ted Osberg
Replied On July 26, 2004 03:08 PM UTC

Is there a way for me to get a handle to the EllipseText button itself?

Administrator [Syncfusion]
Replied On July 26, 2004 03:53 PM UTC

Actually, I made a mistake. The celltype is actually EllipsesText (from your example) and only takes up the last 20 pixels of the column width. I tried your example and it doesn''''t work, even when I offset the point n pixels. I get a round circle with line thru it whenever I hit the enter or return key. Any suggestions on this one? Thanks! can i get a handle to call the buttonclick myself? >Here is one way you can do it by faking a click on the cell. > > >//click cell 4,4 >this.gridControl1.Focus(); >Point pt = this.gridControl1.ViewLayout.RowColToPoint(4, 4, true, GridCellSizeKind.ActualSize); >pt.Offset(3,3); //move it a little >Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(this.gridControl1, pt); >

Administrator [Syncfusion]
Replied On July 26, 2004 03:56 PM UTC

I think you would have to expose methods to do this. It will take touching a couple of classes I think. //A) in the EllipsisCellRenderer class //1) add a button member and assign it in teh constructor private EllipsisCellButton button; public EllipsisCellRenderer(GridControlBase grid, GridTextBoxCellModel cellModel) : base(grid, cellModel) { this.button = new EllipsisCellButton(this); AddButton(this.button); } //2) add this public method method public void PerformClick() { this.button.PerformClick(new GridCellEventArgs(this.RowIndex, this.ColIndex)); } //B) in the EllipsisCellButton class, add this method public void PerformClick(GridCellEventArgs e) { base.OnClicked(e); } //C) here is the code that clicks it this.gridControl1.Focus(); EllipsisCellRenderer cr = this.gridControl1.CurrentCell.Renderer as EllipsisCellRenderer; if(cr != null) cr.PerformClick();

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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon 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.Close Icon

;