|
I wonder how can I right justify (or center) the text on
the cell.
Thanks,
|
|
|
|
|
Hello!
first make a GV_ITEM object. Set row and col members of GV_ITEM to match the cell you want to change.
The nFormat member of GV_ITEM structur holds the format options.
Fill them with the CDC::DrawText(...) - format options
And Last call CGridCtrl::SetItem( GV_ITEM* yourItem) .
Example:
GV_ITEM Item;
>>Item.mask = GVIF_TEXT|GVIF_FORMAT;
>>Item.row = 1; //Set row
>>Item.col = 1; //Set collum
>>Item.nFormat = DT_RIGHT | DT_SINGLELINE; // this is for right justified text --> but you can use all format options from CDC::DrawText(...)
>>SetItem(&Item);
If you want to change the format of all cells, call CGridCellBase* CGridCtrl::GetDefaultCell(), and then call the member-function SetFormat(DWORD nFormat) from the returned object, where nFormat is same like GV_ITEM.nFormat !
hope i could help you!
|
|
|
|
|
NguyenKy - VietNam
email : hongwon@hcm.vnn.vn
PLease help me !
Procedure GTBASE.prg
Program TEST
KTTK.dbf
KTCSDL.dbf
Effice :
When click cmdMyCmdBtn2 CommandButon
display in screen : Name Column and record ?
Thanks see information.
NguyenKy - VietNam
email : hongwon@hcm.vnn.vn
--------------------------
Please see my procedure GTBASE.prg
SET SAFETY OFF
SELECT 1
USE &USINGFILE
SELECT 10
USE KTCSDL
INDEX ON FIELD_NAME TO KTCSDL
SELECT 1
#DEFINE DORONG 60
#DEFINE DOCAO 25
frmMyForm = CREATEOBJECT('Form')
frmMyForm.Closable = .F.
frmMyForm.FontName ='MS Sans Serif'
frmMyForm.caption =TIEUDE
frmMyForm.ICON ='HINHANH\note04.ico'
frmMyForm.Left = 0
frmMyForm.top = 0
frmMyForm.width = 790
frmMyForm.height = 454
frmMyForm.AddObject('grdGrid1','Grid')
frmMyForm.grdGrid1.SetAll("DynamicBackColor",;
"IIF(DELETE(),RGB(128,255,255),RGB(255,255,255))","Column")
frmMyForm.grdGrid1.Visible = .T.
frmMyForm.grdGrid1.FontName ='vni-times'
frmMyForm.grdGrid1.FontSize =12
frmMyForm.grdGrid1.Left = 2
frmMyForm.grdGrid1.top = 2
frmMyForm.grdGrid1.width = 785
frmMyForm.grdGrid1.height = 400
frmMyForm.grdGrid1.ReadOnly =.T.
frmMyForm.grdGrid1.StatusBarText =TieuDe
frmMyForm.grdGrid1.ToolTipText =TieuDe
DO TAO_COLUMN
frmMyForm.AddObject('cmdCommand1','cmdMyCmdBtn1')
frmMyForm.cmdCommand1.Visible =.T.
frmMyForm.AddObject('cmdCommand2','cmdMyCmdBtn2')
frmMyForm.cmdCommand2.Visible =.T.
frmMyForm.AddObject('cmdCommand3','cmdMyCmdBtn3')
frmMyForm.cmdCommand3.Visible =.T.
frmMyForm.SHOW
READ EVENTS
*------------------------------------------------------------------------
DEFINE CLASS cmdMyCmdBtn1 AS CommandButton
Caption = '\
|
|
|
|
|
Hi,
How can i link my DAO database to FlexGrid or DBGrid in VC++ or Excel ActiveX ?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
what is the synonimous of the function GetClip() in MSFlexGrid in the MFC-Grid Control. thinks.
|
|
|
|
|
what is the synonimous of the function GetClip() in MSFlexGrid in the MFC-Grid Control. thinks.
|
|
|
|
|
Hi,
I am using this grid to display quotes, in real time.
in debug mode it works. but in release mode,data is not stable,
some times it flashes, and some times no data.
and one more thing , if i change the text,the second fixed column
is not changing. can any body help????
regards
jay
|
|
|
|
|
High jay,
I've the same problems like you wrote!
I posted my questions since weeks without any response. So my advice don't wait for an answer, buy a professional grid control. For my opinion - and I'really like this site - you can learn much from this grid control, but I think it is not intended to use it in professional applications!
Ralph
|
|
|
|
|
Hi Ralph,
thanks a lot for your info.
I just now purchased VSflexGrid Pro, from www.componentone.com
|
|
|
|
|
Hi,
I wrote the following line :
m_grid.GetCell( 1, 1)->SetText("First line\nSecond line");
and enabled the tool tips.
However the tip for the (1,1) cell appeared as one line ,
meaning '\n' didn't do a thing
How do I make the tip to appear as two lines
or how do I create a multiline tip
Daniel Mark
Thanks
|
|
|
|
|
in the TitleTip.cpp
you should replace the line:
dc.TextOut( 0, 0, strTitle );
with
dc.DrawText(strTitle,strTitle.GetLength(), ......
where the strTitle contains all your data including "\n".
Before calling the DrawText fuction, you should recalc the rect.
|
|
|
|
|
It seems that there is a problem whereby the grid
doesn't get registered as a drop target unless it
contains scroll bars.
If I place a custom control box that is bigger than
the grid (and thus no scroll bars are necessary) then
I can pick the text, but cannot drop it onto that grid.
I would think drag and drop on a grid that requires
scrolling is a bit of a problem!!
Michael Katzmann
|
|
|
|
|
I have a DTCrecordset control, and a form manager control on my web page.
When I insert a record, then update the record shows it is updated.
If I hit the refresh button on my web browser it gives me a popup message to retry or cancel, if someone hits retry it creates another record. Does anyone Know a way around this?
LK
|
|
|
|
|
I had to make the following minor change in order to get it to work within our application where we've internationalized, placing all of our resources in a separate .DLL (any dialog which had a CGridCtrl would fail to load):
change
HINSTANCE hInst = AfxGetInstanceHandle();
to:
HINSTANCE hInst = AfxGetResourceHandle();
Steve Wolf
|
|
|
|
|
I'm trying to use the grid control in a CFormView-based class, by inserting a custom control in the dialog. My application fails with "Failed to create empty document" message at start, this seems to be caused by failure in CFrameWnd::LoadFrame() to create the main window. Any ideas on how to make this work?
|
|
|
|
|
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?
|
|
|
|