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

Using a Custom ButtonEdit Control as a CellType

I have created a Control that inherits from ButtonEdit which works great (thank you syncfusion for all your help), now I need to use it inside a grid and don''t know how to go about doing this. How do I go about using my control instead of a built in control. I saw samples that allow you to build custom drop downs, but I want my cell to look the way my buttonedit does. Thank you, Javier

6 Replies

AD Administrator Syncfusion Team August 12, 2004 04:50 PM UTC

If you only want your control to be in a single cell, then you can try using the "Control" celltype. MyControl box = new MyControl(); //set properties on MyCOntrol box.BorderStyle = BorderStyle.None; gridControl1.RowHeights[2] = 30; gridControl1.ColWidths[2] = 200; gridControl1[2,2].CellType = "Control"; gridControl1[2,2].Control = box; this.Controls.Add(box); But if you need to share your control among many cells, then you will have to derive a custom cell control. Ycan look for the custom cells in our samples folder. Here is a list from our samples that has custom cells CellTypes\CalendarCells CellTypes\PictureBoxCells CellTypes\RadioButtonCells CellTypes\SliderCells CellTypes\XhtmlCells In Depth\CellButtons In Depth\DropDownFormAndUserControlSample In Depth\DropdownGrid In Depth\GridInCells In Depth\VirtTreeGrid Regarding the documentation, you can look for deriving a cell control section in our user guide. EssentialGrid--->EssentialGridOverview --- > Deriving a cell control. This will give you an overall idea how to derive a cell control. You should look for CellModel and CellRenderer classes and suitable methods to override depending upon your functionality.


AD Administrator Syncfusion Team August 12, 2004 04:51 PM UTC

The In Depth\CellButtons sample has a sample button edit cell in it though it may be be what you want.


AD Administrator Syncfusion Team August 12, 2004 05:58 PM UTC

Thanks, this worked. I do have one small issue that I need to look into. When I initially click on the button, the button event doesn''t get trigger, the cell gets focus (I notice the border of the cell turn black....which is something else i want to get rid of). So I was wondering, is there an easy way to get the control to know if the button was press when it got focus? Anyways, thank you again. Javier >If you only want your control to be in a single cell, then you can try using the "Control" celltype. > >MyControl box = new MyControl(); >//set properties on MyCOntrol > box.BorderStyle = BorderStyle.None; >gridControl1.RowHeights[2] = 30; >gridControl1.ColWidths[2] = 200; >gridControl1[2,2].CellType = "Control"; >gridControl1[2,2].Control = box; >this.Controls.Add(box); > > >But if you need to share your control among many cells, then you will have to derive a custom cell control. Ycan look for the custom cells in our samples folder. Here is a list from our samples that has custom cells > >CellTypes\CalendarCells >CellTypes\PictureBoxCells >CellTypes\RadioButtonCells >CellTypes\SliderCells >CellTypes\XhtmlCells >In Depth\CellButtons >In Depth\DropDownFormAndUserControlSample >In Depth\DropdownGrid >In Depth\GridInCells >In Depth\VirtTreeGrid > >Regarding the documentation, you can look for deriving a cell control section in our user guide. > >EssentialGrid--->EssentialGridOverview --- > Deriving a cell control. > >This will give you an overall idea how to derive a cell control. You should look for CellModel and CellRenderer classes and suitable methods to override depending upon your functionality.


AD Administrator Syncfusion Team August 12, 2004 07:20 PM UTC

This sometimes can be tricky to do. One thing you might try is to handle the grid.CellClick event, and then click your control using a grid helper methidd that does a fake left click.
private void gridControl1_CellClick(object sender, GridCellClickEventArgs e)
{
	Point pt = new Point(e.MouseEventArgs.X, e.MouseEventArgs.Y);
	pt = this.gridControl1.PointToScreen(pt);
	pt = myControl1.PointToClient(pt);
	Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(myControl1, pt);
}
Another thing you can do is to expose a method in your control that clicks its button, and then just call your method from the grid.CellClick event.


RA ralph_lachance August 18, 2006 01:03 PM UTC

Hi there,

This posting is pretty old - are there any
samples around that take this a step further?

i.e. putting multiple buttons (like ButtonEdit)
into a grid cell. (using derived gridcellcontrol, not pure Control)

best
Ralph LaChance


RA ralph_lachance August 18, 2006 01:17 PM UTC

Actually, I found exactly what I needed in
http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=26928

which includes a sample that Clay put up called
two_buttons.

Thanks gang
-Ralph LaChance

Loader.
Up arrow icon