Hello!!
Can anyone know : How to resize row height of CListCtrl based on data so that data can be adjusted in row?
It Very Very URGENT!!!!!!!!!!!!!
Printable View
Hello!!
Can anyone know : How to resize row height of CListCtrl based on data so that data can be adjusted in row?
It Very Very URGENT!!!!!!!!!!!!!
You need an ownerdrawn CListCtrl for this. Then just use measureitem. See http://www.codeproject.com/KB/list/changerowheight.aspx for an example.
Marc,
I have sent to you one project that one related to Print Preview. In that project only i do want to increase row height.
I have already been to your posted link but i did not get success..
Can you please look in to my sent project?
I don't have time to look at it in depth.
You need to owner draw the listctrl.
Unfortunately, owner drawing can be complicated.
See: http://www.codeguru.com/Cpp/controls...icle.php/c949/ for an example on how to ownerdraw. Once you understand that, you can handle wm_measureitem to change the height of the rows.
Marc,
It is OK. if by chance if you get sometime then do have a look on my attachment.
i will have a look on your attached link.
Thanks anyways.
I took a quick look, I'm confused.
You are already using owner drawing, so I don't see the problem...
In your code you have the following piece:
Which is specifying the size of a row.Code:void CColoredListReport::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
lpMeasureItemStruct->itemHeight = 40; //CDC::gettexte;
}
Marc,
This is fixed size of the row. but suppose if one row contains 2 lines and another row contains 5 line then for first one we will aable to see all lines with extra space and for another one we will able to only 3 lines.
So i do want to set row height at runtime based on the number of lines in row so that we can see all lines for a particular row without extra spacing between rows.
Unless I'm missing something... a ListControl cannot have variable sizes per item. All the items have the same size.
A listbox can have variable size items, but then you'll miss out on a lot of features that are present in a listcontrol.
OReubens,
We can resize all row's height in list Control. Please do have a look on attached link.
http://www.codeguru.com/Cpp/controls...icle.php/c1013
I don't know what you're aiming at, but nothing in that post seems to indicate that rows of varying heights is possible. Quite the opposite even several people are asking for it, but don't get an answer.
As an affirmation. THe measure item message does NOT provide the item it's trying to size, it's only giving a single ID (the ID of the control). So how would you expect to size individual items when the function called to provide the heights doesn't even know what item it's referring to.
It's possible I'm wrong, but there's a lot more evidence proving my point than there is to proove variable row heights are possible in a listcontrol.
Ok, OReuBen. I will work on it and let u know.
Tel me one thing is there any control which can create 4-5 column with multliple line in a row?
Sample::::
----------------------------------------------------
Col 1 | Col 2 | Col 3 | Col 4 | Col 5 | Col 6|
__________________________________
C1R1 | C2R1 | C3R1 | C4R1 | C5R1 | C6R1|
__________________________________
C1R2 | C2R2 | C3R2 | C4R2 | C5R2 | C6R2|
__________________________________
C1R3 | C2R3 | C3R3 | C4R3 | C5R3 | C6R3|
__________________________________
C1R4 | C2R4 | C3R4 | C4R4 | C5R4 | C6R4|
__________________________________
Note: CxRy can be multiline.
If you do know, please do let me know||
Victor,
If you do have some time, can you have a look on my attached project which i had attached earlier. If there is some thing can you let me know.
I will once again look into your sent link though i have already looked into it but did not get success
Sorry, I don't have enough time...
Victor,
In your sent link, it is creating multiline using Cwnd. But I have to use CFormView and over CFormView, I have to use CListCtrl.
Is ther any way to create multiline row in CListCtrl?
1. What is the problem to use *this* custom control on the FormView? :confused:
2. Why do you "have to use" CListCtrl? :confused:
I don't know!
Try to search in the ListControl sections of www.codeproject.com and www.codeguru.com
A CListCtrl does not provide a means to do what you ask (rows of variable height)
A CListBox can do variable row heights, but it doesn't have a lot of support for columns, you can display columns, but they're typically not user-adjustable (no header control).
A custom control like the one Victor linked is another possible alternative. The one he linked is one example, I'm sure there are other people that have made something similar as well, look around. Alternatively, you can write your own variety of a custom control that does exactly what you want.
With a load of "tweaks" you can probably make a CListCtrl sort of do what you want, with a number of restrictions.
1) Insert each row as an individual item and somehow maintain a "grouping" to know which individual rows make up a single logical item.
2) Set the listcontrol to multi selection.
3) When a row is selected, you also programmatically select all the other rows in the same grouping. When a row is deselected, you also programmatically deselect all the other rows in the same grouping.
This approach will have a number of visual, aestetical and usability issues, but this may be acceptable to you.
It's possible that for various reasons it won't work out. You're asking for doing something the CListCtrl wasn't designed for. Sometimes, you can work around that with varying degrees of success, and sometimes you can't.
Hi all,
i m increase the row height of ListCtrl with using of this code.
#1 September 24th, 2010, 12:43 AMCode:
1.Change the style of list control to “owner draw fixed” style!
2. m_RowList.ModifyStyle( LVS_OWNERDRAWFIXED, 0, 0 ); //in OnInitDialog
3.
void CDialogGuineaPig::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
// If this is our list control then increase height
if( nIDCtl == IDC_ROWLIST )
{
// Increase height by 10
lpMeasureItemStruct->itemHeight += 10;//10 is new row height
}
}
vjshankwar
Member + Join Date: Jan 2008
Location: India
Posts: 676
Row height of List Ctrl not change when Checkbox option used in List.
--------------------------------------------------------------------------------
Hi all,
i m increase the row height of ListCtrl with using of this code.
Code:
1.Change the style of list control to “owner draw fixed” style!
2. m_RowList.ModifyStyle( LVS_OWNERDRAWFIXED, 0, 0 ); //in OnInitDialog
3.
void CDialogGuineaPig::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
// If this is our list control then increase height
if( nIDCtl == IDC_ROWLIST )
{
// Increase height by 10
lpMeasureItemStruct->itemHeight += 10;//10 is new row height
}
}this is working fine but when i use CheckBox style in List ctrl its not working please tell me how can i increase List Row height with Checkbox.
please tell me how can i do this.
thanks in advance.
Did you mean that the list control with LVS_EX_CHECKBOXES extended style didn't change the item height?
Is the OnMeasureItem called in the case you "use CheckBox style in List ctrl"?
I would assume the list control has another ID and therefore the increase wasn't applied.
The OnMeasureItem was called once for a list control. I did it myself a year ago and there is no way out.
However the grouping suggested works quite fine if you can go without icons, checkboxes, automatic sort. I used a special background color for each second logical group and even achieved to place an edit control exactly above some multiple cells of a column in order to allow inline editing. Nevertheless the efforts were immense and if there is a custom multiline-listcontrol available I would go this way.
even ClistCtrl is derived from CWnd right? then why dont you use scope resolution operator :: and access base class methods...
Unless i'm mistaken, LVS_EX_CHECKBOXES and ownerdraw can't be combined.
So just for clarity sake and for all future reference.
A CListControl (a.k.a. SysListControl32 common control) CANNOT create a list where each row determines it's own size. The 'FIXED' in the LVS_OWNERDRAWFIXED is further evidence that this is the case.
You can make a CListCtrl owner draw and make the rows any height you want, but every row will have this same height.
You can "fake" multiline by using multiple list rows and handling item selection to select a group of rows, but this will have a number of visual and usage limitation/issues which may or may not be acceptable to you.
A CListBox CAN be made with rows of variable height. This is done by using the LBS_OWNERDRAWVARIABLE style (as opposed to LBS_OWERDRAWFIXED). Do NOT use the LBS_ styles on a CListCtrl, it won't work.
A CListBox however doesn't have all the features of a listcontrol. Again, the different behaviour of a listbox may or may not be an issue to you.
You can create your own type of control (or use one someone else has made) that mimics a CListCtrl as much as possible but allows multiline variable rows. Again, this may or may not have any number of isues.
You may also be able to make something that works for you by using something else entirely like a RichEdit or a CHtmlEditCtrl. It won't work and behave like a listcontrol, but you may be able to get a result that achieves what you're after.