Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Select particular cell in Datagridview

$
0
0

The following example appears to work.

This sets a flag and saves the current coordinates in the CellEndEdit event but actually changes the current column to the desired one in the Selection_Changed event instead.

Currently this simply sets the focus back to the same column that was just edited but it seems to correctly change it to whatever column you set current-col and current-row fields to.

       class-id testgridrow.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       
       working-storage section.
       01 current-row  binary-long.
       01 current-col  binary-long.
       01 flag-cell-edited condition-value.
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           goback.
       end method.

       method-id dataGridView1_CellEndEdit final private.
       procedure division using by value sender as object e as type System.Windows.Forms.DataGridViewCellEventArgs.
           
           set flag-cell-edited to True
           set current-col to e::ColumnIndex
           set current-row to e::RowIndex

       end method.

       method-id dataGridView1_SelectionChanged final private.
       procedure division using by value sender as object e as type System.EventArgs.
           if flag-cell-edited 
              set DataGridView1::CurrentCell to DataGridView1[current-col, current-row]
              set flag-cell-edited to False
           end-if
    
       end method.
      
       end class.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>