WPF DataGrid Lookup Column Value - wpf

I have a DataGrid bound to a table in DataSet A. I'm manually creating the grid columns.
Two of the columns comprise the key into a table in DataSet B and I need to display the (read-only) lookup Name instead of the IDs.
I'm guessing I use a Value Converter of some sort but don't know how to get started.
I saw this: Lookup-id-control in WPF DataGrid but 1) I need to specify the combobox's ItemSource in the code and can't figure out how to do so 2) I've got a tuple key 3) it seems there should a more straightforward way to accomplish this.
Thanks!
Dan

It hurts that the tables are in different DataSets. Can you possibly clone the referenced table into DataSet A?
If they were in the same DataSet, then it would be simple:
Create a DataRelation between the child table (the one with the foreign key columns) and the parent table (the one containing the lookup name).
Create a DataColumn in the child table and set its Expression to Parent!Name.
Add the new DataColumn to your DataGrid.

As I said in my comment, I'm falling back on Plan A which is more model/view friendly.
I think I'm just going about it 'wrong' otherwise.

Related

Problem with Showing Query Results on a Form

I'm having a Projects lists Continuous form where the form's Record Source is based upon a table.
I have a requirement to display a field from another table which is linked back to original table using its primary key. The primary key is a AutoNumber field, but when displaying in the form I've used Input mask something like this "TMG/FEA/"0000.
So I made:
a unbound list box
and made the Row source as the query which displays the relevant information from second table
This query was created using primary key displayed in form (I mean the [Forms]![Form Name].[Field] ) as the where clause.
But the results returns blank. I'm Stuck here. I'm not sure if the query is not working due to the Input Mask or because of something else. Please help me. Thanks in advance
You should add to form field listbox, and set following values:
Data: primary key of your first table
After this, that field will duplicate ID value. Now you should transform RecordSource of this field in order to see contents from second table. So you should set:
SELECT [PrimaryForeignKeyID], [DetailedField] FROM tblSecond;. Actually I don't know the contents of your second table. Whereas PrimaryForeignKeyID is a field that links second table to first, so-called FK.
After this set following properties of list box:
ColumnCount = 2
ColumnWidth = 0;2
AllowEdits = False
Save form and open it for viewing.
In this case, your listbox will show the associated contents of second table on form.
So to my mind it is better for you to do such simple tables and forms, and you'll realize idea.

Bind tablix with a single row of out of many rows returned by dataset in SSRS 2008?

I am fully aware that ideally, dataset should return only relevant rows with which to bind tablix.
However, in this particular case, I am utilizing same dataset to bind multiple tables and need to perform some filtering 'on the fly'.
I tried writing logic in column visibility of each cell to achieve desired output but there is no unique condition available on cell level .
I need to bind only single row from the dataset based on my unique column value, any pointers will be highly appreciated, thanks !
Although you haven't provided any code/data samples but may be you can utilize row visibility property to filter rows from dataset with which to bind individual tables as suggested here

Access 2007 - Query displays Combobox Primary ID rather than Value

I am writing a query based on a Table which is populated via a Form with several combo boxes. The information is stored in the Table as the Primary Key of the Combobox value which I understand to be correct. However, when I run a query or report based on the Table, I would like to display the Combo box Value rather than the Primary Key ID. Is there a way to do this other than using a Lookup to the combobox in the Table?
Thanks in advance for your help.
JB
It depends on how you have your combo boxes set up. Are they populated from a list in the field or from another table?
If from a list you entered in the table field where the value is stored, you should just store the value.
If they are from a separate table, then set the relationship from the combo lookup table's primary key/ID to a field in the main table that stores the combo selection which should be a number type. In a query, add both your main table and the other table where values for the combo are stored and add the value to your results from the combo value table along with the data from your main table.
It's a little confusing to say you want to query a combobox value, essentially you need to look at the SQL source of the combobox first in order to see where it draws it's values from. You then need to link this back to your query that you are running, as long as there is a common PK/FK between these then you can just perform an INNER JOIN on that.

How can one dynamically modify row and column definitions of a WPF grid?

I have two dimensional data with varying number of rows and columns and must display it to the user for editing. The format of the data itself is essentially described by a list of row and column descriptors with a header text for each row or column.
I derived a control from Grid that has two properties for the row and column descriptors and builds the gird rows and columns based on that information. It also subscribes list change events of the two descriptor collection to update itself if the user dynamically adds or removes rows or columns.
And here the problem occurs - when I try to modify the row or column definitions of the gird I get an exception telling that the collection is read-only. So I assume it is not possible to modify the definition after the grid has been created and shown once. Any ideas?
And just in the case it matters - everything is data bound. There is a (dynamic) collection of tables with each table containing its own (dynamic) row and column definitions and the data entered for each cell.
I did a quick test and I could add rows and columns without problems to a Grid at runtime through code, using the RowDefinitions and ColumnDefinitions collections. I don't think that bindings have something to do with the problem either.
If on the other hand you meant DataGrid, yes, that changes things quite a bit.

Displaying a multi-valued column using a tabular UI

I'm hoping to display a multi-valued column in a tabular UI format. By multi-valued column, I mean a column in which a single cell can simultaneously have multiple values -- aka a list of values. These values might be drawn from a short list of possibilities (e.g. an enumeration) or from a long list (e.g. another table). Imagine a table of contacts with a "friends" column that can refer to zero or more other contacts.
I need the ability to add new values, remove values, and ideally the values would be listed horizontally and word wrapped. I have a feeling that no out-of-the-box datagrid control on the planet can do this, but I figured this is the right forum to ask such a question.
I'm guessing that the current state of the art is to display the information in a form, not in a table (e.g. "details" of a row). However, we would like to actually display the values in a column of the table in a horizontally wrapped, in-line editable fashion. At this time, we are planning to use WPF, so I'm hoping for a WPF solution.
WPF is definitely the right tool for this job. I don't think you'll find it very difficult to get the layout you want once you understand a few core WPF concepts (mostly binding and DataTemplates). I would suggest maybe a ListView/GridView with a GridViewColumn with a custom CellTemplate containing an ItemsControl with its own DataTemplate...Simple, really ;-)

Resources