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

How can I add a column in ggc that this colum contains Textbox in the left and a Picture in the right

Hi:
How can I add a column in ggc that this colum contains Textbox in the left and a Picture in the right.
If I click the right side picture I also want to rise a event which I can put my code in to change the text in the left side textbox?

thanks


3 Replies

AD Administrator Syncfusion Team December 19, 2007 01:40 PM UTC

One way you can do it is to handle the TableControlCellDrawn event and draw the image yourself. Here is a little sample showing some details.



WindowsApplication24_2.zip


SE Sean December 24, 2007 07:04 AM UTC

Thanks,but I have another problem,I want to click the image to fire a event.How can I do this?



HA haneefm Syncfusion Team December 27, 2007 05:35 PM UTC

Hi Strife,

One way you can do this by handling the TableControlCellClick event of the grid and fire the Image clicked event. Below are the codes that shows this task.

void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
if (style.TableCellIdentity.Column != null
&& style.TableCellIdentity.Column.Name == "Col2"
&& style.TableCellIdentity.DisplayElement.GetRecord() is GridRecord)
{

GridTextBoxCellRenderer cr = e.TableControl.CellRenderers["TextBox"] as GridTextBoxCellRenderer;
Rectangle Cellrect = cr.GetCellClientRectangle(e.Inner.RowIndex, e.Inner.ColIndex, style, false);

Rectangle imgRect = new Rectangle(Cellrect.X + Cellrect.Width - style.TextMargins.Right, Cellrect.Y , style.TextMargins.Right, Cellrect.Height);
bool b = imgRect.IntersectsWith(new Rectangle(e.Inner.MouseEventArgs.Location, new Size(1, 1)));
if (b)
{
MessageBox.Show("Image Clicked....");
}

}
}

Best regards,
Haneef



Loader.
Live Chat Icon For mobile
Up arrow icon