473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DataGrid: Update data source when editing a cell and closing the f

Hi,

Suppose there is a DataGrid on a form bound to a DataTable. When a user is
editing a cell without leaving the cell, and then closes the form, the value
is not updated to the underlying data source.

How can I accomplish this?

Thanks,
--
Tom Tempelaere.
Nov 17 '05 #1
4 4248
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid.DataSource,
dataGrid.DataMember];
cm.EndCurrentEdit();
DataGridColumnStyle curColumn =
dataGrid.TableStyles[0].GridColumnStyles[dataGrid.CurrentCell.ColumnNumber];
dataGrid.EndEdit(curColumn, dataGrid.CurrentRowIndex, false);

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message news:5E**********************************@microsof t.com...
Hi,

Suppose there is a DataGrid on a form bound to a DataTable. When a user is
editing a cell without leaving the cell, and then closes the form, the
value
is not updated to the underlying data source.

How can I accomplish this?

Thanks,
--
Tom Tempelaere.


Nov 17 '05 #2
It doesn't work. EndEdit *always* returns false, even if the entry is valid.

Unbelievable that even such trivial operations are so hard to find, and when
you try them they don't even work.

Duh,
Tom T.

"Dmytro Lapshyn [MVP]" wrote:
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid.DataSource,
dataGrid.DataMember];
cm.EndCurrentEdit();
DataGridColumnStyle curColumn =
dataGrid.TableStyles[0].GridColumnStyles[dataGrid.CurrentCell.ColumnNumber];
dataGrid.EndEdit(curColumn, dataGrid.CurrentRowIndex, false);

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message news:5E**********************************@microsof t.com...
Hi,

Suppose there is a DataGrid on a form bound to a DataTable. When a user is
editing a cell without leaving the cell, and then closes the form, the
value
is not updated to the underlying data source.

How can I accomplish this?

Thanks,
--
Tom Tempelaere.


Nov 17 '05 #3
Try to swap the order - call EndEdit first and then EndCurrentEdit on the
CurrencyManager.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message news:8D**********************************@microsof t.com...
It doesn't work. EndEdit *always* returns false, even if the entry is
valid.

Unbelievable that even such trivial operations are so hard to find, and
when
you try them they don't even work.

Duh,
Tom T.

"Dmytro Lapshyn [MVP]" wrote:
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid.DataSource,
dataGrid.DataMember];
cm.EndCurrentEdit();
DataGridColumnStyle curColumn =
dataGrid.TableStyles[0].GridColumnStyles[dataGrid.CurrentCell.ColumnNumber];
dataGrid.EndEdit(curColumn, dataGrid.CurrentRowIndex, false);

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
news:5E**********************************@microsof t.com...
> Hi,
>
> Suppose there is a DataGrid on a form bound to a DataTable. When a user
> is
> editing a cell without leaving the cell, and then closes the form, the
> value
> is not updated to the underlying data source.
>
> How can I accomplish this?
>
> Thanks,
> --
> Tom Tempelaere.



Nov 17 '05 #4
Dmytro,

Thanks for the suggestion. I'll try it out.

Thank you,
Tom T.
PS: Sorry for the frustrated tone ;-), DataGrid is rather complex sometimes.

"Dmytro Lapshyn [MVP]" <x-****@no-spam-please.hotpop.com> schreef in bericht
news:%2****************@TK2MSFTNGP15.phx.gbl...
Try to swap the order - call EndEdit first and then EndCurrentEdit on the
CurrencyManager.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
news:8D**********************************@microsof t.com...
It doesn't work. EndEdit *always* returns false, even if the entry is
valid.

Unbelievable that even such trivial operations are so hard to find, and
when
you try them they don't even work.

Duh,
Tom T.

"Dmytro Lapshyn [MVP]" wrote:
CurrencyManager cm =
(CurrencyManager)this.BindingContext[dataGrid.DataSource,
dataGrid.DataMember];
cm.EndCurrentEdit();
DataGridColumnStyle curColumn =
dataGrid.TableStyles[0].GridColumnStyles[dataGrid.CurrentCell.ColumnNumber];
dataGrid.EndEdit(curColumn, dataGrid.CurrentRowIndex, false);

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
"TT (Tom Tempelaere)"
<_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
news:5E**********************************@microsof t.com...
> Hi,
>
> Suppose there is a DataGrid on a form bound to a DataTable. When a
> user is
> editing a cell without leaving the cell, and then closes the form, the
> value
> is not updated to the underlying data source.
>
> How can I accomplish this?
>
> Thanks,
> --
> Tom Tempelaere.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Junkguy | last post by:
I need some help programmatically causing a row in a DataGrid to "flush" its contents to its bound data (in Visual Studio 6 using Windows Forms with C#). My issue is I want to send an update to...
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
3
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found...
3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
3
by: Islamegy | last post by:
When i press btn_save all changed rows in my grid get saved except the last editing row... I want my btn_Save to end editing in the datagrid.. so if user didn't press "enter" after editing last...
2
by: Joe Au | last post by:
I follow the Walkthrough documented on Visual Studio to create an editable data grid but it does not work on getting the value of the textbox in the data grid. The code is copied here. I mark...
4
by: Suzanne | last post by:
Hi all, I'm having problems with datagrids and the currentcellchanged event. My problem is this: I have a datagrid on a form, if the user changes the text in a cell on the datagrid then tries to...
8
by: Scott Meddows | last post by:
I have a datagrid control that I've inherited from the base datagrid control (Source below). I am applying a datatable style onto the datatable that I assign as my datasource. All of my column...
5
by: Earl | last post by:
I want to fire a database update off of a single change to a single cell in the datagrid. This apparently cannot be done using keypress, keyup, keydown, etc. I've read George Shepard's FAQ and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.