Combobox and DataSource

B

Bruce D

I'm thinking this shouldn't be hard...but I can't seem to grasp what I need
to do here. I have a datagrid on my form (datasource=dtUsers). This
datagrid displays three fields username, password, level. In the database I
have the level as a 1 character field (1,2,3...). The data displays
properly in the datagrid.
I have a textbox below the datagrid. I have put this code in the load event
of the form:
Me.txtUsername.DataBindings.Add("Text", dtUsers, "username")
The textbox works as it should...as I click on different users in the grid
the username changes in the textbox.

So, here's my question.
I want to create a combobox that will display the level...but I want to use
1=User, 2=Admin, etc.
I'm trying to figure out how to do this. I created a DT to match up the
values, but I'm not sure how to bind them and so on...

Can anyone help point me in the right direction?

-bruce duncan
 
C

Cor Ligthert

Bruce,

There is on difference with the dataset you have as well to tell what is the
displaymember and what is the valuemember.

cmb.displaymemer = "mycolumn1"
cmb.valuemember = "mycolumn2"

I hope this helps,

Cor
 
B

Bruce D

Cor,
Maybe I didn't explain my question very well...or I don't understand your
answer. Here's my DT:
dtUsers with fields username,password,level
examples:
bob,xx,1
jane,qa,2
This is what I want to display in the datagrid...yea...that's simple.
The hard part....I want the combobox (located just below the datagrid) to
display "administrator" when I'm on the record for "bob" and I want it to
display "user" when I'm on the record for "jane".
I was thinking I need to create another datatable with two fields
(val,display) and it would look something like:
1,"administrator"
2,"user"
etc
I can create this datatable and display it...but when I change the cell on
the datagrid I want the value to change in the combobox..

Any more insight?

-bruce
 

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