[Mono-bugs] [Bug 369048] New: List controls don' t select first item on binding list fill
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Mar 11 06:07:09 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=369048
Summary: List controls don't select first item on binding list
fill
Product: Mono: Class Libraries
Version: 1.9.0
Platform: Other
OS/Version: Other
Status: NEW
Severity: Minor
Priority: P5 - None
Component: Windows.Forms
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: andyhume32 at yahoo.co.uk
QAContact: mono-bugs at lists.ximian.com
Found By: ---
If the selected item updates due to binding list change (i.e. when the list was
previously empty) then neither ComboBox nor ListBox update to select the first
item.
This is seen in the repro app in bug 349655. Beforehand both empty; after see
no selection in either. MSFT selects the first item. Updated repro below has
a button to show current selection.
Minor as user can make the selection manually -- as in my case.
[[
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
class ListControlIBindingList
{
static void Main(string[] args)
{
bool nonEmptyWhenBound = false;
//
if (args.Length > 0)
nonEmptyWhenBound = true;
//
Foo(nonEmptyWhenBound);
}
static IBindingList m_ibl;
static void buttonDoFill_Click(object sender, EventArgs e)
{
// The bug occurs here, the list is empty and bound,
// now add an item to it. Crash. Occurs when empty list ->
item added.
m_ibl.Add(new Version(3, 1));
m_ibl.Add(new Version(3, 2));
m_ibl.Add(new Version(3, 3));
}
private static void Foo(bool nonEmptyWhenBound)
{
Form f = new Form();
f.Text = "ListControlIBindingList";
FlowLayoutPanel flp = new FlowLayoutPanel();
flp.Dock = DockStyle.Fill;
f.Controls.Add(flp);
//
m_ibl = new BindingList<Version>();
bool skipBug = false || nonEmptyWhenBound;
if (skipBug) {
m_ibl.Add(new Version(0, 99));// NON-EMPTY at bound Add
}
//
ComboBox cb = new ComboBox();
cb.DataSource = m_ibl;
flp.Controls.Add(cb);
//
Button b = new Button();
b.Text = "Do Fill";
b.Click += buttonDoFill_Click;
flp.Controls.Add(b);
//
ListBox lb = new ListBox();
lb.DataSource = m_ibl;
flp.Controls.Add(lb);
//--
Button stateButton = new Button();
stateButton.Text = "State!";
stateButton.Click += delegate {
MessageBox.Show("CB idx: " + cb.SelectedIndex
+ ", item: " + cb.SelectedItem + ", value: " +
cb.SelectedValue
+ Environment.NewLine
+ "LB idx: " + lb.SelectedIndex
+ ", item: " + lb.SelectedItem + ", value: " +
lb.SelectedValue);
};
flp.Controls.Add(stateButton);
//
Application.Run(f);
}
}//class
]]
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list