Adding multi-column items in List View

I've enabled the multi-columns in the List View in Details mode (Script Dialog Editor) but I can't figure out how to add multi-column items either via GUI (less important) or in code via dlg.Control and .AddItem.

I guess I could add items and then iterate over DialogListColumns to fill second column or something similar, but there's got to be a better way to do it in one-shot?

gui

Here's an example --- :grinning:

Script Code tab:

function OnClick(data)
{
	var msg;
	var dlg = DOpus.Dlg;
	dlg.window = DOpus.Listers(0);
	dlg.template = "dialog1";
	dlg.detach = true;
	dlg.Show();

	var lst = dlg.Control("listview1");
	var col = lst.columns;
	col.AddColumn("Item");
	col.AddColumn("Subitem 0");
	col.AddColumn("Subitem 1");
	col.AutoSize();

	do	// msg loop
	{
		msg = dlg.GetMsg();
		if (msg.event == "click" && msg.control == "button1")
		{
			var pos = lst.AddItem("Item " + lst.count);
			var lst_item = lst.GetItemAt(pos);
			lst_item.subitems(0) = "Subitem 0";
			lst_item.subitems(1) = "Subitem 1";
		}
	} while (msg == true);
}

Resources tab:

<resources>
	<resource name="dialog1" type="dialog">
		<dialog fontsize="8" height="169" lang="english" resize="yes" width="201">
			<control height="17" name="button1" resize="yw" title="Add Item" type="button" width="197" x="1" y="150" />
			<control height="147" name="listview1" resize="wh" type="listview" viewmode="details" width="197" x="1" y="1" />
		</dialog>
	</resource>
</resources>
2 Likes