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.
Syncfusion Feedback

GGC PushButton event

Thread ID:

Created:

Updated:

Platform:

Replies:

70656 Dec 25,2007 08:08 AM UTC Jan 2,2008 08:21 AM UTC Windows Forms 4
loading
Tags: GridControl
Arif Eqbal
Asked On December 25, 2007 08:08 AM UTC

Hi
I am using a column in a ggc to show buttons, I handle the TableControlCellButtonClicked to code the click event. This event is fired fine when I click on the button, but if I use Tab keys to select the button and press SpaceBar to click it the event is not fired??
Surprisingly the button appears to be pressed (down and then Up).
Also, I would like to add an image to this button, is it possible? If I can somehow access the control object may be I can try and add an image.
thanks
Arif



Jisha Joy [Syncfusion]
Replied On December 27, 2007 01:15 PM UTC

Hi Arif ,

Thank you for providing query to us.
Question1 : if I use Tab keys to select the button and press SpaceBar to click it the event is not fired??
You can handle TableControlPushButtonClick event that will fire when we click on the PushButton through mouse or space bar.
Here is the code snippets:

this.gridGroupingControl1.TableControlPushButtonClick += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellPushButtonClickEventHandler(gridGroupingControl1_TableControlPushButtonClick);
void gridGroupingControl1_TableControlPushButtonClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellPushButtonClickEventArgs e)
{
MessageBox.Show("Fired");
}

Question2 : I would like to add an image to this button, is it possible?
You can handle the TableControlDrawCellButton event of the gridGroupingControl and draw the image there by checking the CellType. In the event handler code, you can use e.Graphics.DrawImage to draw the bitmap and then set e.Cancel = true.
Below is the code snippets:

this.gridGroupingControl1.TableControlDrawCellButton += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellButtonEventHandler(gridGroupingControl1_TableControlDrawCellButton);

void gridGroupingControl1_TableControlDrawCellButton(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellButtonEventArgs e)
{

if (e.Inner.Style.CellType == "PushButton")
{
e.Inner.Graphics.DrawImage(this.imageList1.Images[0], e.Inner.Button.Bounds);
e.Inner.Style.CellAppearance = GridCellAppearance.Raised;
e.Inner.Cancel = true;
}

}

Please refer the sample in the link to illustrate this:
http://websamples.syncfusion.com/samples/Grid.Windows/F70656/main.htm

Kindly try this and let me know if you need further assistance.

Regards,
Jisha


Arif Eqbal
Replied On December 28, 2007 09:32 AM UTC

Hi there thanks for your reply.
for the second issue actually I would like to have the image over the button so that I can have the pressed effect. using this event actually draws just the image (effect of Cancel=True) if you do not cancel the button is drawn but the image gets lost.
Is there a way to have both, i.e. just like in normal buttons I have an image on the button.
Thanks


Sri Rajan [Syncfusion]
Replied On December 28, 2007 08:49 PM UTC

Hi Arif ,

Thank you for posting query to us.

One way you can do this by handling the TableControlDrawCell event of the gridGroupingControl and draw default pushbutton by using Renderer.Draw method. In the event handler, you can use e.Graphics.DrawImage to draw the bitmap and then set e.Inner.Cancel = true to handle it. Below is the code snippets:

this.gridGroupingControl1.TableControlDrawCell += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellEventHandler(gridGroupingControl1_TableControlDrawCell);

void gridGroupingControl1_TableControlDrawCell(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlDrawCellEventArgs e)
{
if (e.Inner.Style.CellType == "PushButton")
{
e.Inner.Cancel = true;

// //Draw the Image in a cell.
string sButtonText = e.Inner.Style.Description;
e.Inner.Style.Description = string.Empty;
e.Inner.Renderer.Draw(e.Inner.Graphics, e.Inner.Bounds, e.Inner.RowIndex, e.Inner.ColIndex, e.Inner.Style);

Rectangle irect = new Rectangle(new Point(e.Inner.Bounds.X + 3, e.Inner.Bounds.Y + 3), new Size(e.Inner.Bounds.Size.Width - 6, e.Inner.Bounds.Size.Height - 6));
e.Inner.Graphics.DrawImage(this.imageList1.Images[e.Inner.RowIndex % this.imageList1.Images.Count], irect);

}
}

Please refer the sample in the link which illustrate normal buttons having an image:

http://websamples.syncfusion.com/samples/Grid.Windows/F70656_A/main.htm

Kindly try this and let me know if you need further assistance.

Best Regards,
Srirajan



Arif Eqbal
Replied On January 2, 2008 08:21 AM UTC

Thanks SriRajan
Thats exactly what I wanted.


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.

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

;