Autoresize column for ClistCtrl

Hi,

how could I have a Clistcontrol that always resizes its columns(>=1) 
exactly to fit its content.
Recently I saw an article on codeproject for a C# ListView control where 
they use a trick.
They send a [Control] + [+] key , it possible to do the same with MFC.
If not how can I do the same ?
0
7/24/2007 3:03:16 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
541 Views

Similar Articles

[PageSpeed] 11

I have seen that done.  First see if SetColumnWidth with either 
LVSCW_AUTOSIZE or LVSCW_AUTOSIZE_USEHEADER will help you out.

If not see this article. (It mainly about a bug in windows related to 
resizing a list control and it's header dynamically)
http://www.codeproject.com/useritems/Auto_Size_ListCtrl_Header.asp

AliR.


"mosfet" <john.doe@anonymous.org> wrote in message 
news:46a614b4$0$18667$426a74cc@news.free.fr...
> Hi,
>
> how could I have a Clistcontrol that always resizes its columns(>=1) 
> exactly to fit its content.
> Recently I saw an article on codeproject for a C# ListView control where 
> they use a trick.
> They send a [Control] + [+] key , it possible to do the same with MFC.
> If not how can I do the same ? 


0
AliR3470 (3235)
7/24/2007 3:17:45 PM
So you use a table in CListCtrl?
Use CGridCtrl from codeguru or codeproject to handle grids. It has
auto-resize.
Regards, Guido


"mosfet" <john.doe@anonymous.org> schrieb im Newsbeitrag
news:46a614b4$0$18667$426a74cc@news.free.fr...
> Hi,
>
> how could I have a Clistcontrol that always resizes its columns(>=1)
> exactly to fit its content.
> Recently I saw an article on codeproject for a C# ListView control where
> they use a trick.
> They send a [Control] + [+] key , it possible to do the same with MFC.
> If not how can I do the same ?


0
guidof73 (128)
7/24/2007 3:18:08 PM
http://www.codeproject.com/useritems/Auto_Size_ListCtrl_Header.asp
http://www.codeguru.com/Cpp/controls/listview/columns/article.php/c913
http://www.czvc.com/tech/MFC%20Programmer's%20SourceBook/listview/autosize_col.shtml.htm


Tom
"mosfet" <john.doe@anonymous.org> wrote in message 
news:46a614b4$0$18667$426a74cc@news.free.fr...
> Hi,
>
> how could I have a Clistcontrol that always resizes its columns(>=1) 
> exactly to fit its content.
> Recently I saw an article on codeproject for a C# ListView control where 
> they use a trick.
> They send a [Control] + [+] key , it possible to do the same with MFC.
> If not how can I do the same ? 

0
tom.nospam (3240)
7/24/2007 3:20:40 PM
AliR (VC++ MVP) a �crit :
> I have seen that done.  First see if SetColumnWidth with either 
> LVSCW_AUTOSIZE or LVSCW_AUTOSIZE_USEHEADER will help you out.
> 
> If not see this article. (It mainly about a bug in windows related to 
> resizing a list control and it's header dynamically)
> http://www.codeproject.com/useritems/Auto_Size_ListCtrl_Header.asp
> 
> AliR.
> 
> 
> "mosfet" <john.doe@anonymous.org> wrote in message 
> news:46a614b4$0$18667$426a74cc@news.free.fr...
>> Hi,
>>
>> how could I have a Clistcontrol that always resizes its columns(>=1) 
>> exactly to fit its content.
>> Recently I saw an article on codeproject for a C# ListView control where 
>> they use a trick.
>> They send a [Control] + [+] key , it possible to do the same with MFC.
>> If not how can I do the same ? 
> 
> 
Yes it works thanks
0
7/24/2007 3:23:35 PM
"mosfet" <john.doe@anonymous.org> wrote in message 
news:46a614b4$0$18667$426a74cc@news.free.fr...
> Hi,
>
> how could I have a Clistcontrol that always resizes its columns(>=1) 
> exactly to fit its content.
> Recently I saw an article on codeproject for a C# ListView control where 
> they use a trick.
> They send a [Control] + [+] key , it possible to do the same with MFC.
> If not how can I do the same ?

Don't do that.  Do this:

    // Optimally resize columns
 for (int i=0; i < NUM_COLS; i++)
  MyListControl.SetColumnWidth (i, LVSCW_AUTOSIZE_USEHEADER);

-- David



0
dc2983 (3206)
7/24/2007 6:46:57 PM
Reply:

Similar Artilces:

column & border width in excel
Hi, I need to write a document in excel with a column width of 1 cm, and a border width of 0,3 cm example: |_____|||||_____|||||_____|||||_____|||||_____|||||_____|||||_____|||||_____| Maybe I can try to put a value of 7 (???) in the colum width, and not calculate the border width, but i need to be the most accurate than I can to do. What do you think is the best solution for me? Thank you Enrico Enrico wrote: >What do you think is the best solution for me? > >Thank you >Enrico Ps I'm using Excel 2000 Documents should written with a word processor. Word will create t...

Need more columns #2
I desperately need *more than the standard 256 columns* provided in a Excel Worksheet. Working in transpose and utilising the much highe number of rows available is not an option in this case. Many thanks Louca Gree -- LoucaGree ----------------------------------------------------------------------- LoucaGreen's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1210 View this thread: http://www.excelforum.com/showthread.php?threadid=26719 Hi Louca Impossible with Excel. QuattroPro is the most likely solution. http://www.j-walk.com/ss/qpro/ HTH. best wishes har...

How do I add numbers in two column based on the date in another?
Hi Please help. Using Excel 2003, I am trying to find a way to determine if a date changes in a range, total amounts in two columns, by date, by route otherwise return a blank. A=Route# B=Date N=Total Hours(of a call) O=Time Between Calls P=Total of N+O A B N O P 01 16/02/2010 1.25 FALSE 01 16/02/2010 1.17 0.167 01 16/02/2010 0.50 0.083 01 16/02/2010 1.25 0.083 4.503 01 17/02/2010 1.00 FALSE 1.00 I trie...

Totaling columns
I was so impressed with the wonderful responses and spot on answers to my first question on this site I thought I would give this one a try. I did try to research to find this on the site, but perhaps I am wording my search incorrectly. My question is: On my download I run a macro that I have set up do calculations on my worksheet. 1.Each time the report is ran it would have varying information and varying numer of lines. For each run of the report the columns below would a have the following in common, but again each run would have a varying amount of rows) 2. Col A will...

split column into 4 columns
I need some assitance making a huge column into 4 columns. Here is the scenerio: Col A has any given rows of values / text. and I need to split into 4 columns But this is where it gets tricky. a1 =a a2=b a3=c a4=d a5=e a6=f a7=g etc... I need b1=a, c1=b, d1=c, e1=d b2=e, c2=f, d2=g, etc.. What is the best way to do this? Put this in B1: =OFFSET($A$1,4*(ROW()-1)+COLUMN()-2,0) drag across to fill B1:e1 and drag down until you run out of data. Jack wrote: > > I need some assitance making a huge column into 4 columns. Here is the > scenerio: > Col A has any given rows of value...

How can I see column headings of hidden columns in Excel before u.
I have a large spreadsheet with several columns hidden. I want to unhide a specific column that I know has a column name of Project Owner. How can I determine which column to unhide to see the desired column without unhiding all of the columns? I tried the find feature, but that did not help. assuming you have your name in row 1 of the column, you could use MATCH or in vba you could use FIND Sub findcol() Columns(Rows(1).Find("yournamehere").Column).Hidden = False End Sub -- Don Guillett SalesAid Software donaldb@281.com "Beachcomber" <Beachcomber@discussions.m...

Insert text from column A into column B, before text in column B
Hi, I am working with a very large database and I need to find a simple way of inserting the text from 1 column and pasting it into another column, which already has text in it. I want to paste this text to show up before the text in the 2nd column. Here is an example: COLUMN A /images/products/ COLUMN B AA-067.jpg WHAT I WANT TO HAPPEN: COLUMN B /images/products/AA-067.jpg Anyone have any ideas? Please let me know. I've been struggling with what seems to be easy. Thanks :rolleyes: -- dbsupplements ------------------------------------------------------------------------ dbsup...

Last Paid column in Bills & Deposits
Has anyone else noticed that the "Last Paid" column in Bills & Deposits doesn't always reflect the correct date of the last payment? Is there a way to fix this? I have Money 2004 Small Business. - Glen ...

How do you perform a two-column lookup?
I am trying to do a lookup using 2 columns. Example would be SKU Warehouse Qty 13 CA 15 14 CA 30 15 CA 18 13 HN 10 14 HN 5 I want to be able to pull the qty for any given SKU Warehouse combination. Any help would be great. Assuming your headers are in row 1 and the data in A2:C6, use SUMPRODUCT with double unary operators, comme ca: =SUMPRODUCT(--($A$2:$A$6=13),--($B$2:$B$6="CA"),$C$2:$C$6) This link http://groups.google.com/...

Selecting columns containing spaces
Both of these Select statements return the same set of rows. How can I find out what's really in them? Select * from tblAcademics where description = "" Select * from tblAcademics where description = " " In particular, can I trust that description is not null in those rows? The following SQL returns no rows Select * from tblAcademics where description is null A column is either NULL or NOT NULL. It cannot be both. If it contains a space or an empty string then it is NOT NULL. -Dorian "Laurel" wrote: > Both of these Select statements return t...

How do I get 18 numbers to display in a column and not round out
I need a column to display 18 numbers and currently it is rounding the last three with zeros. I am using Microsoft 2003 How many digits in the numbers More than 15? Then you will need to type then as text and will not be able to do math on them Either a) when typing, precede the entry with a single quote (will not show in cell or printout b) before typing, format cells as Text best wishes -- Bernard Liengme Microsoft Excel MVP people.stfx.ca/bliengme email address: remove uppercase characters "whamm24" <whamm24@discussions.microsoft.com> wrote in message ...

Variable column width
I need to build a "profit pool chart". These charts show the opreating margin of each activity in a value chain in the vertical axis and their corresponding share of industry revenues in the horizontal axis. The issue is that I do not know how to build a chart where each input has a different column width (corresponding to their share of industry revenues). Does anyone know how I to do this? Thanks. Hi, Here are some examples, which also include links to another couple of variations. http://www.andypope.info/charts/colwidth.htm http://www.andypope.info/charts/colwidth2.htm ...

columns/rows
I have a spreadsheet that I have to enter xxxxx digits into the first column/first row. I was wondering if there was a way to set the spreadsheet to complete the xxxx1, xxxx2 xxxx3 in the rows beneath automatically? If no is it because excel does not know what numbers would come next? One way. You could also have a worksheet_change event where it would be entirely automatic. Sub addonto() For i = 2 To 4 Cells(i, 1) = Cells(i - 1, 1) + 1 Next i End Sub -- Don Guillett SalesAid Software donaldb@281.com "teddkilroy" <teddkilroy@discussions.microsoft.com> wrote in message ...

finding column
Gooday all, I currently have some names in various columns but on the same same row. I have at the moment been able to search for a name in the column. But as I dont know the actual cell how can I find the cell name? example names are in D12, E12 .... P12 they are all on row 12 but I dont know the column. the search looks at each column untill it finds a match, if it gets to an empty cell on row 12 the search ends, if it find the cell I need to delete the column. Taking into acount that P12 may go as far as FF12!! I dont actualy know. Does this make sense? Use the MATCH() function: ...

Columns Problem
Hello Fellow Excel users, I have alittle problem which i hope somebody can point me in the right direction Picture my screen in excel Col A is a list of Names with Multiple entries for the same person Col B is a number ranging from 0 to 7 eg A B Joe Bloggs 1 Jim Smith 2 Joe Bloggs 4 Pete Smith 5 Jim Smith 4 What i want to create is another list where Col A is a list of names Just 1 entry per name Col B the sum of all entries for that persons name e...

Autosum column ignoring the negatives.
Hello all, I have a columnn of data with an autosum feature. Some of the entrie maybe negative, how do I autosum but do not include any negativ values. TIA -- Message posted from http://www.ExcelForum.com =SUMIF(A:A,">0") HTH Jason Atlatna, GA >-----Original Message----- >Hello all, >I have a columnn of data with an autosum feature. Some of the entries >maybe negative, how do I autosum but do not include any negative >values. >TIA. > > >--- >Message posted from http://www.ExcelForum.com/ > >. > ...

Stacked Column on single column
Good day everybody, I would like to show four figures in one chart. I have use two-axes bar chart. Example, Expenses Sales Commission Royalty Product A 20 100 10 Product B 30 If you just plot the data you have posted as a stacked bar chart, Product A would have three items stacked on it, and Product B would have 1, because the other two have zero value. Is this what you want? - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ Julie wrote: > Good day ev...

Combo Box
Hi, AFTER a user has choosen a row from a combo box, it appears that the combo box automatically display the first printable column. Is there a way to display someother column than the 1st printable column? Sometime I would like to print the 2nd or 3rd column. Is there a way to do this? -- Dennis Dennis wrote: > Hi, > > AFTER a user has choosen a row from a combo box, it appears that the > combo box automatically display the first printable column. > > Is there a way to display someother column than the 1st printable > column? Sometime I would...

Column Chart
Other than adding a text box, is there a way to add text in each column individually? Example: I have a chart showing several tasks and the their cost is listed as a data label (aligned: outsided end). I'd like to add the hours it takes to complete the task in the column, near the bottom. If this is not possible, any recommendations? Thank you! You can add data labels to the column, but you are already using data labels for this series. What I would do is add a line chart series to the chart, with appropriate data values, and apply the data labels to this series. Format the lin...

need to transpose 3 or 4 columns to one column
The matrix below represents what I need to do in Excel. I need to transpose the data from row 1 of C1, C2, C3 and C4 to rows 1-4 of C5 then repeat for each additional row of C1-C4. I think I might need a macro but I have no idea how to write it. Any help would be appreciated. My data set is too large to utilize cut and paste special. Thank you for your responses. Rufus C1 C2 C3 C4 C5 5 4 3 5 5 4 3 4 5 4 5 4 3 2 3 5 4 3 4 5 5 4 3 2 Rufus, If your example table is entered in cells A1:D4, enter this into cell E2, and copy down until it returns #REF ...

Show value with 2 condition in a column
Hi Expert, Example , I have this table Items Country Pric Banana USA $ 22 Banana Canada $ 2 Mango Canada $ 25 Orange France $ 2 Apple USA $ 33 Orange Canada $ 2 What is the formula to find a price by giving 2 condition of Items and country Thanks. Hi try something like the following array formula (entered with CTRL+SHIFT+ENTER): =INDEX(C1:C100,MATCH(1,(A1:A100="Banana")*(B1:B100="USA"),0)) or try =SUMPRODUCT(--(A1:A100="Banana"),--(B1:B100="USA"),C1:C100) ...

Delete Columns
HI, I am new to this site and have tried to find my specific problem and have not been able too. I have an excel spreadsheet, that was previously created by others (no longer working here) We have been able to use the data and get the graphs out just fine. But when you go to delete a graph the format, fonts whatever are changing and cannot be fixed at all. NO matter what data you put in. I am trying to delete 3 columns and keep the other 13 in tact. but to no avail, I can get them deleted but I cannot keep the same column. mine are thin and colored. The ones I delete makes mine crowded togeth...

Downward column
Hi suppose that,my data set on column x and second row(x2),i want to move this column to desired row. For example: data position is x2 and expected position is x7644. I need to a macro, when run it then at first open the Box, and take me new row number, and finally, move data on column x to new row number. Would you please guide me? best regards Please note that, my data set on column x for example is x2: x570 and i want to move to new position x7644:x8214. i have many file and little time. thus i need to a macro that before explained. regards "climate" wrot...

How to use goal seek on column
Hi! I have a formula in cell C which is dependant on values in cell A and B. I use goal seek to adjust the value in cell A to meet the goal for C. This works perfectly. However I would like this to be performed on all rows in column C. Is this possible? Example: Column A Column B Column C 1 1 =A/B 5 3 =A/B .... ... =A/B An answer would be much appreciated! /Daniel Hi, Goal seek is designed to work on one cell at a time only. Why not show...

How do you password protect a single cell or column of cells
I am trying to password protect a column of single cells but it keeps protecting the whole work sheet can ant one help? Select all the column not to be protected; Use Format | Cells | protection and deselect the Lock box Now Tools | Protect | worksheet Does this give you what you want? best wishes -- Bernard V Liengme Microsoft Excel MVP www.stfx.ca/people/bliengme remove caps from email "Kinnaird" <Kinnaird@discussions.microsoft.com> wrote in message news:0D46DB91-B014-492A-94D8-24D5190CD154@microsoft.com... >I am trying to password protect a column of single cells bu...