[Mono-bugs] [Bug 371672] New: ComboBox: SelectedIndex and SelectedItem must be cleared when typed-in value

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Mar 17 05:03:49 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=371672


           Summary: ComboBox: SelectedIndex and SelectedItem must be cleared
                    when typed-in value
           Product: Mono: Class Libraries
           Version: 1.2.6
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          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: ---


Created an attachment (id=202486)
 --> (https://bugzilla.novell.com/attachment.cgi?id=202486)
Repro code

As a "combo" one can either select from the menu or type in a value.  On Mono,
if one selects an item from the menu and later types in a new value then the
SelectedItem and SelectedIndex property still return/reference the previously
selected item, they should be cleared then.

This behaviour would confuse code of the following form:
[[
int GetSelectedPortNumber ()
{
// Has the user selected a given item?
PortAndName item = (PortAndName)comboBox1.SelectedItem;
if (item != null)
  return item.Number;
// Or has the user entered a number directly?
int num;
if (Int32.TryParse(comboBox1.Text, out num))
  return num;
return -1;
}

public Form1()
{
  ...
  comboBox1.Items.AddRange(new object[] {
    new PortAndName(80, "HTTP"),
    new PortAndName(25, "SMTP"),
    new PortAndName(23, "Telnet") });
}
]]

See the attached repro app.
1. Select item "RButton" from the combobox  drop-down.
See SelectedIndex, and SelectedItem set respectively.
2. Type in a letter 'x' to make "xRButton".  Hit <Get State>.
Expect Index=-1 and Item=null.  On Mono the previous values remain.  This is
the fault reported here.
3. Change the text to LButton by typing -- don't open the drop-down.  Hit <Get
State>.
Expect -1/null.
4. Open the drop-down -- the LButton item is automatically selected.  Hit <Get
State>.
Now see SelectedIndex, and SelectedItem set respectively.
Mono doesn't select the item automatically, so just manually select a new item
instead.

(The Text property is correctly set to the current visible string at each
stage, and the SelectedText property is set when the combobox has focus and
some text in the field is selected (highlighted)).


-- 
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