Link to home
Start Free TrialLog in
Avatar of uanmi
uanmiFlag for Australia

asked on

how to change column width in CMsDgridCtrl

I need to be able to set the column width within a
CMsDGridCtrl.  I can set the default column width,
but need to be able to change each column individually.
I am using MFC and Visual C++
Avatar of govindm
govindm

U can set the column with for each column seperately using the following function.
CGridCtrl::SetColWidth(nColumn, nWidth);


Avatar of uanmi

ASKER

When I try to use this I am told that SetColWidth is
not a member of CMsDGridCtrl.
CMsDGridCtrl is of type CWnd and is an OCX
found with Visual Basic 5.
I'm not sure this is any use to me.
CGridCtrl::SetColWidth(nColumn, nWidth);

any other ideas would be appreciated.
Have u imported the grid control from the component gallarey or how.

I have imported the grid control from the componet gallary and using this method,

Even dynamically u can set the width and height of the column.


Does CMsDGridCtrl derived from the CWnd?
When u import the grid control from the component gallary there are
one .cpp( usally Gridctrl) and a .h files will be added to ur project.
in the newly added  files u will be finding out the  SetColWidth function declaration(.h) and definition( .cpp).
Which intern calls the  CWnd::InvokeHelper function.

I feel u have't included the .cpp and .h file in ur project that could be the reason.
I think this is the answer u want.

u can reply to my email id - govindm@teil.soft.net
Avatar of uanmi

ASKER

I'm using the DBGrid that came with Visual Basic 5.
I'm not using the Grid Ctrl.

HI uanmi,

Do u want to set the column width for each column once or u want to change often?
If u want to set the column width only once, there is an option

Set the default width to 0(zero) then it takes the column width as the header length as the column width. so if u want to have the column like "Data" and if u need width is larger than  header length change the header as  "          Data                  ".
This u can set individually for all columns.



HI uanmi,

Do u want to set the column width for each column once or u want to change often?
If u want to set the column width only once, there is an option

Set the default width to 0(zero) then it takes the column width as the header length as the column width. so if u want to have the column like "Data" and if u need width is larger than  header length change the header as  "          Data                  ".
This u can set individually for all columns.



ASKER CERTIFIED SOLUTION
Avatar of tma050898
tma050898
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial