Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a SetText message for the Win32 ListBox control?

This is easy in .NET (not my question) but I'm trying to figure out if it is possible to simply change the text of a string in a Win32 list box control given an index.

There is a GetText function that takes an item index but nothing to change the text of an existing item/string. My workaround will be to remove it and add it back in the box (which is also a weird prospect since there is no single command to add a string + item data -- these must be done carefully by inserting the string and then setting the item data on the index of the inserted string, which is tricky (not possible?) with sorting active).

like image 848
Jared Updike Avatar asked Mar 12 '11 03:03

Jared Updike


People also ask

How many types of listbox controls are there?

The types of forms: Simple forms, each representing a subset of the application's data. Composite forms, composed of several simple forms. Ad hoc grids, in which you aren't confined by the form's design.

Is a single line edit control?

The single-line edit control has the ES_PASSWORD style. By default, edit controls with this style display an asterisk for each character that is typed by the user. This example, however, uses the EM_SETPASSWORDCHAR message to change the default character from an asterisk to a plus sign (+).

Which of the following control is used to accept and display editable text?

Answer. Explanation: The textbox control is generally used for editable text, although it can also be made read only.


2 Answers

Yes, the lack of a LB_SETITEMTEXT message is a bit weird.

You should put your Delete+Insert+SetData calls between calls to WM_SETREDRAW...

like image 63
Anders Avatar answered Oct 21 '22 08:10

Anders


At the risk of being off topic...

I tend to use the ListView control all of the time. You'll want it in report view to mimic a listbox, and, as a plus, it supports multiple columns.

Oh.. and it has a LVM_SETITEM Message :)
http://msdn.microsoft.com/en-us/library/bb761186(v=VS.85).aspx

like image 43
Lynn Crumbling Avatar answered Oct 21 '22 10:10

Lynn Crumbling