Link to home
Start Free TrialLog in
Avatar of lxiao
lxiao

asked on

using MS FlexGrid -- Urgent

Where or how can I get a control which would be like MSFlex Grid control, but with editable cells?
ASKER CERTIFIED SOLUTION
Avatar of guruprasad031298
guruprasad031298

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lxiao
lxiao

ASKER

I have TRUE DBGrid Evaluation copy, but I don't have a DB to support. My usage is simple, MSFlexGrid does very well except it's not editable. I would prefer in-place editing. How?
Avatar of lxiao

ASKER

I have TRUE DBGrid Evaluation copy, but I don't have a DB to support. My usage is simple, MSFlexGrid does very well except it's not editable. I would prefer in-place editing. How?
Try using this. This is one of the answer I suggested to a question at expert-exchange already. It worked well. Should work good for you too. May be rquires some minor adjustment for edit control positioning.

void CMyView::OnDblClickStdgrid()
 {
    // Embed editable CEdit Control

    // Construct edit control
    pEdit = new CStdEqpEdit(&m_StdGrid, row);  // Pass the flexgrid control & the                                                                       // selected row for further processing

    /*
     * Conversion from Twips to Pixel scale. Divisor values are specific to this
     * grid and may not work for others. Generic conversion routine couldn't be
     * written for this purpose. Make sure not to change this
     */

    long lLeft = (long) (m_StdGrid.GetCellLeft () / 15);
    long lTop = (long) (m_StdGrid.GetCellTop () / 15);
    long lHeight = (long) (m_StdGrid.GetCellHeight() / 15);
    long lWidth = (long) (m_StdGrid.GetCellWidth() / 14.3);

    CRect rect (lLeft, lTop, lLeft + lWidth, lTop + lHeight);

    // Create the edit control on the fly
    pEdit->Create (WS_CHILD | WS_VISIBLE | WS_BORDER, rect,                                                       this,IDC_SEQ_NUM_EDIT);
    pEdit->SetWindowText (m_StdGrid.GetText());

    // Change the font of the edit control to that of the grid cell for consistency
    CString sFontName = m_StdGrid.GetCellFontName();
    int iFontSize = (int) (m_StdGrid.GetCellFontSize() * FONT_SCALE);
    CFont *pFontEdit = new CFont();
    pFontEdit->CreatePointFont (iFontSize, sFontName);
    pEdit->SetFont (pFontEdit);

    // Set the focus to the edit control
    pEdit->SetFocus();
}

    Hope this helps





Avatar of lxiao

ASKER

Thanks. I'll try.
Avatar of lxiao

ASKER

I created the CEdit control. But once it gets into the Grid area, it disappears. What's wrong?
Thanks.
Make sure you have subclassed the standard edit control, by using the classwizard - add new class functionality and derive the new class from CEdit, so that all the messages will be routed to this new class.

Add an OnSetFocus message handler to this Edit control. Then debug through the code to see what's wrong. Once you make sure the edit control behaves in the proper way, it's easy to figure out the rest.

Have a nice weekend
Avatar of lxiao

ASKER

The edit control size looks fine. But the position is wrong. How can I find the right position without using magic numbers? Thanks.