Skip to content

Combobox bug when using dataview #2

Description

@pamar1908

I have submitted the following bug report and fix at MaterialSkin2DotNet (DigitalAdeel/MaterialSkin2DotNet#15) but I am using MaterialSkin2Framework so I would be grateful if we can commit this change to Nuget.

When Combobox.datasource is set to a dataview, when combobox's draw opens it shows the wrong display text if the dataview is filtered. The error occurs because the display text is taken from the datatable and not the dataview, i.e. the index of the dataview is not the same as the index of the datatatable.

The following change needs to be implemented in
private void CustomDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
of the Combobox (line 324):

Remove: var table = ((DataRow)Items[e.Index].GetType().GetProperty("Row").GetValue(Items[e.Index])).Table;
Remove: Text = table.Rows[e.Index][DisplayMember].ToString();
Add: Text = ((DataRowView)Items[e.Index])[DisplayMember].ToString();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions