473,385 Members | 1,798 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,385 software developers and data experts.

binding to Combo

Rod

I have an Access database with the 3 fields in
[ID], [Last Name], [First Name]

I create a dataset and bind a form to it, no problem.

I now want to put in a combo box to search on name.
Now I can do this fine if I just use [Last Name]

But I want [Last Name] & ", " & [First Name] to appear in the combo box.

I can't see a way of getting this directly from the dataset.

I can see a way of getting it by going back to Access. But I really want to
avoid this.

any clues much appreciated.

rod

PS posted earlier to dotnet.framework.windowsforms.databinding
Jul 21 '05 #1
4 1286
Rod,

You could build an array of strings to hold the names, fill it in from the
dataset, and bind the combo box to the array, but then you're not bound to
the dataset any more, and I'm guessing you want to be bound to the dataset.

You could use a listbox instead of a combo box, if you never want the user
to enter a name that's not in the list. Listboxes can have multiple
columns.

But unless there's some strong reason not to, I'd recommend writing a query
in Access that gets you the string in the form you want it, and building
your dataset from that query.

Good luck!

Rob, providing advice that is probably not worth much more than you paid for
it.
Jul 21 '05 #2
Rod


You could use a listbox instead of a combo box, if you never want the user
to enter a name that's not in the list. Listboxes can have multiple
columns.

But unless there's some strong reason not to, I'd recommend writing a query in Access that gets you the string in the form you want it, and building
your dataset from that query.

If I add a new record I want it to appear in the combo box. OK, I can build
some logic to make it happen but I was hoping that I could make it happen
automatically. Naively I had though you could create a dataview using sql
acting on a table in the dataset.
Your list box is a good idea, I will explore that.

many thanks

Rod
Jul 21 '05 #3
Rod,

A very simple method is adding an extra column to the datatable and fill
that using an expression.

http://msdn.microsoft.com/library/de...ctortopic4.asp

That column is your displaymember.

I hope this helps?

Cor
Jul 21 '05 #4
Rod
Why did i not think of that?

Thanks

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Rod,

A very simple method is adding an extra column to the datatable and fill
that using an expression.

http://msdn.microsoft.com/library/de...ctortopic4.asp
That column is your displaymember.

I hope this helps?

Cor

Jul 21 '05 #5

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

Similar topics

3
by: Shravan | last post by:
Hi, How can I bind DataRow array to ComboBox. I tried setting DataSource -> DataRow Array DisplayMember -> ColumnName But it was showing "System.Data.DataRow" for every item in the...
2
by: SoftWhiteDelgiht | last post by:
Help me. I am obviously stupid! :-) I am just starting out with VB.Net and am trying to do a simple master/detail form with a SqlServer backend. I have created a combo box which is to populate with...
0
by: Larry Serflaten | last post by:
I am not sure how many are aware of this sort of data binding, but as it is new to many (classic) VB developers I thought I would post this once just to let people know of its availablility. ...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
4
by: Jim Shaffer | last post by:
Perhaps I have the wrong construct, or misunderstand arrays in vb (2003).... I've loaded a two-dimensional array (168 by 28) into memory as AcctArray. {Dim AcctArray (500,28) as string...} The...
7
by: Nathan | last post by:
I'd like to use an enumeration as a datasource for a drop-down box. Is there a way to do this?
0
by: Roger Odermatt | last post by:
Hello I have binding a class to a DataGridView and this class have a property from another class and this i want binding to a DataGridViewComboBoxColumn. So when i change a item in the Combo and...
1
by: Monty M. | last post by:
Does anyone know how to perform two way data binding between a combo box and a listview. The listview is bound to a dataset table in code: Binding Bind = new Binding(); DataTable dt;...
3
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When...
0
by: Dawnyy | last post by:
I have a form which is bound to a dataset. I am filling the forms dataset on Form_Load event. On my form I have combo boxes which I am setting by running a stored procedure to return a datatable,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.