CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Location
    Surrey, England
    Posts
    23

    Retrieving text from an MSDBGrid cell

    Hello,

    VC++ 6.0 Prof, Windows 98

    I hope some one can help me. I have just used the MSDBGrid ActiveX
    control for the first time in the following way:

    I have created a AppWizard application with one splitter bar dividing
    the window in two. In the top section I have put a CFormView dialog
    with a DBGrid in it, and below, a CEdit View. What I want to do is
    every time the user changes row in the DBGrid, the CEdit View displays
    related information from the same database.

    To do this, I have done the following in the FormView DBGrid class:

    void CPTDBGView::OnRowColChangeDbgrid1(VARIANT FAR* LastRow, short
    LastCol)
    {
    // TODO: Add your control notification handler code here
    CMsDgridCtrl* ldgptr = (CMsDgridCtrl*) GetDlgItem(IDC_DBGRID1);
    CString lstri;
    lstri = ldgptr->GetColumns(1);
    MessageBox(lstri,"Text");

    }



    The above must look very basic to experts; I have used the RowColChange
    event, and in there I have attempted to load a key field from the row
    (which has four columns, by the way) into a CString. The trouble is, I
    do not know which command in the DBGrid control retrieves a cell's
    text: I have attempted to use GetColumns, above, with no success, to
    load the first column's text.

    I would be very grateful if someone could show me the code to retrieve
    text from a DBGrid column, and load it into a CString.

    Sincerely,
    Paul Trimming

    ----------------------------------
    Email: [email protected]
    4, High St, Merstham
    Surrey RH1 3EA, England
    ----------------------------------


  2. #2
    Join Date
    Apr 1999
    Posts
    306

    Re: Retrieving text from an MSDBGrid cell

    I have not worked with DBGrid ActiveX, but I think it's similar to CListCtrl so try GetItemText().


  3. #3
    Join Date
    Jun 1999
    Posts
    81

    Re: Retrieving text from an MSDBGrid cell


    Have you solved your problem? I met the same problem. Could you put your solution, if any, on the site? Thanks.



    Zenger Huang


  4. #4
    Join Date
    Jun 1999
    Posts
    21

    Re: Retrieving text from an MSDBGrid cell

    Try using GetText() - this should return the text in the currently selected column.


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