Can I access one cell to get column,,

6 posts, 2 answers
  1. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 09 Feb 2011 Link to this post

    I want to click on one cell in the grid view to get a whole column on another form related to one single cell,,

     

    For example:

     

    If I had a database which have products table and product details table,,

    In my grid view I want to click on one product (cell) to get the details for that  product in separate form which contains another grid view.
    the details will be column in another table in the database. 

     

    Thanks in advance,,

  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Feb 2011 Link to this post

    Hello Anoop,

    There are several ways to get the cell value when you click on it which are demonstrated below

    private void radGridView1_CellClick(object sender, GridViewCellEventArgs e)
    {
        if (e.Row.Index > -1)
        {
            var cellValue = e.Value;
            // or
            var cellValue1 = this.radGridView1.CurrentCell.Value;
            // or
            var cellValue2 = e.Row.Cells["ColumnName"].Value;
        }
    }

    However, from you explanation of having a product and product details table, you may want to explore using a Hierarchy Grid View to display the data in a hierarcical way. You can find out more about this type of view here

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 09 Feb 2011 Link to this post

    Thanks a lot for your reply,,



    one more question,,
    can I get a row instead of column,,


    thanks

  5. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Feb 2011 Link to this post

    Hello Anoop,

    As per my post above, you need to use the GridViewCellEventArgs not System.EventAergs
    private void radGridView1_CellClick(object sender, GridViewCellEventArgs e)

    This will give you all the row, column and cell information that you will need.
    Hope that helps but let me know if you need further information
    Richard
  6. Anoop
    Anoop avatar
    76 posts
    Member since:
    Sep 2006

    Posted 09 Feb 2011 Link to this post

    thaaaaaaaaanks Richard
  7. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 09 Feb 2011 Link to this post

    No problem. Please remember to mark as answer and if you need more help, just let me know
    Richard
Back to Top
UI for WinForms is Visual Studio 2017 Ready