Reputation: 651
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.
Upvotes: 1
Views: 3882
Reputation: 83699
this works for me in a simple test just now:
string[] alist = { "a", "b", "c", "d", "e", "f", "g", "h" };
listBox1.DataSource = alist;
Upvotes: 0
Reputation: 21078
http://msdn.microsoft.com/en-us/library/aa288424(VS.71).aspx
listbox.Items.AddRange(this.ProcessNames);
Upvotes: 0
Reputation: 5282
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;
Upvotes: 1