Solved

how to change column width in CMsDgridCtrl

Posted on 1998-05-24
8
501 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Expert Comment

by:govindm
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Author Comment

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

0
 

Expert Comment

by:govindm
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 76
Installing Microsoft R server on REDHAT or SUSE Linux 4 125
mapBully challenge 6 88
Change to event 1 72
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now