[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how to change column width in CMsDgridCtrl

Posted on 1998-05-24
8
Medium Priority
?
528 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 100 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

650 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