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

Select particular cell in Datagridview

$
0
0

I am using Visual Cobol 2.2 -1  and Visual studio 2012
Problem :
How to set a particular datagridview cell active within handling a Datagridview event.
The datagridview is NOT BOUND to a dataset.

The Windows forms app contains several controls, one of which is the Datagridview.
The Datagridview consists of 5 cols in this case.
Loading the grid and validatiing / editing / redisplaying values entered  is working fine.


When the user enters data in the first column (or any other column of course) of a row , the program is using the
'CellEndEdit' event-method to test some values of several columns and process accordingly.

----------------------------------  code begin ---------------------------------------------------
*>
*> Method to test what to do
*> dg-view is the name of the datagrid               

       method-id dg-view_CellEndEdit final private.
       procedure division using by value sender as object e as type System.Windows.Forms.DataGridViewCellEventArgs.

*>Within the method i want to set the focus to
*>the fourth column on the same row for example.
*>I have searched MSDN and tried other searches but all suggestions do not seem to work :
*>example of a solution i have tried with the Datagrid property 'SelectionMode' set to 'CellSelect' using designer:

        
                 set hlp-row to dg-view::CurrentCellAddress::Y.
                 set hlp-col to dg-view::CurrentCellAddress::X.

*>               ..... Get data of the current cell and process according to hlp-col value .......
*>               ......For the first cell (hlp-col = 0) on the current row the following lines are coded
*>               ......just before leaving the method ............
    
                 if hlp-col = 0
                    invoke dg-view::ClearSelection
                    set dg-view::CurrentCell to dg-view::Rows[hlp-row]::Cells[hlp-col + 3]                     
                    set dg-view::CurrentCell::Selected to true
                 end-if
    end method.

----------------------------------  code end ---------------------------------------------------


effect:
    whe the user leaves the first cell on row 0 , the focus will be on the second column
    instead of the fourth.  I have verified that hlp-col = 0 by debugging.



Viewing all articles
Browse latest Browse all 4356

Trending Articles



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