DataGridView - How do I...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: DataGridView - How do I...

  1. #1
    Join Date
    Feb 2006
    Posts
    55

    DataGridView - How do I...

    I have a DataGridView control in a Windows forms app bound to a datatable. I want the DataGridView to update the datatable as soon as a cell value is changed.

    The default behaviour only seems to update the datatable when you move to a different row. Moving to a different cell or clicking a button outside the DataGridView does not cause the datatable to be updated. When the user clicks a button outside the DataGridView control I want to ensure that all changes have been committed to the datatable.

    Your advice is appreciated.

    Thanks,

    David

  2. #2
    Join Date
    Dec 2004
    Posts
    163
    David,

    When the user clicks a button outside the datagridview control, you might try calling the bindingsource's EndEdit method.

    You might also try the following:

    Select the grid in design mode.
    From the Properties window, select Databindings | Advanced. Click the Ellipsis button in the Advanced property. This brings up the Formatting and Advanced Binding dialog.

    Choose OnPropertyChanged from the Data Source Update Mode combo box.

    Kerry Moorman

  3. #3
    Join Date
    Feb 2006
    Posts
    55
    Quote Originally Posted by kmoorman
    David,

    When the user clicks a button outside the datagridview control, you might try calling the bindingsource's EndEdit method.

    You might also try the following:

    Select the grid in design mode.
    From the Properties window, select Databindings | Advanced. Click the Ellipsis button in the Advanced property. This brings up the Formatting and Advanced Binding dialog.

    Choose OnPropertyChanged from the Data Source Update Mode combo box.

    Kerry Moorman
    Thanks for the suggestions.

    I'd already tried the EndEdit but without success. I'm binding programatically so the second suggestion wouldn't be applicable.

    After some amount of frustration I found a solution. Call the forms Validate() method.

Similar Threads

  1. Replies: 7
    Last Post: 03-18-2008, 11:36 AM
  2. Datagridview data print in vb.net 2005 win forms
    By hellopraveen30 in forum .NET
    Replies: 0
    Last Post: 02-14-2007, 01:01 AM
  3. Replies: 0
    Last Post: 09-27-2006, 03:47 AM
  4. DataGridView Returning Values from Cells
    By triley35 in forum .NET
    Replies: 1
    Last Post: 07-08-2006, 12:34 AM
  5. updating datagridview in vb 2005
    By TigerMoonSix in forum .NET
    Replies: 1
    Last Post: 06-20-2006, 10:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center