I am making payment screen with c# winform, the ODEMEID in gridview1 is registered in the ODEMEBELGETID field in the gridview2 record,
when I recall the record, the first ODEMEID value I select in gridview1 is not automatically checked in gridview2, but if I select the second record, the corresponding record in grid2 is checked, then if I select the first record, grid2 is checked.
When the form is loaded, the first ODEMEID is automatically transferred to memory. When the records are loaded into the form, if the ODEMEID value is -1, my problem is solved.
private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
{
try
{
object odemeIdValue = gridView1.GetFocusedRowCellValue("ODEMEID");
if (odemeIdValue != null && odemeIdValue != DBNull.Value)
{
int odemeID = Convert.ToInt32(odemeIdValue);
SelectAndFocusGridView2Rows(odemeID);
}
else
{
DeselectGridView2Rows();
}
}
catch (Exception ex)
{
Mesajlar.Hata(ex);
}
}
private void SelectAndFocusGridView2Rows(int odemeID)
{
//DeselectGridView2Rows();
for (int i = 0; i < gridView2.RowCount; i++)
{
var rowValue = (int)gridView2.GetRowCellValue(i, "ODEMEBELGEID");
if (rowValue == odemeID)
{
gridView2.SelectRow(i);
gridView2.FocusedRowHandle = i;
}
}
}
private void DeselectGridView2Rows()
{
for (int i = 0; i < gridView2.RowCount; i++)
{
gridView2.UnselectRow(i);
}
}