S
Stef
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);
}
}
}
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);
}
}
}