Solved

how to change column width in CMsDgridCtrl

Posted on 1998-05-24
8
509 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Folder Comparison 12 55
Best tools for Backup and restore of Wordpress site 6 58
Sed question 2 123
Detect file exist or not 3 202
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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