MFCリストボックスにintデータを挿入する方法
CListBox に int 型のデータを挿入するには、次のメソッドを使用します。
- AddString() 関数を使用すると、int 型データを文字列に変換した値を追加できます。例:
CListBox listBox;
int value = 10;
CString strValue;
strValue.Format("%d", value);
listBox.AddString(strValue);
- InsertString()関数は、指定した位置にint型データを文字列に変換した値を追加します。例えば、
CListBox listBox;
int value = 10;
CString strValue;
strValue.Format("%d", value);
int index = 0; // 插入位置
listBox.InsertString(index, strValue);
int型データをリストボックスに追加するときは、まず文字列型に変換する必要があります。