Solved

how to change column width in CMsDgridCtrl

Posted on 1998-05-24
8
508 Views
Last Modified: 2013-11-20
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++
0
Comment
Question by:uanmi
  • 5
  • 2
8 Comments
 

Expert Comment

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


0
 
LVL 3

Author Comment

by:uanmi
ID: 1314556
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.
0
 

Expert Comment

by:govindm
ID: 1314557
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.


0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Expert Comment

by:govindm
ID: 1314558
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
0
 
LVL 3

Author Comment

by:uanmi
ID: 1314559
I'm using the DBGrid that came with Visual Basic 5.
I'm not using the Grid Ctrl.

0
 

Expert Comment

by:govindm
ID: 1314560
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.



0
 

Expert Comment

by:govindm
ID: 1314561
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.



0
 
LVL 3

Accepted Solution

by:
tma050898 earned 50 total points
ID: 1314562
uanmi,

You need to get the column you want from the columns collection and resize the column via its SetWidth method. Here's an example.

CColumns columns = m_grid.GetColumns();
CColumn column = columns.GetItem(COleVariant((short)0, VT_I2));
column.SetWidth(17);

Tom

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 96
Define unique primary key 9 95
WinWaitActive parameters 12 31
I could not set window to top 4 20
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question