Noobie

Alessandro Lendaro <[email protected]> Fri, 08 Oct 2004 15:54:05 +0200
Newsgroups gmane.comp.lib.wxwindows.wxnet
Message-ID <[email protected]>
This code generates an error on Windows (Server 2003) - .NET 1.1 - 
wx.NET 0.5 - wxWindows 2.4.2
A popup opens saying:  "Couldn't retrieve information about list control 
item 46967228",
thanks to who'll give me an explanation.

	ListCtrl lstctrl;
	enum Cmd { Quit }

	public TestFrame()
		: base("Tester")
	{
		lstctrl = new ListCtrl(this, -1, new Point(15,125),
			new Size(560,300),
			ListCtrl.wxLC_REPORT);

		lstctrl.InsertColumn(0, "Column1", ListCtrl.wxLIST_FORMAT_CENTER, 100);
		lstctrl.InsertColumn(1, "Column2", ListCtrl.wxLIST_FORMAT_CENTER, 110);
		lstctrl.InsertColumn(2, "Column3", ListCtrl.wxLIST_FORMAT_CENTER, 250);

		ListItem lstItem = new ListItem();

		// Set the mask for which fields int the list item are valid
		lstItem.Mask    = ListCtrl.wxLIST_MASK_TEXT;
		lstItem.Id      = 0;
		lstItem.Text    = "Fred";
		lstctrl.InsertItem(lstItem);

		// Set the text for the columns
		lstItem.Column  = 1;
		lstItem.Text    = "Mr.";
		lstctrl.SetItem(lstItem);

		lstItem.Column  = 2;
		lstItem.Text    = "Fred Says Hi!";
		lstctrl.SetItem(lstItem);

		// Insert another item
		lstItem.Column  = 0;
		lstItem.Text    = "Sally";
		lstctrl.InsertItem(lstItem);

		lstItem.Column  = 1;
		lstItem.Text    = "Mrs.";
		lstctrl.SetItem(lstItem);

		lstItem.Column  = 2;
		lstItem.Text    = "Sally Says Hi!";
		lstctrl.SetItem(lstItem);

		lstctrl.EVT_LIST_ITEM_SELECTED(-1, new EventListener(this.OnSelectItem));
	}

	public void OnSelectItem(object sender, Event e)
	{
		ListItem info = new ListItem();
		info.Id = ((ListEvent)e).ID;
		info.Column = 1;
		info.Mask = ListCtrl.wxLIST_MASK_TEXT;
					
		lstctrl.GetItem(out info);
		
		Console.WriteLine(info.Text);
	}



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl