|
-
April 29th, 1999, 02:08 PM
#1
Columns in list control
How do you get the column count of a list control?
-
April 29th, 1999, 04:17 PM
#2
Re: Columns in list control
For MSVC 6:
// How many columns are there?
int MyListCtrl::GetColumnCount() const
{
// One of the few examples of when this cast is okay. (Microsoft forgot
// to supply a const CListCtrl::GetHeaderCtrl() - doh!)
CHeaderCtrl* pHeader = const_cast<MyListCtrl*> (this)->GetHeaderCtrl();
ASSERT_VALID(pHeader);
return pHeader ? pHeader->GetItemCount() : -1;
}
For MSVC5, this is the best we can do:
// Does the sent column exist?
BOOL MyListCtrl::IsColumn(int nCol) const
{
_ASSERTE(0 <= nCol);
LV_COLUMN lvc;
::ZeroMemory(&lvc, sizeof(lvc));
lvc.mask = LVCF_WIDTH;
return -1 < nCol && GetColumn(nCol, &lvc);
}
LA Leonard - http://www.DefinitiveSolutions.com
-
April 29th, 1999, 04:45 PM
#3
Re: Columns in list control
I thank you for your response, but I am still using vc4 for the meantime. I hope you have an example for this version?
-
April 29th, 1999, 05:21 PM
#4
Re: Columns in list control
The one for MSVC5 should work for MSVC4, I think...
LA Leonard - http://www.DefinitiveSolutions.com
-
April 30th, 1999, 08:39 AM
#5
Re: Columns in list control
I tried it and it did the trick. Thanks!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|