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

custom control & first click

Hi. I have a custom control made of five checkboxes, that I use to edit a custom datatype of mine in a grid. I implemented it with the renderer machinery, as shown in the samples. It works fine, but the first click in the cell just activates the cell and does not go to the checkbox on which the user clicked. Subsequent clicks, after the cell has been activated, work as expected. I understand that when the cell is clicked, the editCtl is moved over the cell and initialized with the cell value. So when the cell is first clicked, there is no custom control to get the click. I tried to find a way to pass the click to the custom control after it has become active, but had no success. Can you help, please. Thanks, Raul

5 Replies

AD Administrator Syncfusion Team April 15, 2005 02:32 PM UTC

There is a helper method that tries to do a fake mouse click: Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(focusControl, p); where p is a Point in the coordinate system of the Control focusControl. So, when you control becomes active, you might try calling this method to see if it will handle this problem for you. If you have our source code, you can look at the renderer code for our GridGenericControlCellRenderer, \Syncfusion\Essential Suite\\Windows\Grid.Windows\Src\Extensions\CellTypes\GridGenericControlCell.cs(379). It uses this method in an override on OnClick to refire the click.

RR Raul Rosenthal April 18, 2005 09:38 AM UTC

My renderer is derived from GridGenericControlCellRenderer, so I think the fake onclick should already get to my user control, but it does not. I copied the code of the onclick method to my renderer class, started the debugged and confirmed that it is executed as expected, but the OnClick event does not get to my custom control (I assume it should get a normal click event.) I ended up with a copy of the onclick code put in my renderer, modified to directly call a public method in my user control to handle the click. It works, but it''s awful. Have you any suggestion that could help me understand why my control does not received the click event? Thanks, Raul

AD Administrator Syncfusion Team April 18, 2005 09:58 AM UTC

Something you could try is to go ahead and set the focus to your control in the renderer.OnClick before calling the fakemouse click. maybe this will help in forwarding the click. The FakeLeftMouseClick is sort of a hack to begin with. It does not always work. If you look at its implementation code, Syncfusion\Essential Suite\\Base\Shared.Base\Src\Drawing\ActiveXSnapshot.cs(297), you will see that it just sends window messages WM_LBUTTONDOWN and WM_LBUTTONUP through interop calls. In your setup, something must be catching these window messages before that hit your control, or the parameters are not set properly for the click you need. You could add an override of WndProc to your control class, and see if these messages are getting there, and if paramaters are what is expected. To see the expected parameters, you could try clicking the control after it is activated.

NA Naveed Ahmed Siddiqui May 17, 2005 06:35 AM UTC

I had similar problem with my custom control, which internally contains a checkbox and a combo box. Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(Control,Point), posts a MouseDown msg followed by MouseUp msg, but somehow these two msgs doesnot combine to give Mouse Click event to your control, that u can see by hooking Click event of your main control, that u will recieve MouseDown followed by MouseUp but no Click event. So even if u delegate your mouse event to one of your internal controls, that control wont get any mouse click. e.g. in your case; Checkbox''s checked state wont be toggled unless it gets Click event on it. hence delegating mouse event via Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(Control,Point) wont give u your desired functionality. I worked around this problem by toggling the checked state of my check box when mouse is clicked on it. But i couldnt do the same for my comboBox.

AD Administrator Syncfusion Team May 17, 2005 09:11 AM UTC

If you can upload a sample project showing the problem you are having, we may be able to suggest a specific solution.

Live Chat Icon For mobile
Up arrow icon