views:

142

answers:

3

I'm relatively new to .NET GUI programming using WinForms (the project I'm working on is targetting .NET 2.0 for deployment reasons), and I'm trying to bind a ListBox in a Form to a string[] property that is defined in the form:

namespace AVPriorityUI
{
    public partial class AVPriorityUI : Form
    {
        public AVPriorityUI()
        {
            InitializeComponent();
        }

        public string[] ProcessNames
        {
            get { ... }
            set { ... }
        }
    }
}

No matter what I do, I can't get Visual Studio 2008 to offer up the ProcessNames property as a valid source to bind to. What do I need to do differently to make this work?

[EDIT] I've been trying to use the GUI to establish the binding.

A: 

You should be able to set the list box's DataSource to the ProcessNames property in the code itself. If you are trying to use the UI to set the DataSources/Bindings that may be the culprit.

ie:

mylistBox.DataSource = this.ProcessNames;
Pat
That was it... I've never seen a UI that works for the complex case but fails utterly at the trivial... :(
Brian Bassett
A: 

http://msdn.microsoft.com/en-us/library/aa288424(VS.71).aspx

listbox.Items.AddRange(this.ProcessNames);

klabranche
scratch my solution... old c# syntax.... no longer valid in 2.0 and higher it seems....
klabranche
A: 

this works for me in a simple test just now:

string[] alist = { "a", "b", "c", "d", "e", "f", "g", "h" };
listBox1.DataSource = alist;
John Boker