Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / July 2004

Tip: Looking for answers? Try searching our database.

DataGrid & IBindingList Binding Problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Hoffer - 23 Jun 2004 14:08 GMT
Hello, can someone help me?

I have a DataGrid of which I assign its DataSource property to my custom
list object that implements the IBindingList interface and inherits
CollectionBase (I followed the CustomerList example in the msdn docs).

Everything seems fine when I run my application except...   The statement
that assigns the DataSource causes BeginEdit() to be called on my object in
my custom list and it does not call EndEdit().  This prevents me from being
able to actually edit any data in the grid because the first call to edit
never finishes.  And this call to edit is not called by me, it's called by
the framework.  The call stack is like this...

 xrite.retail.dll!XRite.Retail.PaletteInfo.BeginEdit() Line 193 C#

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.OnCurrentChang
ed(System.EventArgs e = {System.EventArgs}) + 0xd4 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordSt
ate(int newPosition = 0, bool validating = true, bool endCurrentEdit =
false, bool firePositionChange = true, bool pullData = false) + 0x157 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
g(bool force = false) + 0xd0 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
g() + 0xd bytes

system.windows.forms.dll!System.Windows.Forms.BindingManagerBase.PushData()
+ 0x1d bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.CurrencyManage
r_PushData() + 0x47 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.OnItemChanged(
System.Windows.Forms.ItemChangedEventArgs e = {Index=-1}) + 0x78 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.SetDataSource(
System.Object dataSource = {XRite.Retail.Collections.PaletteInfoArrayList})
+ 0x14b bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.CurrencyManage
r(System.Object dataSource =
{XRite.Retail.Collections.PaletteInfoArrayList}) + 0x5d bytes

system.windows.forms.dll!System.Windows.Forms.BindingContext.EnsureListManag
er(System.Object dataSource =
{XRite.Retail.Collections.PaletteInfoArrayList}, string dataMember = "") +
0x11a bytes

system.windows.forms.dll!System.Windows.Forms.BindingContext.get_Item(System
.Object dataSource = {XRite.Retail.Collections.PaletteInfoArrayList}, string
dataMember = "") + 0x15 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.Set_ListManager(Syste
m.Object newDataSource = {XRite.Retail.Collections.PaletteInfoArrayList},
string newDataMember = "", bool force = false, bool forceColumnCreation =
true) + 0x157 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.Set_ListManager(Syste
m.Object newDataSource = {XRite.Retail.Collections.PaletteInfoArrayList},
string newDataMember = "", bool force = false) + 0x1c bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.set_DataSource(System
.Object value = {XRite.Retail.Collections.PaletteInfoArrayList}) + 0x190
bytes

It looks like the reason for the BeginEdit() is the endCurrentEdit parameter
being set to false.  Why is this false?  How can I change it to true?  Why
does the framework need to edit any object?  Can I turn this off?

-dh
Ernest Morariu - 04 Jul 2004 04:45 GMT
> Everything seems fine when I run my application except...   The statement
> that assigns the DataSource causes BeginEdit() to be called on my object in
> my custom list and it does not call EndEdit().  This prevents me from being
> able to actually edit any data in the grid because the first call to edit
> never finishes.

From msdn:

Implementations of the IEditableObject interface should keep track of
whether the BeginEdit has already been called and ignore subsequent calls to
BeginEdit.

Ernest

> Hello, can someone help me?
>
[quoted text clipped - 10 lines]
>
>   xrite.retail.dll!XRite.Retail.PaletteInfo.BeginEdit() Line 193 C#

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.OnCurrentChang
> ed(System.EventArgs e = {System.EventArgs}) + 0xd4 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordSt
> ate(int newPosition = 0, bool validating = true, bool endCurrentEdit =
> false, bool firePositionChange = true, bool pullData = false) + 0x157 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
> g(bool force = false) + 0xd0 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
> g() + 0xd bytes

system.windows.forms.dll!System.Windows.Forms.BindingManagerBase.PushData()
> + 0x1d bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.CurrencyManage
> r_PushData() + 0x47 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.OnItemChanged(
> System.Windows.Forms.ItemChangedEventArgs e = {Index=-1}) + 0x78 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.SetDataSource(
> System.Object dataSource = {XRite.Retail.Collections.PaletteInfoArrayList})
> + 0x14b bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.CurrencyManage
> r(System.Object dataSource =
> {XRite.Retail.Collections.PaletteInfoArrayList}) + 0x5d bytes

system.windows.forms.dll!System.Windows.Forms.BindingContext.EnsureListManag
> er(System.Object dataSource =
> {XRite.Retail.Collections.PaletteInfoArrayList}, string dataMember = "") +
> 0x11a bytes

system.windows.forms.dll!System.Windows.Forms.BindingContext.get_Item(System
> .Object dataSource = {XRite.Retail.Collections.PaletteInfoArrayList}, string
> dataMember = "") + 0x15 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.Set_ListManager(Syste
> m.Object newDataSource = {XRite.Retail.Collections.PaletteInfoArrayList},
> string newDataMember = "", bool force = false, bool forceColumnCreation =
> true) + 0x157 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.Set_ListManager(Syste
> m.Object newDataSource = {XRite.Retail.Collections.PaletteInfoArrayList},
> string newDataMember = "", bool force = false) + 0x1c bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.set_DataSource(System
> .Object value = {XRite.Retail.Collections.PaletteInfoArrayList}) + 0x190
> bytes
[quoted text clipped - 4 lines]
>
> -dh
David Hoffer - 08 Jul 2004 15:17 GMT
I think I am doing this already.  Here is what I am doing...
public void BeginEdit()
{
if (!m_bInTxn)
{
 // Save backup copy of data...
 m_bInTxn = true;
}
}
public void CancelEdit()
{
if (m_bInTxn)
{
// Undo backup copy of data...
m_bInTxn = false;
}
}
public void EndEdit()
{
if (m_bInTxn)
{
m_bInTxn = false;
}
OnChanged();
}

> > Everything seems fine when I run my application except...   The statement
> > that assigns the DataSource causes BeginEdit() to be called on my object
[quoted text clipped - 31 lines]
> system.windows.forms.dll!System.Windows.Forms.CurrencyManager.OnCurrentChang
> > ed(System.EventArgs e = {System.EventArgs}) + 0xd4 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.ChangeRecordSt
> > ate(int newPosition = 0, bool validating = true, bool endCurrentEdit =
> > false, bool firePositionChange = true, bool pullData = false) + 0x157
> bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
> > g(bool force = false) + 0xd0 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.UpdateIsBindin
> > g() + 0xd bytes

system.windows.forms.dll!System.Windows.Forms.BindingManagerBase.PushData()
> > + 0x1d bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.CurrencyManage
> > r_PushData() + 0x47 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.OnItemChanged(
> > System.Windows.Forms.ItemChangedEventArgs e = {Index=-1}) + 0x78 bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.SetDataSource(
> > System.Object dataSource =
> {XRite.Retail.Collections.PaletteInfoArrayList})
> > + 0x14b bytes

system.windows.forms.dll!System.Windows.Forms.CurrencyManager.CurrencyManage
> > r(System.Object dataSource =
> > {XRite.Retail.Collections.PaletteInfoArrayList}) + 0x5d bytes

system.windows.forms.dll!System.Windows.Forms.BindingContext.EnsureListManag
> > er(System.Object dataSource =
> > {XRite.Retail.Collections.PaletteInfoArrayList}, string dataMember = "") +
> > 0x11a bytes

system.windows.forms.dll!System.Windows.Forms.BindingContext.get_Item(System
> > .Object dataSource = {XRite.Retail.Collections.PaletteInfoArrayList},
> string
> > dataMember = "") + 0x15 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.Set_ListManager(Syste
> > m.Object newDataSource = {XRite.Retail.Collections.PaletteInfoArrayList},
> > string newDataMember = "", bool force = false, bool forceColumnCreation =
> > true) + 0x157 bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.Set_ListManager(Syste
> > m.Object newDataSource = {XRite.Retail.Collections.PaletteInfoArrayList},
> > string newDataMember = "", bool force = false) + 0x1c bytes

system.windows.forms.dll!System.Windows.Forms.DataGrid.set_DataSource(System
> > .Object value = {XRite.Retail.Collections.PaletteInfoArrayList}) + 0x190
> > bytes
[quoted text clipped - 5 lines]
> >
> > -dh

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.