From: Jay on
Hi All
I am trying to create a 4 column ListBox .
I have added the ListBox to the Dialog & set the MultiColumn
property there.

Using the following names could someone give me some code to,
1/ Create 4 Columns in the ListBox
2/ Load "some data" into each column in row 0

Name : ListBox
Control Variable : m_ctrlList
String Variable :m_strList

Any help is much appreciated as I am not having much luck
with MSDN or the web,


Jay


From: Frank Hickman [MVP] on
"Jay" <itsjayceecee.NoSpam(a)hotmail.com> wrote in message
news:%23nYiUMSIFHA.3332(a)TK2MSFTNGP14.phx.gbl...
> Hi All
> I am trying to create a 4 column ListBox .
> I have added the ListBox to the Dialog & set the MultiColumn
> property there.
>
> Using the following names could someone give me some code to,
> 1/ Create 4 Columns in the ListBox
> 2/ Load "some data" into each column in row 0
>
> Name : ListBox
> Control Variable : m_ctrlList
> String Variable :m_strList
>
> Any help is much appreciated as I am not having much luck
> with MSDN or the web,
>
>
> Jay


Very basic example...

BOOL CDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// <snip> removed all the MFC generated code for a dialog based app...

// TODO: Add extra initialization here

m_ctrlList.InsertColumn( 0, _T("Column 1"), LVCFMT_LEFT, 100 );
m_ctrlList.InsertColumn( 1, _T("Column 2") ); // Default
formatting...

m_ctrlList.InsertItem( 0, _T("Item One") );
m_ctrlList.SetItemText( 0, 1, _T("SubItem One") );


m_ctrlList.InsertItem( 1, _T("Item Two") );
m_ctrlList.SetItemText( 1, 1, _T("SubItem Two") );

m_ctrlList.InsertItem( 2, _T("Item Three") );
m_ctrlList.SetItemText( 2, 1, _T("SubItem Three") );

return TRUE; // return TRUE unless you set the focus to a control
}


--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp(a)m_ with @ to reply.


From: Joseph M. Newcomer on
Actually, you answered the question for a list control, which is what I think he really
wants anyway. He is thinking a multicolumn listbox is something other than what it really
is, which is a listbox which has multiple columns to display single top-level data. So my
advice was going to be that he should use a list control--so you've already answered that.
joe

On Fri, 4 Mar 2005 23:11:10 -0500, "Frank Hickman [MVP]" <fhickman_NOSP(a)M_noblesoft.com>
wrote:

>"Jay" <itsjayceecee.NoSpam(a)hotmail.com> wrote in message
>news:%23nYiUMSIFHA.3332(a)TK2MSFTNGP14.phx.gbl...
>> Hi All
>> I am trying to create a 4 column ListBox .
>> I have added the ListBox to the Dialog & set the MultiColumn
>> property there.
>>
>> Using the following names could someone give me some code to,
>> 1/ Create 4 Columns in the ListBox
>> 2/ Load "some data" into each column in row 0
>>
>> Name : ListBox
>> Control Variable : m_ctrlList
>> String Variable :m_strList
>>
>> Any help is much appreciated as I am not having much luck
>> with MSDN or the web,
>>
>>
>> Jay
>
>
>Very basic example...
>
>BOOL CDemoDlg::OnInitDialog()
>{
> CDialog::OnInitDialog();
>
> // <snip> removed all the MFC generated code for a dialog based app...
>
> // TODO: Add extra initialization here
>
> m_ctrlList.InsertColumn( 0, _T("Column 1"), LVCFMT_LEFT, 100 );
> m_ctrlList.InsertColumn( 1, _T("Column 2") ); // Default
>formatting...
>
> m_ctrlList.InsertItem( 0, _T("Item One") );
> m_ctrlList.SetItemText( 0, 1, _T("SubItem One") );
>
>
> m_ctrlList.InsertItem( 1, _T("Item Two") );
> m_ctrlList.SetItemText( 1, 1, _T("SubItem Two") );
>
> m_ctrlList.InsertItem( 2, _T("Item Three") );
> m_ctrlList.SetItemText( 2, 1, _T("SubItem Three") );
>
> return TRUE; // return TRUE unless you set the focus to a control
>}

Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Frank Hickman [MVP] on
"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:83hi21pduu843chu5394rqtc22cg8lbmtd(a)4ax.com...
> Actually, you answered the question for a list control, which is what I
> think he really
> wants anyway. He is thinking a multicolumn listbox is something other than
> what it really
> is, which is a listbox which has multiple columns to display single
> top-level data. So my
> advice was going to be that he should use a list control--so you've
> already answered that.
> joe
>

Good eye Joe, I didn't catch that, obviuosly :)

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp(a)m_ with @ to reply.


From: Jay Cee on
Thank you Frank & Joe
Its a good thing you both knew what I wanted !!!

Works perfectly and explained in an easy sample.

Regards,

Jay



"Frank Hickman [MVP]" <fhickman_NOSP(a)M_noblesoft.com> wrote in message
news:%23D8tg%23UIFHA.3760(a)TK2MSFTNGP12.phx.gbl...
> "Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
> news:83hi21pduu843chu5394rqtc22cg8lbmtd(a)4ax.com...
>> Actually, you answered the question for a list control, which is what I
>> think he really
>> wants anyway. He is thinking a multicolumn listbox is something other
>> than what it really
>> is, which is a listbox which has multiple columns to display single
>> top-level data. So my
>> advice was going to be that he should use a list control--so you've
>> already answered that.
>> joe
>>
>
> Good eye Joe, I didn't catch that, obviuosly :)
>
> --
> ============
> Frank Hickman
> Microsoft MVP
> NobleSoft, Inc.
> ============
> Replace the _nosp(a)m_ with @ to reply.
>
>