Live Chat Icon For mobile
Live Chat Icon

I have hidden (column width = 0) columns on the right side of my datagrid, but tabbing does not work properly. How can I get tabbing to work

Platform: WinForms| Category: Datagrid

As you tabbed to the right side of your grid, you have to tabbed through these zero width column and that is causing the tab key to appear not to work properly. One solution is to handle the grid’s CurrentCellChanged event, and if you are on a border cell (among the hidden columns), then explicitly set the proper currentcell.

//columns 3-6 are hidden with 0-column width...
private int LEFTHIDDENCOLUMN = 3;
private int RIGHTHIDDENCOLUMN = 6;
		
private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs e)
{
	if(dataGrid1.CurrentCell.ColumnNumber == LEFTHIDDENCOLUMN)
		dataGrid1.CurrentCell = new DataGridCell(dataGrid1.CurrentCell.RowNumber + 1, 0);
	else if(dataGrid1.CurrentCell.ColumnNumber == RIGHTHIDDENCOLUMN)
		dataGrid1.CurrentCell = new DataGridCell(dataGrid1.CurrentCell.RowNumber, LEFTHIDDENCOLUMN - 1);
}

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.