次の方法で共有


CVSListBox Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CVSListBox Class.

The CVSListBox class supports an editable list control.

Syntax

class CVSListBox : public CVSListBoxBase  

Members

Public Constructors

Name Description
CVSListBox::CVSListBox Constructs a CVSListBox object.
CVSListBox::~CVSListBox Destructor.

Public Methods

Name Description
CVSListBox::AddItem Adds a string to a list control. (Overrides CVSListBoxBase::AddItem.)
CVSListBox::EditItem Starts an edit operation on the text of a list control item. (Overrides CVSListBoxBase::EditItem.)
CVSListBox::GetCount Retrieves the number of strings in an editable list control. (Overrides CVSListBoxBase::GetCount.)
CVSListBox::GetItemData Retrieves an application-specific 32-bit value that is associated with an editable list control item. (Overrides CVSListBoxBase::GetItemData.)
CVSListBox::GetItemText Retrieves the text of an editable list control item. (Overrides CVSListBoxBase::GetItemText.)
CVSListBox::GetSelItem Retrieves the zero-based index of the currently selected item in an editable list control. (Overrides CVSListBoxBase::GetSelItem.)
CVSListBox::PreTranslateMessage Translates window messages before they are dispatched to the TranslateMessage and DispatchMessage Windows functions. For more information and method syntax, see CWnd::PreTranslateMessage. (Overrides CVSListBoxBase::PreTranslateMessage.)
CVSListBox::RemoveItem Removes an item from an editable list control. (Overrides CVSListBoxBase::RemoveItem.)
CVSListBox::SelectItem Selects an editable list control string. (Overrides CVSListBoxBase::SelectItem.)
CVSListBox::SetItemData Associates an application-specific 32-bit value with an editable list control item. (Overrides CVSListBoxBase::SetItemData.)

Protected Methods

Name Description
CVSListBox::GetListHwnd Returns the handle to the current embedded list view control.

Remarks

The CVSListBox class provides a set of edit buttons that enable the user to create, modify, delete, or rearrange the items in a list control.

The following is a picture of the editable list control. The second list entry, which is titled "Item2", is selected for editing.

CVSListBox control

If you use the resource editor to add an editable list control, notice that the Toolbox pane of the editor does not provide a predefined editable list control. Instead, add a static control such as the Group Box control. The framework uses the static control as a placeholder to specify the size and position of the editable list control.

To use an editable list control in a dialog box template, declare a CVSListBox variable in your dialog box class. To support data exchange between the variable and the control, define a DDX_Control macro entry in the DoDataExchange method of the dialog box. By default, the editable list control is created without edit buttons. Use the inherited CVSListBoxBase::SetStandardButtons method to enable the edit buttons.

For more information, see the Samples directory, the New Controls sample, the Page3.cpp and Page3.h files.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CStatic

CVSListBoxBase

CVSListBox

Requirements

Header: afxvslistbox.h

CVSListBox::AddItem

Adds a string to a list control.

virtual int AddItem(
    const CString& strIext,  
    DWORD_PTR dwData=0,  
    int iIndex=-1);

Parameters

[in] strIext
A reference to a string.

[in] dwData
An application-specific 32-bit value that is associated with the string. The default value is 0.

[in] iIndex
The zero-based index of the position that will hold the string. If the iIndex parameter is -1, the string is added to the end of the list. The default value is -1.

Return Value

The zero-based index of the position of the string in the list control.

Remarks

Use the CVSListBox::GetItemData method to retrieve the value that is specified by the dwData parameter. This value can be an application-specific integer or a pointer to other data.

CVSListBox::CVSListBox

Constructs a CVSListBox object.

CVSListBox();

Return Value

Remarks

CVSListBox::EditItem

Starts an edit operation on the text of a list control item.

virtual BOOL EditItem(int iIndex);

Parameters

[in] iIndex
Zero-based index of a list control item.

Return Value

TRUE if the edit operation starts successfully; otherwise, FALSE.

Remarks

The user starts an edit operation either by double-clicking the label of an item, or by pressing the F2 or SPACEBAR key when an item has the focus.

CVSListBox::GetCount

Retrieves the number of strings in an editable list control.

virtual int GetCount() const;  

Return Value

The number of items in the list control.

Remarks

Note that the count is one greater than the index value of the last item because the index is zero-based.

CVSListBox::GetItemData

Retrieves an application-specific 32-bit value that is associated with an editable list control item.

virtual DWORD_PTR GetItemData(int iIndex) const;  

Parameters

[in] iIndex
The zero-based index of an editable list control item.

Return Value

The 32-bit value that is associated with the specified item.

Remarks

Use the CVSListBox::SetItemData or CVSListBox::AddItem method to associate the 32-bit value with the list control item. This value can be an application-specific integer or a pointer to other data.

CVSListBox::GetItemText

Retrieves the text of an editable list control item.

virtual CString GetItemText(int iIndex) const;  

Parameters

[in] iIndex
The zero-based index of an editable list control item.

Return Value

A CString object that contains the text of the specified item.

Remarks

CVSListBox::GetListHwnd

Returns the handle to the current embedded list view control.

virtual HWND GetListHwnd() const;  

Return Value

A handle to the embedded list view control.

Remarks

Use this method to retrieve a handle to the embedded list view control that supports the CVSListBox class.

CVSListBox::GetSelItem

Retrieves the zero-based index of the currently selected item in an editable list control.

virtual int GetSelItem() const;  

Return Value

If this method is successful, the zero-based index of the currently selected item; otherwise, -1.

Remarks

CVSListBox::RemoveItem

Removes an item from an editable list control.

virtual BOOL RemoveItem(int iIndex);

Parameters

[in] iIndex
The zero-based index of an editable list control item.

Return Value

TRUE if the specified item is removed; otherwise, FALSE.

Remarks

CVSListBox::SelectItem

Selects an editable list control string.

virtual BOOL SelectItem(int iItem);

Parameters

[in] iItem
The zero-based index of an editable list control item.

Return Value

TRUE if this method is successful; otherwise, FALSE.

Remarks

This method selects the specified item, and if it is required, scrolls the item into view.

CVSListBox::SetItemData

Associates an application-specific 32-bit value with an editable list control item.

virtual void SetItemData(
    int iIndex,  
    DWORD_PTR dwData);

Parameters

[in] iIndex
The zero-based index of an editable list control item.

[in] dwData
A 32-bit value. This value can be an application-specific integer or a pointer to other data.

Remarks

See Also

Hierarchy Chart
Classes