Accessing Datagrid Cell Content

Hi

Could anyone tell me the way through which i can access a particular cell content of the "DATAGRID VIEW " control placed in my windows form.

I should be able to "access any of the cell content programmatically ",where i fill my datagrid contents from the database.




Answer this question

Accessing Datagrid Cell Content

  • EdMellor

    Hi,

    Were you able to solve your problem

    Thank you,
    Bhanu.



  • phensahw

    try this

    System.Drawing.Point pt = gridDetails.PointToClient(Cursor.Position);
    DataGrid.HitTestInfo info = gridDetails.HitTest(pt);

    info.Row & info.Column --> to get selected row & col respectively..

    gridDetails[info.Row,info.Column].ToString(); --> to get the text of that selected column


  • Derrix Sture-Tucker

    I don't know what you mean but trying to see the following comments: Suppose we have a datagrid with name "dg", so to access a particular cell content of this datagrid, we simply use:

    dg[dg.CurrentCell].ToString()

    the property CurrentCell will determine the current cell you've just selected. You can also use:

    dg[iRow,iCol] where iRow & iCol corresponds with row & col of the datagrid 

    Good luck !

     

     

     



  • Umapathy

    This should be what you want. I assume you are using .Net Framework 2.0

    http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.item(VS.80).aspx

    Something like datagirdview.item(0,1)

    Good Luck


  • Accessing Datagrid Cell Content