CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2005
    Posts
    141

    show data in datagridview

    hi,
    i have a datagridview which displays data from a MySQL table (using ODBC connection).
    what i want to do is, when i click one of cells inside the datagridview, a message box will pop-up,displaying all the other data from the selected row. how do i do it?

    thanks in advance

  2. #2
    Join Date
    Dec 2006
    Posts
    38

    Re: show data in datagridview

    Many ways to do this I suppose.

    Code:
    private void click_cellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
    {
       string www = "";
    
       DataGridView dgv = (DataGridView)sender;
       int w = dgv.CurrentCell.RowIndex;
       for(int i=0; i < dgv.Rows[w].Cells.Count; i++)
       {
           www += (string)dgv.Rows[w].Cells[i].Value + " ";
       }
    
       MessageBox.Show(www);
    
    }
    BTW... The datagridview event you want to capture is "CellMouseUp"

  3. #3
    Join Date
    Jul 2005
    Posts
    141

    Re: show data in datagridview

    thanks... actually i've already got a way to do it... anyway thanks for the alternative way

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured