Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Community
right now im trying to create a sizable dialog with an embeddd grid control.

After the Resize of the dialog, with all its components, like the grid control "frame"-control,
the COLs of the Grid Control per se will not resize. this looks pretty bad.
Only the last Col increases his width during every move i do with the boarder of the dialog

i tried to add an FitToWindow()of the control in the resize function, but it just gets an unusal behaviour.(see What have you tried?)

Is there a little trick i forgot to use?

Thanks

What I have tried:

//GridCtrl is the name of my Grid Container inside of the MyClass Dlg

void MyClass::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
UPDATE_EASYSIZE;

GridCtrl.FitToWindow(0,m_ConfigGridCtrl.GetNumberCols()-1); //->after a few resizes, the "last" column will be super big, the other ones getting smaller and moved to the left(in the 0 direction)
//GridCtrl.RedrawAll();->crash
//GridCtrl.AdjustComponentSizes();->crash
}
Posted
Updated 6-Jul-16 6:53am
v2
Comments
Richard MacCutchan 6-Jul-16 11:20am    
Where does the grid control come from - is it part of MFC?
Dennis1990 6-Jul-16 12:05pm    
the Ultimate Grid Control is Part of a CodeProject library.
http://www.codeproject.com/Articles/20183/The-Ultimate-Grid-Home-Page
like Easysize:
http://www.codeproject.com/Articles/1657/EasySize-Dialog-resizing-in-no-time
Richard MacCutchan 6-Jul-16 13:15pm    
Then you should really post your question in the forum at the end of the article. That way the author gets to know you have a problem.

As I understand you your grid container only resizes the last column correctly and the others not correct: that is bug. It can come from some rounding division float to int by throwing the fraction over board. You need some better computation of the sizing values or some logic to sum up and balance the fractions.

Tip: start by an own array of floats for the col width to understand and track it.
 
Share this answer
 
Id created a workaround.

I created a resize function for the UltimateGridControl,
which uses my (for example)"COL_1_WIDTH = 20""COL_2_WIDTH = 30" defines
and resizes all cols of the Grid without manipulating the data.
It works cause the UGC-defines are relative to the whole grid control.

Its not the best solution,cause im just supressing and overpainting,
but for the moment the best working.

Thank you for your help

___i can fire it in the
C++
::OnSize(UINT nType, int cx, int cy)
	
CDialog::OnSize(nType, cx, cy);
	UPDATE_EASYSIZE;
	if(GridCtrl)
		GridCtrl.ResizeColsWidth();


here i use a for loop to set all the WIDTH_DEFINES for setting the width again, without updating the data.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900