Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > BindingNavigator save button validate form
 

BindingNavigator save button validate form

In my form I have a bindingnavigator linked to a bindingsource to allow the user to create new records. There are certain validation rules for each field to ensure that fields are of a certain type or not null etc

I can't figure how to perform this validation when the save \ add new button is clicked on the bindingnavigator. surely this is a very common scenario? reading some posts on here suggests subclassing bindingnavigator and overriding capturing the left mouse click and doing validation there. there has to be a more intuitve way to do this.

thanks
declan
db83  Friday, September 18, 2009 1:49 PM

Hi,

You can add your validation in save and add button click event.

private void SaveButton_Click(System.Object sender,

System.EventArgs e)

{

if (validation() == true)

{

TableAdapterName.Update(DataSetName.TableName);

}

}

public bool validation()

{

...

}

Some useful information about BindingNavigator Control:

http://msdn.microsoft.com/en-us/library/safa4957(VS.80).aspx

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  Friday, September 25, 2009 1:32 PM

Hi,

You can add your validation in save and add button click event.

private void SaveButton_Click(System.Object sender,

System.EventArgs e)

{

if (validation() == true)

{

TableAdapterName.Update(DataSetName.TableName);

}

}

public bool validation()

{

...

}

Some useful information about BindingNavigator Control:

http://msdn.microsoft.com/en-us/library/safa4957(VS.80).aspx

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  Friday, September 25, 2009 1:32 PM

You can use google to search for other answers

Custom Search

More Threads

• Problem with DataGridView.
• Binding Source failing in Framework 2.0 SP1
• Copy-Paste option in DataGridView
• Data Problem / Committal
• Expanding/Collasping rows in DataGridView
• databinding to table
• in this coding what is datagridview? we get error datagridview is not declared....
• DataGrid Master/Detail... close but not right
• DATA GRID
• DataGridView Problem