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 General / June 2006

Tip: Looking for answers? Try searching our database.

Very annoying datagrid problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stef - 21 Jun 2006 21:36 GMT
Hello folks,
  The problem I have is this: I have a datagrid with custom column
styles.
I bind this grid to a DataSet then I use the CurrencyManager to handle
the PositionChanged event.
The problem is I get this error saying "No value for index 1" and the
grid becomes a huge red X when I change some data in an item and then
click on the item underneath which is an empty grid row...
I'm puzzled...

Someone can help?

Thanks

Here's the code:

...
private void frmMain_Load(object sender, System.EventArgs e)
        {
            BindAccounts();
            SetOperationGridColumns(Enums.GridMode.EditMode);

            BindHisto();
            SetHistoGridColumns();

            BindGestionnaires();
            SetDestinataireGridColumns(Enums.GridMode.EditMode);

        }
...

private void BindAccounts()
        {
            this.dsOperations1.Clear();
            this.OperationAdapter.Fill(this.dsOperations1,"qryGetAllOperations");
            this.dsOperations1.Tables["qryGetAllOperations"].Columns["AD_Statut"].DefaultValue
= false;
            this.dsOperations1.Tables["qryGetAllOperations"].Columns["Script_Statut"].DefaultValue
= false;
            this.dsOperations1.Tables["qryGetAllOperations"].Columns["Archive_Statut"].DefaultValue
= false;
            this.dsOperations1.Tables["qryGetAllOperations"].Columns["Email_Statut"].DefaultValue
= false;
            this.dsOperations1.Tables["qryGetAllOperations"].Columns["KeepAlive_Statut"].DefaultValue
= false;
            this.dsOperations1.Tables["qryGetAllOperations"].Columns["Deleted"].DefaultValue
= false;

            CurrencyManager cmOperations =
(CurrencyManager)this.BindingContext[this.dbgOperations.DataSource,
this.dbgOperations.DataMember];
            cmOperations.PositionChanged += new
EventHandler(CurrentOperationRowChanged);
            cmOperations.ItemChanged += new
ItemChangedEventHandler(CurrentOperationItemChanged);

            this.dbgOperations.DataSource=this.dsOperations1.Tables["qryGetAllOperations"];
        }

        private void CurrentOperationRowChanged(object sender, EventArgs e)
        {

            if(this.dsOperations1.HasChanges())
            {
                DialogResult dr=MessageBox.Show("Vous avez des modifications en
cours, voulez-vous les sauvegarder?", "Confirmation de modification.",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr ==DialogResult.Yes)
                {
                    cmdSave_Click(sender, e);                   
                }
            }
        }
Stef - 26 Jun 2006 14:37 GMT
Ok, I've played a bit around and noticed that my problem seems related
to this code:
...
private void BindAccounts()
...
CurrencyManager cmOperations =
(CurrencyManager)this.BindingContext[this.dbgOperations.DataSource,
this.dbgOperations.DataMember];
            cmOperations.PositionChanged += new
EventHandler(CurrentOperationRowChanged);
...

If I comment out this code, the bug is NEVER happening!
I use the currency manager's PositionChanged event to notify the user
that some changes occured (if DataSet.GetChanges() returns something
that is) after he changed row position in the grid.
Maybe I'm not doing something correctly?  Is there a better way to do
this?

Thanks all for reading and possibly help me out with this!

Stef

> Hello folks,
>    The problem I have is this: I have a datagrid with custom column
[quoted text clipped - 69 lines]
>             }
>         }

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.