Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I must fill my list but I don't want to fill the first column, how can I write?
C++
for (int nTagli = 0; nTagli< 10; nTagli++)
	{
		m_list.InsertItem(nTagli, _T(""), -1);
		m_list.SetItemText(nTagli, 1, _T("ciao"));
		m_list.SetItemText(nTagli, 2, _T("ciao1"));
		m_list.SetItemText(nTagli, 3,_T("ciao2"));
		m_list.SetItemText(nTagli, 4, _T("ciao3"));
	}
In this way I must fill the first column with an empty space..but I don't want to fill list not at all

What I have tried:

I tried to write in the first column but I don't find the correct way.
Posted
Updated 11-Jan-24 22:54pm
v3
Comments
Richard MacCutchan 11-Jan-24 6:20am    
Why do you need the item text to be null?
Member 14594285 11-Jan-24 6:22am    
because I must draw in the first column and the first column must be empty
Richard MacCutchan 11-Jan-24 9:09am    
If you set the text to the null string as shown above it should work.
Member 14594285 11-Jan-24 9:12am    
yes but there is an empty space and the first column isn't drawn correctly
Richard MacCutchan 11-Jan-24 9:40am    
Of course there is an empty space, that is what you asked it for. You need to explain exactly what you are trying to do here. Also, if you wish to reply to a comment then please use the Reply button above the message. That way I get a notification that you replied.

You probably need to use the LVS_OWNERDRAWFIXED style which allows you to draw the item yourself. See
List-View Window Styles (CommCtrl.h) - Win32 apps | Microsoft Learn[^] and also this article: Using virtual lists[^].
 
Share this answer
 
Comments
Member 14594285 11-Jan-24 11:31am    
I wrote:
m_list1.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FLATSB | LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES | LVS_OWNERDRAWFIXED);

but my problem isn't solved
Richard MacCutchan 11-Jan-24 11:47am    
Well unless you explain the problem in proper detail there is nothing we can suggest.
Member 14594285 11-Jan-24 11:50am    
the poblem is that I can't draw in the first column of my list if I write:

for (int nTag = 0; nTag< 10; nTag++)
{
m_list.InsertItem(nTag, NULL, -1);

m_list.SetItemText(nTag, 1, _T("ciao"));

m_list.SetItemText(nTag, 2, _T("ciao1"));

m_list.SetItemText(nTag, 3,_T("ciao2"));

m_list.SetItemText(nTag, 4, _T("ciao3"));
}

I want to fill the list from the second column
Richard MacCutchan 11-Jan-24 12:13pm    
No, because you are not following the rules for an owner drawn List control.
I recommend that you take a look at this article and especially the code : Another Report List Control[^].

That is an owner-drawn list control in MFC and I use this class all the time. It is quite good I think.
 
Share this answer
 
Comments
Member 14594285 12-Jan-24 4:26am    
I used this class, but I see that there isn't a method to color header of the column
Member 14594285 12-Jan-24 9:04am    
Thank you, very useful
Use must fill the first column to use the ListControl. Use some graphic or some white picture.
Else redesign your app and try some other solution like text outside of the ListControl to provide the extra information.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900