|
Hi Carsten,
try this:
void CMyProjectDoc::Serialize(CArchive& ar)
{
int nRows = 0, nCols = 0;
if (ar.IsStoring())
{
nRows = gridCtrl.GetColumnCount();
nCols = gridCtrl.GetRowCount();
ar << nRows << nCols;
for (int i = 0; i < nRows; i++)
{
for (int j = 0; j < nCols; j++)
{
ar << gridCtrl.GetItemText( i, j );
}
}
}
else
{
ar >> nRows >> nCols;
CString sItemText;
for (int i = 0; i < nRows; i++)
{
for (int j = 0; j < nCols; j++)
{
ar >> sItemText;
gridCtrl.SetItemText( i, j, sItemText );
}
}
}
}
Best regards
Holger
|
|
|
|
|
Hi,
When starting the application the created view is without the gridctrl showing although I know it is the right view that was created.
On any new documents created after that the view correctly displays the grid.
How can this be?
/Johannes Strömberg
|
|
|
|
|
Hi All,
I am using the Grid control in an SDI app to display
two sets of related data.
I am also using the Visual Framework to split the screen
into sections.
When I create a FormView and place the first grid control
in it, it will draw and operate perfectly ok.
BUT When I create a second formview, almost IDENTICAL code
no matter what I try, the grid control will not display!
I can tell that the control has been created correctly,
because my resizing routine makes it fit the window and
the scroll bars are active when the control does not fit
anymore. (This is made clearer since the working control
is the same size (But visible!) and directly above
the hidden control.
I figure I must be doing something REALLY simple wrong but
I have tried using WS_VISIBLE in the create, I have tried
creating a new class, I have tried using only the
Grid control directly (Which works!) But I would like
to define my own class and use the Grid control as the
base class.
Is it something about inheritence I have missed?
Any help on this would be IMMEASURABLY appreciated
Regards,
D
|
|
|
|
|
I put a GridCtrl in SDI Frame, in Debug ,It display normal,
but in Release Grid only display gridline,every Item can't display?
But I put this Release in Win98 ,It run very normal
|
|
|
|
|
I have to say it works fine for me under Win2K (SP1) in both debug and release...
|
|
|
|
|
i put the grid control in a property page. i also create a view and property sheet which hold the property page. all of this is in an extension dll. i have a strange problem when trying to create the page on win98. i get a blank page, even my ok and cancel buttons don't display. the tab is there but the page is completely blank.
now, in nt 4.0 i don't have this problem. anybody have some experience trying something like this?
mike
|
|
|
|
|
I have the same problem. Don't you know the solution please? I have a deadline... Thx a lot
|
|
|
|
|
My English is very pool,so i just to do it.
I have a problem,when V2.21 Grid Control in a Doc/View framework,I find a small rim around grid Control in frame? but In V2.20 is none,Why? How to wipe off it?
In Dialog App,V2.21 work is very normal.
I want everybody to help me! Thanks very much
|
|
|
|
|
Just after calling m_pGrid->Create(...), insert following lines, which removes the 'bordering' window styles
m_pGrid->ModifyStyle( WS_BORDER, 0 );
m_pGrid->ModifyStyleEx( WS_EX_CLIENTEDGE, 0 );
HTH,
Thomas
--
I am a signature virus!
Help me spread and copy me to your sig
|
|
|
|
|
Version 2.21 should fix the problems you are having - but I only have a W2K box to test on, so I can't be 100% (or even 50% ) sure.
cheers,
Chris Maunde
|
|
|
|
|
I got the demo to work by uncommenting 'Initialise();' in 'CGridCtrl::Create' and commenting out 'Initialise();' in 'CGridCtrl::PreSubclassWindow'
|
|
|
|
|
|
I experienced the same problems as the other posters, but found that if I added this code to my CMyApp::InitInstance function, the problems disappeared
if (!AfxOleInit())
{
AfxMessageBox(_T("Unable to initialize OLE"));
return FALSE;
}
This code should be called prior to the call to AfxEnableControlContainer() and before any AddDocTemplate calls.
|
|
|
|
|
Same problem with Peter and Mouez.
Chris if you have some time it would be great if could have a look on the view-sample. I have downloaded your 2.12 version and it works fine in my view!
A great job!
Ralph
|
|
|
|
|
Some problem with Peter.
But works fine in NT 4.0
Someone with an idea
|
|
|
|
|
I tried to run the "Grid in View" demo - without success.
The debug version crashes in CGridCtrl->Create(). The release version runs - the first view that is created by the app contains rubbish, if you click File->new a nice new view appears.
I tried to build the demo on w2k and win98 - same problems
|
|
|
|
|
Running the demo, after I changed the width of the column, I clicked the top cell of this column. This cell became a black box and the width of this box also is not correct.
What is the problem?
Tbanks,
Pete
|
|
|
|
|
Hi,
I did everything Chris did in this tutorial.
But my app (just fresh out of AppWizard) crashes
when I want to start it.
Also, what exactly is "m_pGridCtrl" in the
OnInitialUpdate handler ???
Any suggestions ?
Dennis Voss
|
|
|
|
|
Hi Dennis,
CMyView::OnInitialUpdate
{
CView::OnInitialUpdate();
if (m_pGrid == NULL) // Have we already done this bit?
{
// WRONG -> m_pGridCtrl = new CGridCtrl; // Create the Gridctrl object
/* RIGHGT ->*/ m_pGrid = new CGridCtrl;
// REPLACE EVERY "m_pGridCtrl" WITH "m_pGrid" AND WILL WORK PROBABLY
if (!m_pGrid) return;
CRect rect; // Create the Gridctrl window
GetClientRect(rect);
m_pGrid->Create(rect, this, 100);
m_pGrid->SetRowCount(50); // fill it up with stuff
m_pGrid->SetColumnCount(10);
// ... etc
}
}
This will be all ...
Bye
Victo
|
|
|
|
|
In the code below, you're checking the status of your memory allocation by checking for null in the pointer returned by new().
That is not the right way to check for memory errors, because the new() operator will throw an exception if it fails, unless the compiler is explicitly told not to use exceptions.
// Create the Gridctrl object
m_pGridCtrl = new CGridCtrl;
if (!m_pGridCtrl) return;
|
|
|
|