|
forget about subclassing the dialog custom control and create the control at runtime on the formview's initialupdate call, that's how i'm doing it in my program ie i have a seperation function cll CreateGrids()
called from CFormView::OnInitalUpdate();
// protected member variable initalized in constructor to null
// CGridCtrl* m_pTopScoresGrid
CFormClassView::OnInitialUpdate()
{
if (m_pTopScoresGrid == NULL)
{
// Create the Gridctrl object
m_pTopScoresGrid = new CGridCtrl(6,12,2,1);
if (!m_pTopScoresGrid) return ;
// Create the Gridctrl window
rect.left=220;
rect.right=rect.left+370;
rect.top=30;
rect.bottom= rect.top+178;
m_pTopScoresGrid->Create(rect, this, 100);
m_pTopScoresGrid->EnableWysiwygPrinting();
m_pTopScoresGrid->SetEditable(FALSE);
for(int i=1; i< m_pTopScoresGrid->GetColumnCount(); i++)
m_pTopScoresGrid->SetColumnWidth(i,24);
for(int j=0; j < m_pTopScoresGrid->GetRowCount(); j++)
m_pTopScoresGrid->SetRowHeight(j,26);
} // end of CFormClassView::OnInitalUpdate
// of course you might want a line or 2 in the OnSize function
// so that the grid will size with the window for the view like
void CFormClassView::OnSize(UINT nType, int cx, int cy)
CFormView::OnSize(nType, cx, cy);
CRect cRect;
CRect tsRect;
GetClientRect(cRect);
// make sure we have a grid to resize
if(m_pTopScoresGrid!=NULL )
{
tsRect.left=220;
tsRect.right=cRect.right-12;
tsRect.top=30;
tsRect.bottom=tsRect.top+182;
m_pTopScoresGrid->MoveWindow(&tsRect);
} // make sure pointers have vaild window objects
} // end of CFormClassView::OnSize
i've don't particularly like having to subclass the custom control in the dialog code, this way is
easier, for me. you may have to finesse the rect to get the control where you want it.
|
|
|
|
|
|
Hi,
I am using the Grid Control with some Check Boxes, and I need some of the check boxes to be centered, and some to be left aligned. The current Version 2.22 does not allow this. Either all check boxes are left, or centered. Here is my fix.
BOOL CCellCheckBox::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd )
{
.
.
.
.
DWORD nFormat=GetFormat();
if (nFormat & DT_RIGHT) rectCheck.left=rectCheck.right-nSize;
if (nFormat & DT_CENTER)
{
rectCheck.left=rect.CenterPoint().x -(nSize>>1);
rectCheck.right=rectCheck.left+nSize;
}
if (nFormat & DT_TOP) rectCheck.bottom=rectCheck.top+nSize;
if (nFormat & DT_BOTTOM) rectCheck.top=rectCheck.bottom-nSize;
if (nFormat & DT_VCENTER)
{
rectCheck.top = rect.CenterPoint().y - (nSize>>1);
rectCheck.bottom = rectCheck.top + nSize;
}
.
.
.
}
Thanks,
Peter Tewkesbury
Software Developer - Manchester, England
|
|
|
|
|
Hi,
did anybody make a modification for data binding? Read only ODBC level 1 would be enough - just adding several properties for ODBC connection and SQL string.
|
|
|
|
|
Hi,
That is not very difficult. You can do it by self.
But now I am making the grid to read content from ADO
recordset. But the task is not finished. That have any
help for you?
|
|
|
|
|
hi,
how do i get each mfc grid's cell support DDE linkings?
|
|
|
|
|
salut,
nous avons rencontré un problème concernant la base de donnée.
la question se pose comment fait un lien entre le controle Editbox et les champs de la base on a utilisé le composant ADO pour la connexion avec la base et notre application sera réalisée suivant le type dialog-based.
|
|
|
|
|
Hi!
I wanted to change the background color of an individual cell and I tried to do it changing crBkClr but it didn't work...
Do u have any idea of how to do it??
|
|
|
|
|
Hi, You can do this by SetItemBkColour function. I am sure this function is good.
cz
|
|
|
|
|
In v2.22 I've applied the format to remove DT_SINGLELINE DT_VCENTER and the ELLIPSIS stuff, but I'm having trouble getting multi-line cells to auto size. They don't. The extent stuff in the cell classes doesn't actually use the cell width, so I guess that's a non-starter. I added a GetTextExtentEx which also took a col width, but it seems that the height I get back is way too big for the row itself, I'm getting 8 or 9 lines height when I only need 2 or 3. Anyone any advice?
|
|
|
|
|
Not unusually, this was my fault
My mods were all correct, but the problem was I was resizing the rows before setting the normal (larger) column widths in the appropriate columns. Doh!
|
|
|
|
|
Does anyone know how to get the corresponding row numbers for the CGridCellBase objects in the
sorting comparison function? The sorting requirements that I have specify that the grid should be sort by the column selected and a column that contains a price. I know that I can
handle this in the comparison function if I can determine the corresponding row numbers.
Thanks in advance for your help,
Danny
|
|
|
|
|
Hello
I have changed the version of the CGridCtrl class from V2.11 to V2.22 and now the CComboBox doesnt work correctly anymore.
Example: The user selects a string from CCombox and left the active cell => the selected string disappears.
Who can help me ?
|
|
|
|
|
Are there any known issues with the Grid under Windows 95?
I develop using VC++ 5.0 on a Windows NT (SP6) machine. I've added a Grid to a dialog. The dialog is invoked modally from a CButton on a DocView. Under NT the dialog runs perfectly, both from the IDE and fully compiled (as an .EXE). However, if I run the EXE on a Windows 95 machine the entire dialog will not display. Oddly, it does NOT generate an error either.
I've "one by one" removed each control from the dialog and it is definitely the Grid that is causing the problem (or atleast my implementation of it). Any help or ideas would be greatly appreciated.
Mike Mullikin
|
|
|
|
|
There was an issue that had to do with the OLE initialisation, but I thought that had been fixed long ago. I haven't touched win95 for a year or so, os mayhbe the issue has cropped back up again in more recent version.
cheers,
Chris Maunder
|
|
|
|
|
I tried v2.12 with no better luck. I've also disabled TITLETIPS, DRAGDROP & CLIPBOARD (shouldn't that eliminate any OLE issues???), still no luck. Any ideas?
Regards,
Mike Mullikin
|
|
|
|
|
I think I've solved my problem!
I tried the Grid demo on W95/98/ME machines and it worked fine. I wrote my own "simple" demo and it worked fine as well. Then I realized that my "problem" application had one more difference. It has been "localized" for different languages. All of the resources (dialogs, menus, string table etc...) reside in a seperate .DLL file - one for each language.
I started looking through the GridCtrl.cpp and noticed in the RegisterWindowClass() function that the line:
//HINSTANCE hInst = AfxGetResourceHandle();
...was commented out and replaced by the line:
HINSTANCE hInst = AfxGetInstanceHandle();
I un-commented the former and commented the latter and all is well. Why this worked in NT and not 95/98/ME is anybody's guess. I'm sure Microsoft has a good explanation, maybe I'll try to find it someday.
Mike Mullikin
|
|
|
|
|
I've got the same problem, but on Windows 2000. I develop witch VC ++ 6.0 under
WinNt. The Grid works perfect under an NT, but under Win2000, the Dialog wont display.
Derrow
|
|
|
|
|
I had the same problem, but Mr. Mullikin's solution didn't work for me (maybe because I am developing a DLL instead of an exe). Instead, I found the following solution:
In the GridCtrl constructor, I added CS_GLOBALCLASS to the window class style field like so:
wndcls.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
Works for me, I have absolutely no idea why...
--Mike
|
|
|
|
|
Please Help
I have a Gridline display as a CForView... and I want to modify a gridline by adding more row or delete row.. My question how Can I add 5 more row at one time....
for example
When the user click on the option dialog, the dialog display and ask the user enter number of row want to add. Can anyone please help me... I'm using VC++ 6.0.
Thanks
|
|
|
|
|
Hi,
I have been successfully using your grid control for a windows CE program that I writing. However, I need
to add an event for when the combo box selection changes. I was able to manually create this in the
CGridCellCombo class, and it does work. I'm not sure that this is correct. What I really want is for it to call
back to my program rather than the Combo Class. I also need to know what cell I am in. Any assitance on
this matter would be greatly appreciated
Thanks
Susan Meyer
|
|
|
|
|
The method GetSelectedCount() fails the first time the GVN_SELCHANGED is received.
|
|
|
|
|
I am looking for a way to have a column divided into two rows, a la Quicken.
In other words, my row actually consists of two rows, but each row has a separate set of columns. Overall, the columns can break at the same place (like quicken).
For example:
|-----ColA1------|--------ColA2---------|-----ColA3------|
|-----ColB1------|---ColB2---|---ColB3--|-----ColB4------|
Each cell could be a regular cell, or a combo box, etc.
Has anyone had any luck doing something like this?
Rich
Rich Goldstein, MD
|
|
|
|
|
How can you join two cells into one?
Thanks,
Sen.
|
|
|
|
|
Hi,
As far as i know cell joining isn't supported by the current version, but it would be a interesting feature.
Regards
Holger
|
|
|
|