|
I have a table filled in from reading a text file and I load that into a multi column CListCtrl, which is fine, I can also append to columns in there.
Is there an easy way to delete a specific column on a specific row?
What I'm doing right now:
a dialog button "Clear Entry" calls GetSelectionMark() on the table, and uses that to set the columns to "" in a rather heavy handed way
LVITEM lvi;
CString item = "";
lvi.mask = LVIF_IMAGE | LVIF_TEXT;
lvi.iItem = sel;
lvi.iSubItem = 3;
lvi.pszText = (LPTSTR)(LPCTSTR)(item);
m_Table.SetItem(&lvi);
lvi.iSubItem = 5;
lvi.pszText = (LPTSTR)(LPCTSTR)(item);
m_Table.SetItem(&lvi);
this seems to work fine, though there are issues
1) if the table hasnt been clicked there is no selection mark.
2) you can only click on the 1st column in a particular row - this is fine, but if I then click "Clear Entry" button, it works OK but the blue highlight disappears like that row is no longer selected but if I add data there and click "Clear Entry" it seems to remember what was last selected and deletes those items - a bit messy
I see DeleteAllItems and DeleteColumn, but how can I delete just one item on one particular row in an elegant way?
tia
L
|
|
|
|
|
ldsdbomber wrote: 1) if the table hasnt been clicked there is no selection mark.
So just disable the "clear" button until a selection is made.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ldsdbomber wrote: Is there an easy way to delete a specific column on a specific row?
For a row subitem to be considered "deleted", that means its text is empty, correct?
If so, the only way I see to "delete" the subitem is to set its text to "" like you are doing.
I personally prefer to use LPSTR_TEXTCALLBACK instead of storing the text in the control.
Then when a LVN_GETDISPINFO notification is received, I can supply the text for all the items
and subitems.
This allows me to store objects of any type (representing the listview items) in any container
I prefer to use (array, etc).
Then, to "delete" an item, I can set a flag indicating the item is "deleted" or actually change
the text in my list object and refresh/repaint the control. Then the updated text is changed
the next time the LVN_GETDISPINFO is received for the item/subitem. (if that makes sense )
ldsdbomber wrote: 1) if the table hasnt been clicked there is no selection mark.
If you aren't relying on the user to select items then you'll have to keep track of what items
are in the list yourself. Another advantage of storing the data separately as I described above.
ldsdbomber wrote: 2) you can only click on the 1st column in a particular row
Even with the LVS_EX_FULLROWSELECT extended style?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark,
where do I put this LVS_EX_FULLROWSELECT. I don't see that style in the dialog resource view, and have tried programmatically setting it via SetExtendedStyle, but maybe I am doing it wrong, I've created a control member variable for my dialog of type listview, which has the LVS_REPORT style via the dialog resource editor checkboxes.
I've tried m_Table.SetExtendedStyle(LVS_EX_FULLROWSELECT);
but maybe I'm doing it in the wrong place or wrong way?
|
|
|
|
|
OK I have found that and it now works, I had it in the wrong block of code
All I need now is which message I need to handle so that if the user clicks an item in the row, I can then use the SetExtendedStyle call, or can that be done in the InitDialog?
Also, I am still having problems selecting anything other than the 1st column item - I thought the FULLROWSELECT allowed you to select a row by clicking any of the items?
|
|
|
|
|
oh!
putting it in OnInitDialog seems to have done the trick!
many thanks
|
|
|
|
|
Cool! Yeah, OnInitDialog should be a good place to set the style
Glad you got it working!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks Mark.
Now, if only I could programmatically set the selected state - so that if data is added to the table in a particular row, it's highlighted as though the user clicked that row, it would be perfect. Have tried the SetSelectionMark but that doesn't seem to be it! Do you know how that's done~?
|
|
|
|
|
LVIS_SELECTED (SetItemState()) should be the message you want to use.
state, stateMask LVIS_SELECTED | LVIS_FOCUSED
You may need to remove the slected/focused state from the previously selected item(s)...
LVM_GETNEXTITEM (GetFirstSelectedItemPosition()/GetNextSelectedItem()) will help find those.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello,
If I have vector of int and vector of strings
vector<int>IntVector
vector<string>StringVector
and now I want to compare an int a within IntVector
and string s within StringVector
which comparison or search within these vectors will take more time.
I expect the size of vectors to be 100000.
so will it make a significant difference.
Prithaa
|
|
|
|
|
prithaa wrote: which comparison or search within these vectors will take more time.
Why don't you implement both and time them, then tell us?
led mike
|
|
|
|
|
prithaa wrote: which comparison or search within these vectors will take more time.
Without actually testing it myself, I'd say comparing strings would be slower.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
Thanks
Even I thought strings would take more time.
Pritha
|
|
|
|
|
Hi,
Why don't you try to compare ASCII code? It can be the easiest way, as long numbers and letters are there and are different, and you can use higher than, lower than, equal... as well.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
Hi, in my application I'm setting the fonts of some controls through WM_SETFONT by creating a LOGFONT and then calling CreateFontIndirect to create an HFONT from the LOGFONT.
For some reason the fonts don't look the same in debug and release mode. Also they look different on different computers. Is there a better way I can set the fonts, a more "standard" way that would look the same on all systems/modes?
For instance I wish I could just say, make the font 10 point FixedSys font. But with LOGFONT I have to give it lfHeight and lfWidth which seems somewhat arbitrary.
Thanks for help!
KR
|
|
|
|
|
KellyR wrote: But with LOGFONT I have to give it lfHeight and lfWidth which seems somewhat arbitrary.
Probably not much help, but...
I get consistent results across machines by setting only the lfHeight, lfWeight,
lfPitchAndFamily, and lfFaceName members of the LOGFONT struct. The rest of the members are set
to 0. I use a negative height and let the system pick the appropriate width.
The only inconsistency I've experienced is when using a specific font that does not come pre-
installed on all systems (so the font gets mapped to the closest match, not always good).
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I didn't realize I could use negative height to have the system auto-set width; this seems to make everything work correctly in my program. Thanks much!!
KR
|
|
|
|
|
Use (or lookup the implementation of) CFont::CreatePointFont(...) - it is great for creating fonts of specific point sizes. For example:
CFont fMyFont;
fMyFont.CreatePointFont( 100, _T( "FixedSys" ) );
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
hello, I have an project which generate boxes(bin packing) and I want to save the results on the disk(in the memory) so I can use this results in matlab or to save this results in xml so i can use xml for further reaserch please..if you know how can i do this help me ........if you can give me some clues... thanks
lavi
|
|
|
|
|
you have to know the structure of the files matlab is waiting for...
is this basic text, or binary one ?
|
|
|
|
|
if is basic test how can I save my results ...please help me... I realy need help
|
|
|
|
|
File I/O is file I/O regardless of what you put into the file. Do you know how to write to, and read from, a file?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
If you are using C++, then I would suggest file I/O from the STL. See here and here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
we've got a dialog window and are using the Power point object model to run the slide show. We've set that power point slideshow window into the main dialog window's client area by using SetWinodwPos(). The slide show runs properly, the problem is that if we click Deskop button (Show desktop) on quick launch toolbar it gives some painting issues. The slideshow window set into client area of dialog doesn't paint itself clearly. What should we do to overcome these painting issues ? Do we need to handle EraseBkground or WM_PAINT of dialog window ? what should be our move in this case ?
- Malli...!
|
|
|
|