can I display text from a related table in a datagrid?

PatM

Well-known member
Joined
Dec 5, 2012
Messages
52
Programming Experience
10+
I've been looking all morning but I have no background with Datagrids so I'm probably looking for the wrong things anyway.

I have a table that has a number to show the user's level. I have a related table that contains the text that I want to display rather than the number so basically

user row = id,name,roleid with roleid as an integer
roles row = role,name

So I'd like the datagrid column to display roles.name instead of user.roleid
Easy if I do a select and left join but then I can't use Adapter.update because of multiple tables being involved
 
I've kept searching and I have an inkling of what I can do. I know I can assign a database column to a cell and I know I can assign a list to a combobox. I'm thinking load the datatable into a list then assign that to a combobox. That way I get the text displayed and a Selected value to set or read too.
 
While laying in bed last night almost asleep I had a thought. I am looking for complexity where it doesn't really exist. There is a datagridcombobox column type that I was looking at but I couldn't find examples of how to fill each one so I was totally confused, Fact is, it is a combobox the same as any other combobox. The only difference being that it copies itself for each row in the datagrid. I just need to set its Itemssource , displaymenberpath, and selectedvalue that just like any single combo.
I thought this morning some more and had another crazy idea too, I've been searching for ways to use several different controls like wrappanels and things and even made one work after mangling someone's rather pretty example but still didn't understand binding and all that. Now I am thinking just the control a name and set its itemssource and that is probably pretty close to everything I need.
 
I was right in the end. Had a bit of trouble when I set the combocolumn's binding to SelectedItemBinding instead of SelectedValueBinding but once I spotted that it works perfect. I wonder how many other mysteries about vstudio and that easily solved. Guess I will find out!
 
Back
Top