I am subclassing the UltraGrid to create a read only Grid in my WInForms. I want to prevent tab and mouse clicks inside individual cells. I was able to prevent tab navigation by using the following inside my class
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { switch (keyData) { case Keys.Tab: { this.TopLevelControl.SelectNextControl(this, true, true, true, true); return true; } } return base.ProcessCmdKey(ref msg, keyData); }
I also want to prevent the user from clicking on a cell and effectively cancelling the event. can someone
show me some possible solutions?
I'm not sure exactly what you are trying to do here. But it looks like you might be jumping through some unnecessary hoops here.
If you want the tab key to move to the next control rather than tabbing between rows or cells, all you have to do is set the TabNavigation property on the grid. You might also want to remove any reference to the Tab key from the KeyActionMappings collection.
rpgCoder said:I also want to prevent the user from clicking on a cell and effectively cancelling the event. can someone
This statement doesn't really make sense. You can't stop the user from clicking on a cell. You can prevent the results of the click. But what result are you trying to prevent? You can use the CellClickAction property to determine what happens when the user clicks on a cell. You can use the Activation or CellActivation property to disable cells. You could disable the whole grid. There are any number of possible solutions depending on what you want.
Thanks Mike
We are creating the UltraGrid programatically at runtime. I couldn't find the properties earlier
What I meant by cell click is that on that event occurring I didn't want the cursor to start blinking on the
cell. I used the following two properties to prevent tab navigation and selecting entire row on cell click
this.DisplayLayout.TabNavigation = TabNavigation.NextControl;
ultraGridColumn[index].CellClickAction = CellClickAction.RowSelect;
Thanks once again