Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Binding data to the custom DataGridView
 

Binding data to the custom DataGridView

All,

I have a customized DataGridView where I have implemented extra functionality and bounded datasource in the same custom DataGridView (Using C# and .NET). Now, I could able to use it properly by placing it on a Tab control. I have added Add button on tab control to add a new row and added a Save button on a main form where the above mentioned Tab control has been placed.

Issue: I pressed Add button to create an empty row (Here, the cell value is null). Modified the grid cell value and immediately pressed Save button which is on main form. I observed that, the cursor is still in the grid cell when I press Save button. While saving, the cell value is null even though I have entered something in the presentation layer. My expected behaviour is to get the modified value while saving.

Special Case: After typing something in the grid cell, if I click on somewhere else before I click on Save button, it is working fine. (Here, mainly I tried to remove the focus from the currently modified cell)

Is there any way to bind sources before I click on save button? Please suggest me.

Please feel free to ask me if you need any information.

Kumar...  Wednesday, September 30, 2009 6:31 AM

Hi,

 

Seems datagridview doesn’t commit currentcell value.


Does the save button is a toolstripbutton on the toolstrip or menustrip? These buttons do not need focus when you click. So these do not force DataGridView validating and committing the data.

Related FAQ:

6.3 Why a ToolStripButton didn’t cause the validation?

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/77a66f05-804e-4d58-8214-0c32d8f43191/

 

Use the following code to force datagridview committing changes.

this.Validate();

 

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, October 05, 2009 8:59 AM

Hi,

 

Seems datagridview doesn’t commit currentcell value.


Does the save button is a toolstripbutton on the toolstrip or menustrip? These buttons do not need focus when you click. So these do not force DataGridView validating and committing the data.

Related FAQ:

6.3 Why a ToolStripButton didn’t cause the validation?

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/77a66f05-804e-4d58-8214-0c32d8f43191/

 

Use the following code to force datagridview committing changes.

this.Validate();

 

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, October 05, 2009 8:59 AM

You can use google to search for other answers

Custom Search

More Threads

• How to draw new PictureBox on a pictureBox
• How can i get the serial number of Hard disk or mainboard
• Refresh problem when using MonthCalendar control in custom UITypeEditor
• Product Review of Aspose.Excel
• grouped checkboxes
• More TreeView Issues - OnMouse and AfterLabelEdit Problem
• Making child controls of UserControl editable
• want to show date from Datetime picker
• Disable execution in designer time
• Form_resize does not fire?