Hi Brian,
Based on my understanding, you'd like a better way to display multiline
data with conventional control such as TextBox and ComboBox. If I am off
base, please feel free to let me know.
The behavior of displaying multiline data within a control is called
complex data binding. TextBox can only be used for simple data binding,
i.e. bind a property of a TextBox control, usually its Text property to a
field of the data source.
As for ComboBox, although it supports complex data binding, the common
usage is to set the DataSource property of the ComboBox to a lookup data
source(set the DisplayMember and ValueMember properties in the meanwhile)
and then bind its SelectedValue property to a field of another data source.
I'm sorry to say that I don't think it's a good idea to display multiline
data with TextBox and ComboBox. As for your workaround, I think there's a
problem in it. Suppose that there're 1000 rows in the data source, then we
should create 1000 sets of controls 1000 myIList<> objects and 1000
BindingSource objects to display all the data, shouldn't we?
DataGridView is very good for complex data binding, and is easy to extend.
Could you tell me why you don't like to use DataGridView?
Alternatively, ListBox is a good candidate for complex data binding . Set
the DataSource property of the ListBox to the data source and then set its
ValueMember and DisplayMember properties properly.
Hope this helps.
If you have any concerns, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Brian Pelton - 23 Jan 2007 16:16 GMT
> Based on my understanding, you'd like a better way to display multiline
> data with conventional control such as TextBox and ComboBox. If I am off
> base, please feel free to let me know.
Sort of...
> I'm sorry to say that I don't think it's a good idea to display multiline
> data with TextBox and ComboBox. As for your workaround, I think there's a
> problem in it. Suppose that there're 1000 rows in the data source, then we
> should create 1000 sets of controls 1000 myIList<> objects and 1000
> BindingSource objects to display all the data, shouldn't we?
There will only be one IList<> object for the form. The IList<> will
contain say 1000 objects. But I wouldn't create 1000 BindingSource objects.
I would still create 3 (or some other fixed number) of sets of controls,
and 3 BindingSource objects. If the IList<> has more than 3 objects,
then the user would need to scroll through the IList<> using a scroll
bar or arrow buttons. The scroll bar could trigger the BindingSource's
MoveNext() or MovePrevious() methods.
> DataGridView is very good for complex data binding, and is easy to extend.
> Could you tell me why you don't like to use DataGridView?
I use the DataGridView for "quick" data binding. But I am building data
input forms for things like orders and invoices. I want the look and
feel of text boxes and combo boxes for my detail lines. I don't like
the appearance of the Grid. I want to provide a logical layout for my
controls rather than the strict excel columns and rows of the DataGrid.
Linda Liu [MSFT] - 25 Jan 2007 11:08 GMT
Hi Brian,
Thank you for your prompt response. I understand what you really want now.
I think your solution works but there may be two problems in it.
One problem is that you have to create 3 or some other fixed number sets of
controls on your form, and I don't think it necessary.
Generally speaking, if we need to use the same set of controls in our
project for several times, we create a UserControl for the set of controls
and then use the UserControl everywhere we'd like.
The other problem is that it may be not easy to maintain the correct
position for each BindingSource object.
I suggest that you create only 1 BindingSource object. You may pass the
current object in the BindingSource object to one UserControl instance on
the form and call the MoveNext method and then pass the current object to
the next UserControl instance. You could add a public property in the
UserControl to accept the current object in the data source. After the
public property is set, you may display the values of the passed object in
the UserControl immediately.
Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
Brian Pelton - 25 Jan 2007 16:39 GMT
> Generally speaking, if we need to use the same set of controls in our
> project for several times, we create a UserControl for the set of controls
> and then use the UserControl everywhere we'd like.
That's a good idea. It would make it easier to modify the form later if
I need to go from 3 to 5 sets.
> The other problem is that it may be not easy to maintain the correct
> position for each BindingSource object.
Yes, I was thinking that too. I would almost need some kind of
BindingSource manager to keep all of the BindingSource objects in sync.
> I suggest that you create only 1 BindingSource object. You may pass the
> current object in the BindingSource object to one UserControl instance on
[quoted text clipped - 3 lines]
> public property is set, you may display the values of the passed object in
> the UserControl immediately.
Thanks for the ideas. I think I see how to do this now.