Rotsey wrote:
The FileName property is spelled/cased correctly
You will notice that my ocde is in ProgressChnaged event
so the listox is to be filled incremently.
Using the DataSource property correctly uses the displaymenber/valuemember
properties.
So why doesn't AddRange work the same????
It does. There must be some other bug. See below.
When I load that form, I get a listbox with the words One, Two, Three,
and Four as the items in it. In .NET 2.0 it seems to work fine anyways.
Chris.
using System;
using System.Collecti ons.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
namespace ProofOfConcept
{
public class Form1 : Form
{
protected class InnerTestObject
{
private string someValue;
public InnerTestObject () : this("") { }
public InnerTestObject (string val)
{
this.someValue = val;
}
public string Jabberwocky
{
get { return this.someValue; }
set { this.someValue = value; }
}
}
public Form1()
{
InitializeCompo nent();
}
private void Form1_Load(obje ct sender, EventArgs e)
{
listBox1.Items. AddRange(new InnerTestObject[] {
new InnerTestObject ("One"),
new InnerTestObject ("Two"),
new InnerTestObject ("Three"),
new InnerTestObject ("Four")});
listBox1.Displa yMember = "Jabberwock y";
}
private ListBox listBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.IContain er components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing ">true if managed resources should be
disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Disp ose();
}
base.Dispose(di sposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.listBox1 = new System.Windows. Forms.ListBox() ;
this.SuspendLay out();
//
// listBox1
//
this.listBox1.F ormattingEnable d = true;
this.listBox1.L ocation = new System.Drawing. Point(12, 12);
this.listBox1.N ame = "listBox1";
this.listBox1.S ize = new System.Drawing. Size(120, 95);
this.listBox1.T abIndex = 0;
//
// Form1
//
this.AutoScaleD imensions = new System.Drawing. SizeF(6F, 13F);
this.AutoScaleM ode = System.Windows. Forms.AutoScale Mode.Font;
this.ClientSize = new System.Drawing. Size(251, 238);
this.Controls.A dd(this.listBox 1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHan dler(this.Form1 _Load);
this.ResumeLayo ut(false);
}
#endregion
}
}