Autor Beitrag
ralph71
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Fr 13.01.17 14:59 
Hallo,

in einem DGV habe ich eine ComboBox, die wenn eine neue Row angelegt wird nur dann aktiv sein soll, wenn vorher die Spalten A und B gefüllt sind.

Mein Code funktioniert irgendwie, aber es ist das falsche Ereignis im DGV. Aktuell habe ich dataGridView1_RowEnter

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
          if (dataGridView1.Rows[e.RowIndex].IsNewRow)
            {
                var lvvon = dataGridView1.Rows[e.RowIndex].Cells[1].Value;
                var lvbis = dataGridView1.Rows[e.RowIndex].Cells[2].Value;
                if (lvvon == null || lvbis == null)
                {

                    DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dataGridView1[e.ColumnIndex, e.RowIndex];
                    cell.ReadOnly = true;
                }
                else
                {
                    DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dataGridView1[e.ColumnIndex, e.RowIndex];
                    cell.ReadOnly = false;

                }


Ideen?

Danke Euch!

Moderiert von user profile iconTh69: Titel (leicht) geändert.
Moderiert von user profile iconTh69: C#-Tags hinzugefügt
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Fr 13.01.17 15:10 
Hallo,

probiere mal besser CellEnter bzw. CellBeginEdit.
ralph71 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Mo 16.01.17 16:14 
CellEnter und noch einen Fehler im Code korrigiert.
Funktioniert.
Danke!