views:

177

answers:

3

Hello,

I am trying to use ultimate grid from Code Project in a dialog box but the grid is invisible.

m_Plist.AttachGrid(this, IDC_CREDENTIALS) returns true but the static text place holder where the grid should be shown cant be seen and the grid is never displayed.

I am using sample the code from here http://www.codeproject.com/KB/MFC/UltimateGrid_Start.aspx?display=PrintAll&fid=452565&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2629959&fr=51#Using_the_Grid_in_a_CDialog

I have installed the latest update UltimateGrid72_Src_Update03.zip and Im using VS2008 SP1.

Thanks...

BOOL CCredentials::OnInitDialog()
{
    CDialog::OnInitDialog();

    MyCug m_PList;

m_Plist.AttachGrid(this, IDC_CREDENTIALS);

}
A: 

I don't know why your grid is not displaying, things to look for are is it correctly loading from the dialog template, and is it visible? You can use spy++ (a tool distributed with visual studio) to see what windows are actually created in your dialog, where they are and the flags and styles set on them.

1800 INFORMATION
A: 

After you create and attach the grid, are you adding rows and columns as defined by the examples?

Otherwise, there isn't going to be anything to see.

You'll need the following code in MyCug::OnSetup():

void MyCug::OnSetup(){ 

    //*******Set the Rows and Columns
    SetNumberCols(10);
    SetNumberRows(10); 

}

That's from the tutorial in the 7.2 version. I used UG extensively, and have no problems with VS2008. But I create all my grid myself, I don't use dialog templates.

Eric H.
Yes I was doing that.
Canacourse
OK, when you call Create for your grid, are you marking it VISIBLE?Here's more code my grid's constructor MyCug::MyCug (int id, CWnd *parent) { CreateGrid( WS_CHILD|WS_VISIBLE, wp.rcNormalPosition, parent, id); }
Eric H.
+3  A: 

I've not used Ultimate Grid myself. However, looking at the code you posted, I can see that there is likely to be a problem: you declare an instance of "MyCug" on the stack, then attach it, but that stack-based instance will be destroyed as soon as the OnInitDialog() method exists. What you must do is put the declaration of "MyCug m_PList;" as a member of the dialog class, so that the lifetime of the grid object is the same as the lifetime of the dialog.

DavidK
You were spot on. It working now many thanks..
Canacourse