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.

Grids in MDI containers losing clicks

Thread ID:

Created:

Updated:

Platform:

Replies:

10761 Feb 11,2004 01:39 PM Feb 14,2004 04:34 AM Windows Forms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On February 11, 2004 01:39 PM

I have a grid that is contained inside an MDI container that has a toolbar on the left. The MDI window is set to be maximized within its container. i.e. you have a toolbar on the left and a grid on the right. i was having problems with the first click on a grid not always bringing focus to that control and i''ve only just figured out why. it is a grid like your example 10722 (a grid with ListBoxSelection=MultiExtended, and a CurrentCellActivating event which sets e.ColIndex=0). what i think is happening is that the focus is not being given to my grid''s Form when i click on the grid. its definitely capable of receiving clicks when the form is activated. if i have two application instances open i can click between them with no problems. each initial click activates the form and selects the grid row clicked on. HOWEVER: if the toolbar (which contains a SF tree control) has focus and i click on the grid then the initial click does not change the selected row. BUT (and this is the wierd thing) if i override OnMouseDown for this grid then it DOES receive a mouse click (i have a messagebox.show("clicked") inside the handler). HOWEVER this mouse click does not then subsequently set the row. i have send you a simplified version. if you click on the tree then the grid then the first click will not be received. if you were to add a Clicked event to the grid then it would be triggered on EVERY click. any ideas? 10722b_551.zip

Administrator [Syncfusion]
Replied On February 11, 2004 04:44 PM

This seems like a bug. I will forward it to the grid architect so he can look into it. As far as a workaround until we can get it fixed in a release, you can do a fake click to get the row selected. It is not a perfect workaround as the first time, the row is selected on the mouseup instead of the normal mousedown. But the row does get selected eventually.
bool inGrid = false;
private void gridControl1_Click(object sender, EventArgs e)
{
	if(!inGrid)
	{
		Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(this.gridControl1, this.gridControl1.PointToClient(Control.MousePosition));
		inGrid = true;
	}
}

private void InnerForm_Leave(object sender, EventArgs e)
{
	inGrid = false;
}

Administrator [Syncfusion]
Replied On February 12, 2004 01:07 PM

i have tried this, yet i seem to only occasionally get enter+leave events on the grid (which obviously breaks the logic). even if i have a text control in another open window - that doesnt seem to make the grid get/lose focus every time. perhaps this is the underlying bug? i dont see why your idea wouldnt work. perhaps i need an event on formactivated for the parent form to activate the grid? i''ll maybe try a few things >This seems like a bug. I will forward it to the grid architect so he can look into it. > >As far as a workaround until we can get it fixed in a release, you can do a fake click to get the row selected. It is not a perfect workaround as the first time, the row is selected on the mouseup instead of the normal mousedown. But the row does get selected eventually. >
>bool inGrid = false;
>private void gridControl1_Click(object sender, EventArgs e)
>{
>	if(!inGrid)
>	{
>		Syncfusion.Drawing.ActiveXSnapshot.FakeLeftMouseClick(this.gridControl1, this.gridControl1.PointToClient(Control.MousePosition));
>		inGrid = true;
>	}
>}
>
>private void InnerForm_Leave(object sender, EventArgs e)
>{
>	inGrid = false;
>}
>

Administrator [Syncfusion]
Replied On February 12, 2004 04:08 PM

The grid architect has corrected this problem in our code base. In MDI scenarios, the grid''s OnEnter was not called. A check for ParentForm.Enter was added, and if the grid''s Enter was not called, an explicit call to it is made.

Administrator [Syncfusion]
Replied On February 13, 2004 01:44 PM

With this in mind, is there a workaround i can use right now? It may be the case that for my app. I can call the FakeClick method without adverse problems since I am not allowing the user to edit in the grid (its just a listboxcontrol). What is your release schedule for this bug? Also there appears to be a similar problem when bring up a [Windows Forms] context menu in the grid and the right clicking on the grid. I have a multi selection listbox with context menu options determined by what is selected. So obviously if they right click on part of the selection then that selection should not be cleared, but if they right click on an unselected row then all other rows should be deselected. i have managed this just fine with mouse events, but when the context menu is displayed and you right click on the grid then sometimes those rows arent selected. I can provide more information on this if required but it may be the same bug? -simon >The grid architect has corrected this problem in our code base. In MDI scenarios, the grid''s OnEnter was not called. A check for ParentForm.Enter was added, and if the grid''s Enter was not called, an explicit call to it is made. > >

Administrator [Syncfusion]
Replied On February 13, 2004 06:24 PM

You can turn off the right-click removing selections by setting this property. this.gridControl1.Model.Options.SelectCellsMouseButtonsMask = MouseButtons.Left; The fake click was the only work-around I could come up with. The next release will be a release candidate for 2.0. Right now, it looks like it will be out in about a week or so.

Administrator [Syncfusion]
Replied On February 14, 2004 04:34 AM

I had asked a question before about this right clicking and concluded that I would have to write some custom code. This is because i only want right clicking to NOT deselect the selection when I click on an already selected row. So if i right click on an unselected row then I DO want it unselected. This is pretty much standard expected behavior but I had to do quite a bit of extra work to get it working. -simon >You can turn off the right-click removing selections by setting this property. > >this.gridControl1.Model.Options.SelectCellsMouseButtonsMask = MouseButtons.Left; > > >The fake click was the only work-around I could come up with. > >The next release will be a release candidate for 2.0. Right now, it looks like it will be out in about a week or so.

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.

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.

;