ComboBox woes



I need help solving a couple of problems (and learning a couple of concepts)
involving ComboBox columns in my DataGrid.

The first problem involves my custom ComboBoxColumn class. I don't have
experience making custom classes so I downloaded some code. From what I've
read, it's pretty standard for adding a ComboBox column. It overrides the
Edit, SetColumnValueAtRow, and GetColumnValueAtRow subroutines.

It works great, but it doesn't allow the user to type in custom items in the
combobox. Anything you type in just gets ignored. I want users to be able to
add new items to the database through the comboboxes. I don't understand all
of this code, though, so I'm not sure how to do this. The comboboxes are
bound to datatables, so when the changes are committed I just need to add a
new row with the new text to the datatable. Then when my "Update Database"
button is clicked, the table changes will get sent to the database. It looks
like maybe SetColumnValueatRow is the key subroutine?

The second problem involves the relationship between my query form and my
display form. My query form is a series of ListBoxes bound to certain
DataTables in my DataSet. But before I fill the tables from the database, I
add an item called "All" to the tables so that I can select all items in the
listbox for query purposes. The problem is that the comboboxes in my datagrid
are bound to the same tables, so I have to remove the "All" item before
displaying the datagrid or else "All" will be displayed as a selectable item
in the combobox. This works fine if you use the query form once, but if the
user clicks the "Back" button on the display form I have to put the "All"
item back into the tables for use in the query form. But inserting an item in
a datatable that is already filled doesn't seem to be as trivial as adding a
row to a blank table. Obviously I want "All" to be the first item in the
list, so I can't just tack it on to the end. Right now I have to clear the
tables and refill them, which is taking about 15 seconds. I guess one
solution is to just make copies of the tables and put "All" at the first
index in one of them and bind each listbox and combobox to different tables,
but it seems there should be a more elegant solution. Is there a syntax for
inserting a custom item in a datatable at index 0?


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