Question Databinding to a specific cell

keb1965

Well-known member
Joined
Feb 9, 2009
Messages
103
Programming Experience
10+
I may have painted myself in a corner and I am hoping to code my way out of it, either that or perhaps some kind soul will tell me the proper way to handle this problem.

Background:
I have a front end (in vb.net) that is designed to read various bits of data and display it for editing, viewing etc.
For ease of management I created a user control with several other controls, one of which is a listview (I can make it a DataGridView if it will help). On each control, I can bind data so that when I move through my data, each of the several user controls is updated accordingly. However, the listview will have a varying number of items in a single column. For example "Customer" will have a list of "purchases" that need to be displayed in the listview. Since the number of purchases will vary, I need to list them in a table, rather than have a hundred different fields (and fields that I don't even know about yet I might add), but I still need the "purchases" field to correspond to a specific row item in the "customer" table.

Maybe I just don't know how to ask the question .. but it seems a bit complicated to me.
 
I don't have authorization to disclose any portion of the project, except perhaps an empty database, which I don't think would provide much to go on.
 
Understandable but could you make an working example of it with different names & dummy data. It would be more helpful if we could look at your coding and your table structure and point to something specifically to say change this to that.
 
I certainly am willing to look at other solutions, regardless of what they are, but unfortunately the requirement of a vertical display is something I have no control over.
Why do you have no control over it?

As I see it you want any number of questionnaires to have any number of questions and any number of any kind of answers and you want to be able to represent multiple questions and answers from different questionnaires in one grid whereby the column header poses the question and the row value answers it. It does have the small advantage that you can use a DataGridViewComboBoxColumn to show relevant answers (constraint) without building anything custom but it's a counterintuitive way to lay out a UI, and you need to point that out to the person who forced it to be that way. Columns are fixed and rows vary, your questions vary so they should be rows, not columns

So, if you would please let me know what information you require I'd be more than willing to provide it, particularly if it will allow me to come to a successful completion of this project.

I don't recall seeing a mock-up of what you want to see; I only saw some confusing screenshots of what you don't want to see and a description of how you envisaged they should be changed
 
You are saying the same thing I am ... the questions are in one column .. in the datagrid view, the answers are in the adjacent column, but, remember the columns of questions and answers cannot be stored as columns in the database because access cannot update joined tables effectively. If this were SQL we were talking about it would be no problem to use inner and outer joins to manipulate the data across multiple tables where the questions and answers were stored one-to-many.

No worrys though, I managed a simple solution today. ;) If I had only considered the possibility first, this wouldn't have been an issue.

The solution I used is to dynamically create a textbox for each question in that particular category. Since the questions will be limited to less than 25 in any particular category, this is a simple proposition. The next step is to bind the column from the database to the corresponding textbox.

Each question has its answer in a column named "CONTROL_NAME_{X}" where "CONTROL_NAME" is the contextual name for the group of questions (i.e. "Home Life"), and {X} is the question number.

Since each group of question are displayed on a different control (with a different parent control) I can name the dynamic textboxes whatever I want, and simply add an index suffix to identify that particular question.
i.e. question 1 would be bound to "BindText1".

In the "TextChanged" event for the textbox, I update the corresponding cell in the DataGridView. Also, in the CellValueChanged event, I update the "BindText" textbox. To keep from having an infinite loop, I check the values to make sure they are different before updating.

The result is a simulated binding to a datagridview cell.

I appreciate your time trying to help me resolve this.
 
Back
Top