473,325 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Data manipulation before binding

I'm using data binding to display the values of a dataset in a form.
Normally I associate the Text property of the UI element to a field of
the dataset.

For a specific field, I need to do the following:

I fill a combobox with custom objects that basically have two
properties (value which is stored in the dataset and description which
is retrieved from the value using a custom algorithm)

1. the dataset field is a string (the value)
2. In the combobox, I need to select an item based on the value of the
dataset (after having appropriately converted from string to int).

How can I do that? Should I use a TypeConverter? How?

Thanks.
Andrea
Jan 5 '08 #1
5 1524
Andrea,

Are these values properties of the same object/datatable? If so, just
set the DisplayMember and ValueMember to the appropriate properties and you
should be able to access the currently selected value through the
SelectedValue property.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<na***@community.nospamwrote in message
news:7q********************************@4ax.com...
I'm using data binding to display the values of a dataset in a form.
Normally I associate the Text property of the UI element to a field of
the dataset.

For a specific field, I need to do the following:

I fill a combobox with custom objects that basically have two
properties (value which is stored in the dataset and description which
is retrieved from the value using a custom algorithm)

1. the dataset field is a string (the value)
2. In the combobox, I need to select an item based on the value of the
dataset (after having appropriately converted from string to int).

How can I do that? Should I use a TypeConverter? How?

Thanks.
Andrea
Jan 6 '08 #2
Thanks for your reply Nicholas.
Actually, the combobox doesn't have to show a list of values gathered
from the database.

I need to show a list of installed browsers and I fill the combobox
with the description of the browsers I get looking into the registry.

In my DB, in each record, I have saved the name of the executable, for
example iexplore.exe or firefox.exe.

I retrieve the name of the browser executable and from that I need to
select the appropriate element in the combobox.
The combobox contains a custom object, with two properties, the name
and the description of the browser.

I don't know if I can bind the data directly or it would be easier to
create a column in the DB containing, for example, the index of the
element to be selected in the combobox according to the value. The
only problem with this would be synchronizing the data.

Thanks.
Andrea

On Sat, 5 Jan 2008 20:55:24 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.comwrote:
>Andrea,

Are these values properties of the same object/datatable? If so, just
set the DisplayMember and ValueMember to the appropriate properties and you
should be able to access the currently selected value through the
SelectedValue property.
Jan 6 '08 #3
Hi Andrea,
I need to show a list of installed browsers and I fill the combobox with
the description
of the browsers I get looking into the registry.
Based on my understanding, you have a list of objects containing the name
and description of the installed browsers and you fill a ComboBox with this
list.
In my DB, in each record, I have saved the name of the executable, for
example
iexplore.exe or firefox.exe.
Based on my undertanding, you have a DataTable with one field containing
the name of the installed browsers and you'd like to bind the ComboBox to
this DataTable.

If I'm off base, please feel free to let me know.

I suggest that you bind the ComboBox to the above list by setting the
DataSource property of the ComboBox to the list and the DisplayMember
property to the description property and the ValueMember property to the
name property.

Then you bind the SelectedValue property of the ComboBox to the field
containing the name of the installed browsers within the DataTable.

If you have any question, 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/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 7 '08 #4
Hi Andrea,

How about the problem now?

If you have any question, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Jan 9 '08 #5
Thanks for the reply Linda.
I managed to fix the problem binding the value to a textbox and
handling the textchanged event to correctly select the item in the
combobox.

On Wed, 09 Jan 2008 03:58:47 GMT, v-****@online.microsoft.com (Linda
Liu[MSFT]) wrote:
>Hi Andrea,

How about the problem now?

If you have any question, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support
Jan 16 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
3
by: rufus | last post by:
Up until now I have been using OR Mapping tools for my database access. I liked this approach because with one line of code I could bind my form fields to my objects and then persist them. The...
2
by: | last post by:
I've defined an ObjectDataSource against a dataset, and I can bind the ObjectDataSource's members to data controls. I'm wondering how to take the values in an ObjectDataSource and...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
2
by: Mike Cain | last post by:
Hi, The Repeater control seems like exactly what I want to output rows of data from my database. However I need to do some manipulation to the data prior to it being output and I'm not...
3
by: alan.chambers | last post by:
I am new to C++/CLI. I want to do a very simple thing. In other C++ applications, my forms have always been 'context free' in the sense that I pass them a temporary copy of the data for them to...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
8
by: tkjensen | last post by:
How to make a own dataview in c#? Can someone please help me? I want to get id and users and everything else from database to be showed in the same place at the same time just as DataView. Please...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.