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
close icon

Changing grid cursor

Hi, Cursor ------ I have databound grid on a form along with toolbars, listboxes etc. When I set form.Cursor to Cursors.AppStarting, it shows up everywhere except for the grid. I tried setting grid.Cursor. It does not reflect in my gui. It is setting its own cursor based on the column header, interior cells etc. How can I give feedback to the user that the form is working on getting some data in background? PopupMenus ---------- I am handling righmouse clicks to get the popup menu for my grid. How can I get the same popup menu when the user types the "Popup Start Button" (the button between Windows key and Control Key)? Wrapping --------- Right now for my databound grid, the WrapCellBehavior is set to WrapRow. It works fine when I press tab/Shift tab it cycles between cells/rows in the grid. How can I get out of the grid? thanks, - Reddy

4 Replies

AD Administrator Syncfusion Team September 9, 2003 10:01 PM UTC

1)If you want to control the mouse cursor, then you would have to add you own mousecontroller to plug into the grid's mouse architecture. In the grid, there are many cursors that can be displayed (like sizing cursors, D&D cursors, etc) depending upon where the mouse is. Any functionality that needs a cursor, has to implement a mouse controller object. The grid's mouse controller architecture controls exactly what functionality gets control of the cursor through these mouse controller objects. Here is a sample that always display a wait cursor over the grid. Here is a sample that changes the cursor over the top half of each cell. This means that anywhere else, the grid allows the other controllers a chance to handle the mouse actions. Your mouse controller must implement the IMouseController interface. The main method you have to handle is the HitTest method. Returning a non-zero hit value at that point indicates to the grid that your mousecontroller wants control of things at this point. It will then the use your controller for all messages as long as the hittest returns nonzero. This means your controller will provide the cursor, it will handle the mousedown etc. In the sample, the only functionality implemented is to change the cursor and to handle a left click. 2) I'll look into menu key question tomorrow when I have access to a full keyboard. 3) If you want to tab out of the grid into the next control on the form, try setting this property: Me.CustomGridControl1.Model.Options.WrapCellBehavior = GridWrapCellBehavior.NextControlInForm Now if your grid is directly on a form, this is all you have to do. If your grid is on a panel, or groupbox or tabpage or some other container, then you will also have to handle the WrapCellNextControlInForm event and actually move the focus to where you want it in your container. Here is a sample that might help. The sample has 2 grids, the one on the left is parented to the form, and the one of the right is on a panel. Out of the box, just setting the NextControlInForm value, makes the grid on the left behave as expected, allowing you to tab from button1 to the grid to button2. But the grid on the panel does not behave as expected. There you tab from button3 to the grid to button 1, passing over button 4 which is the next button on the panel. The way to handle this problem is to catch the WrapCellNextControlInForm event, and set the focus the way you want it done depending upon the parent container being used. In the sample, there is commented code in the handler that will move the focus on the panel (the way you might expect). The reason the grid architect opted to expose an event to handle this is that he did not want to try to add code to handle arbitary containers. Instead, the default behavior should handle a form as a parent, but if you have something else, then you will have to use the event.


AD Administrator Syncfusion Team September 10, 2003 08:39 AM UTC

2) If you set the Control.ContextMenu property for the grid and its cell controls, then you will get this behavior bu default. You can do this with code like:
//in formload
this.gridControl1.ContextMenu = this.contextMenu1;
this.gridControl1.ControlAdded += new ControlEventHandler(grid_ControlAdded);

//the handler
private void grid_ControlAdded(object sender, ControlEventArgs e)
{
	e.Control.ContextMenu = this.contextMenu1;
}              
This will just display the this.contextMenu1 every where in the grid whether or not a current cell control is has focus or not. You do not have to handle right-clicks or anything, and the menu key will work. But if you are handling the right clicks to show position dependent menus, then you could do the sample thing, and handle the menu's Popup event, clearing the MenuItems there an dreadding the ones you want to see at this particular popup. Exactly how this works your depend on how you want to determine wher ethe location is. Th edefault behavior is to display the menu where the mouseposition is. If you do not want to change what you are doing now (probably not using the ContextMenu property), then you can catch this keystroke in CurrentCellKeyDown as in this code:
private void gridControl1_CurrentCellKeyDown(object sender, KeyEventArgs e)
{
	if(e.KeyCode == Keys.Apps)
	{
		Console.WriteLine("menukey);
	}
}
If the current cell is actively being edited, then this event is not hit as the key goes to the cell control. If you need to catch this case as weel, then instead of handling the CurrentCellKeyDown event, I think you would have to derive the GridControl and override ProcessDialogKey, catching the Keys.Apps there for both cases.


AD Administrator Syncfusion Team September 11, 2003 12:29 PM UTC

Clay, Thank you very much for your replies. Your suggestions all worked. I have another question regarding tabbing. In a form I have several control and a databound grid. When the user is tabbing through the controls and enters the grid, the only way to exit out of grid is to ta through all the rows/cols and then get out of the grid. I am using my grid as a list box. I want the user to be able to selct a row and then somehow tab out of the grid to the next control. How can I do this? thanks, - Reddy


AD Administrator Syncfusion Team September 11, 2003 06:10 PM UTC

Try setting this.gridControl1.WantTabKey = false; This should make teh grid ignore teh tab key.

Loader.
Live Chat Icon For mobile
Up arrow icon