Databinding ComboBox Slow

G

Guest

I have a DataSet with 4 tables and also it has relation for each table like
this:

Table1
- Table2
- Table3
-Table4

Each of this table is bounded to a ComboBox, when i select an item from the
first combo, the rest of the combos are filtered.

I click the menu option and My problem is that the form take more than 5
seconds to load, i don't my users will like that.

If i remove the DataSource from the Combo, the form is show in less than 2
seconds, i could live with that.

I Also realize that if i only bind to the first 2 comboboxes, the speed is
not affected, but when i bind the 3 combobox the form slow down.

What can i do to avoid this?

Why DataBinding in .NET is so slow, always when i show a form with
databinding takes more than a second to be show, in real applications this
doesn't have on normal forms.

If I unbind my controls my form is shown inmediately.

Didn't the Microsoft Developers test this?

I feel like .NET has slow down things talking about UI.

If i make a control to change its appereance like a flat textbox with a
border color, it is grayed when the form is loaded and the is drawn, this
things doesn't look good.


'This code is in the form_load event

Combo1.DataSource = DataSet
Combo1.DisplayMember = "tblPaises.Pais"
Combo1.ValueMember = "tblPaises.Pais"

Combo1.DataSource = DataSet
Combo1.DisplayMember = "tblPaises.Relation1.Departamento"
Combo1.ValueMember = "tblPaises.Relation1.Departamento"

'From this point on, the relation becomes slow when i set the display member.
Combo1.DataSource = DataSet
Combo1.DisplayMember = "tblPaises.Relation1.Relation2.Ciudad"
Combo1.ValueMember = "tblPaises.Relation1.Relation2.Ciudad"

Combo1.DataSource = DataSet
Combo1.DisplayMember = "tblPaises.Relation1.Relation2.Relation3.Ciudad"
Combo1.ValueMember = "tblPaises.Relation1.Relation2.Relation3.Ciudad"

The filtering is managed automatically by the DataRelations, i don't do
anything.

if i select an item in combo1, it automatically filter the values in the
other combos.
 
S

Sahil Malik [MVP]

Databinding is slow because it uses reflection.

Try databinding with a much smaller subset of the data - i.e. using a
DataView, instead of a Datatable.

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
 
G

Guest

Thanks for the answer!

That's what i did yesterday, looking for a solution:

I add dataviews as a DataSource
without a filter, the user can skip to other records and the values of the
combos are updated.

When the user edit the controls i apply the filter to the DataViews to show
only related records and also addhandler to the selectedindex event of every
combo.

When the user finish editing and changes to ReadOnly or ViewOnly, i remove
the filter from the DataViews and remove the handlers.

Then problem i have this records in two tables (Table1 - ParentTable, Table2
- ChildTable)

Value1 (Table 1)
Field1 Field2
- Value A Description 1 (Table 2)
- Value B Description 2 (Table 2)
Value 2 (Table 1)
Field1 Field2
- Value A Description 3 (Table 2)
- Value B Description 4 (Table 2)

I have a combo bound to (Table 2) field1 and its actual value is (Value A)
its parent records is Value2, how you can see (Value A) also exist for Value1
record in (Table 1)

Since i am not filtering whe the user is viewing the information is showing
Description 1 instead of Description 3 because it is the first it found in
the view.

I remove the handlers of the combos because when the user selects a value i
clear the rest of the combo in order to select the values.

How can i manage that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top