Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

DataGridView i promena podataka

[es] :: .NET :: DataGridView i promena podataka

[ Pregleda: 1853 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

L a d y

Član broj: 101977
Poruke: 53
80.74.160.*



Profil

icon DataGridView i promena podataka12.02.2007. u 07:08 - pre 208 meseci
DataGridView se koristi za promene podataka u tabeli, dodavanje redova je onemoguceno. Sta treba dodati kodu da bi se prosledila promena ako postoji samo 1 red u tabeli, posto tada ne moze da odreaguje na PositionChanged dogadjaj?

//tracks for PositionChanged event last row
private DataRow LastDataRow = null;


/// <SUMMARY>
/// Checks if there is a row with changes and
/// writes it to the database
/// </SUMMARY>
private void UpdateRowToDatabase()
{
if (LastDataRow != null)
{

if (LastDataRow.RowState ==
DataRowState.Modified)
{
// this.ordersTableAdapter.Fill(this.baseDataSet.Orders);
ordersTableAdapter.Update(LastDataRow);

}
}
}


private void ordersBindingSource_PositionChanged(object sender, EventArgs e)
{
try
{

// if the user moves to a new row, check if the
// last row was changed
theBindingSource =
(BindingSource)sender;
ThisDataRow =
((DataRowView)theBindingSource.Current).Row;
if (ThisDataRow == LastDataRow)
{
// we need to avoid to write a datarow to the
// database when it is still processed. Otherwise
// we get a problem with the event handling of
//the DataTable.
throw new ApplicationException("It seems the" +
" PositionChanged event was fired twice for" +
" the same row");
}

UpdateRowToDatabase();
// track the current row for next
// PositionChanged event
LastDataRow = ThisDataRow;

}
catch { }
}


 
Odgovor na temu

sstanko78
Novi Sad

Član broj: 19139
Poruke: 411
212.200.52.*



Profil

icon Re: DataGridView i promena podataka12.02.2007. u 08:07 - pre 208 meseci
Nisam te bas razumeo, ali probaj sa

Probaj sa eventom BindingSource.CurrentItemChanged
To nije event DataGridView-a
 
Odgovor na temu

[es] :: .NET :: DataGridView i promena podataka

[ Pregleda: 1853 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.