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

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

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!

5 Replies

AD Administrator Syncfusion Team July 26, 2004 10:08 AM

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);


TO Ted Osberg July 26, 2004 11:00 AM

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!


TO Ted Osberg July 26, 2004 11:08 AM

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


AD Administrator Syncfusion Team July 26, 2004 11:53 AM

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); >


AD Administrator Syncfusion Team July 26, 2004 11:56 AM

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();

Loader.
Live Chat Icon For mobile
Up arrow icon