datagridviewcomboboxcolumn woes.

    Date: 03/07/06 (C Sharp)    Keywords: no keywords

    Using C# 2005 standard edition.

    (Side note: how do I change the default directory to which projects save for one specific project? I'd like this one to go to a flash drive instead of My Documents\Visual Studio Projects.)

    I have a datagridview pointing to the Categories table. The categories table contains two ID columns relating to other tables, Indices and Parents. What I'm trying to do is tie the descriptions in those two lookup tables to this datagridview. I'll use Indices as an example, since it comes first. Here's the properties for the IndicesID column:



    Appearance:
    DefaultCellStyle: DataGridViewCellStyle{}
    DisplayStyle: DropDownButton
    DisplayStyleForCurrentCellOnly: False
    FlatStyle: Standard
    Header Text: Index
    ToolTipText:
    Visible: True

    Behavior:
    AutoComplete: True
    ContextenuStrip: {none}
    DropDownWidth: 1
    MaxDropDownItems: 8
    ReadOnly: False
    Resizable: True
    Sorted: False
    SortMode: Automatic

    Data:
    DataPropertyName: IndicesID
    DataSource: indicesBindingSource1
    DisplayMember: Description
    Items: (Collection) collection is empty, of course.
    ValueMember: ID

    Design:
    Name: clmIndex
    ColumnType: DataGridViewComboBoxColumn

    Layout:
    AutoSizeMode: AllCellsExceptHeader
    DividerWidth: 0
    FillWeight: 100
    Frozen: False
    MinimumWidth: 5
    Width: 39



    I'm not sure if I'm getting the error from this, parents, or both, but the two are identically laid out, with only Header Text and the Data stuff different. I have checked, and the DataPropertyName combo box still pulls from the original binding source, not indicesBindingSource1 (or parentsBindingSource1), so that's working properly.

    When I run the application and open the form, then immediately hit the close button-- without actually changing anything on the form (or if I do, it doesn't matter), I get the following error:

    The following exception occurred in the DataGridView:
    System.ArgumentException: DataGridViewComboBoxCell value is not valid.
    To replace this default dialog, please handle the DataError event.

    I'd rather fix the problem than handle the event.

    After discovering this page, I checked the tables to make sure foreign keys were there (they weren't, I added them, ran it again, same error) and did visual confirmation that there were no values in the IndicesID and ParentID columns that didn't exist in the lookup tables (there weren't). I also checked to make sure all the ID columns referred to are of the same type (they are, all are int).

    I'm out of 'net resources, at least using the search terms I'm using. Anyone have any ideas what else it could be? Any chance it's a slight difference in syntax between Express (where it was originally written) and Standard editions? Because that's about the only option I have left...

    Thanks.

    EDIT: The foreign key constraints are now also set within the dataset that's driving all the tableadapters. No change.

    Source: http://community.livejournal.com/csharp/51302.html

« One moer stupid question || marshalling abstract pointers »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home