Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > BindingSource GridView No Selection
 

BindingSource GridView No Selection

Hi all,

I use the PositionChanged of the BindingSource to catch row changes in my GridView.
But how do I properly handle a No Selection scenario on the GridView, solely by looking at the bindingSource? Is this possible?

When there is no selection in the GridView, the Position property of the BS still says 0 which indicates the first row, but that is not true!

Should I work with flags?

Please provide me with a proper way of handling this scenario where there is no selection in the grid and I want to handle that in the PositionChanged event of the BindingSource


Kind regards,
Wim
hypo  Tuesday, September 15, 2009 8:32 AM

Hi,

You can change the bindingNavigatorPositionItem.Text property when there is no selection.


private void allowNullDataGridView_SelectionChanged(object sender, EventArgs e)

{

if (allowNullDataGridView.SelectedCells.Count == 0)

{

bindingNavigatorPositionItem.Text = "-1";

}

}

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, September 21, 2009 10:41 AM

Hi,

You can change the bindingNavigatorPositionItem.Text property when there is no selection.


private void allowNullDataGridView_SelectionChanged(object sender, EventArgs e)

{

if (allowNullDataGridView.SelectedCells.Count == 0)

{

bindingNavigatorPositionItem.Text = "-1";

}

}

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Monday, September 21, 2009 10:41 AM

You can use google to search for other answers

Custom Search

More Threads

• DataGridView CellValueChanged Event on load?
• how te get date only?
• DataGridView - Choosing in one column, loads data in another
• VB 2005 Express:Creating a Dataset with the Dataset Designer-Can't Connect a Database in SQL Server Management Studio Express?
• DataView problems...
• DataGrid Problem in Visual J#
• Datagridview - pressed should be Uppercase
• UnhandledException?
• Updating a Sql Database via a datagrid after it has been populated by a excel sheet, some alignment is required
• How to force the sorting glyph to show?