|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using pulldownlist in datagridview .. can it be done!I am having trouble figuring out how to use combobox in a datagridview. What seemed to be a simple task turned out not to arrghh. I have a dataGridView with 4 columns, one of them is column ID (double). I want to be able to lookup a textual value using a combobox and - when choosed - replace this textual value with the corresponding ID ... the pulldownlist has a dataSource pointing to a table. It shows a text field from this table (displayMember) and inserts a double field (valueMember) .... when I startup the application I fill the dataAdapter. If the adapter returns more than one row it popups with a message System.argumentexception: datagridviewcomboboxcell value is not valid. and I just cant find any logic in it. I assume the value in the combobox can differ from row to row (I mean not as in the good old ms Access days where the pulldownlist control always were the same no matter there were many rows) Does anyone outthere have any experience using combobox in datagridview. Thanks . regards Danny Hi,
Show quoteHide quote "Danny Nielsen" <dannydavidniel***@ofir.dk> wrote in message Ussually this means that the master table has a foreign key which could not news:1138016290.810248.70300@g43g2000cwa.googlegroups.com... > Hi > I am having trouble figuring out how to use combobox in a datagridview. > What seemed to be a simple task turned out not to arrghh. > > I have a dataGridView with 4 columns, one of them is column ID > (double). I want to be able to lookup a textual value using a combobox > and - when choosed - replace this textual value with the corresponding > ID ... > > the pulldownlist has a dataSource pointing to a table. It shows a text > field from this table (displayMember) and inserts a double field > (valueMember) > > ... when I startup the application I fill the dataAdapter. If the > adapter returns more than one row it popups with a message > > System.argumentexception: datagridviewcomboboxcell value is not valid. be found in the lookup table (ValueMember field). Are you sure (1) the lookup table is loaded and (2) contains all the keys referenced by the master table ? You also say you bound the DGVComboBox to a table, what do you exactly mean, it should be bound to a second BindingSource (eg. LookupBindingSource, which is bound to the lookup table in the DataSet on the Form) and there should also be a second TableAdapter (eg. LookupTableAdapter) and it should be used to fill the lookup table at Form_Load. HTH, Greetings Show quoteHide quote > > and I just cant find any logic in it. I assume the value in the > combobox can differ from row to row (I mean not as in the good old ms > Access days where the pulldownlist control always were the same no > matter there were many rows) > > Does anyone outthere have any experience using combobox in > datagridview. > > Thanks . > > regards Danny > Hello HTH
The master DatagridView has a dataView lying upon a DataAdapter with this sql source: SELECT TVISFC818200."T$ID", TVISFC817200."T$AKTIV", TVISFC817200."T$DESC", TVISFC818200."T$AGRP", TVISFC817200."T$TYPE" FROM TVISFC818200 LEFT OUTER JOIN TVISFC817200 ON TVISFC818200."T$ID" = TVISFC817200."T$ID" ....and the comboBox has a DataSet with following Source (from a 2. DataAdapter): SELECT "T$AKTIV", "T$DESC", "T$ID" FROM TVISFC817200 WHERE ("T$AKTIV" = 1) I am using DESC and ID, with DESC as the visual text the user chooses from and ID as the entry written in db when user selects from comboBox. The combobox is loaded with the load of the form. I am not aware of how to use BindingSource as I am still that new to VB - having mostly being programming in VB.2003 (two months). Hopefully the above give you an expression. As long as only one record is loaded with the DataGridView no errors occur but with more the last mentioned error occur for each row. Strange. Does this give you any hints about the reason for this ? Thanks for any responds Danny Hi,
"Danny Nielsen" <dannydavidniel***@ofir.dk> wrote in message Not sure about this kind of field syntax but why are you using an outer news:1138084993.734010.322270@g49g2000cwa.googlegroups.com... > Hello HTH > > The master DatagridView has a dataView lying upon a DataAdapter with > this sql source: > SELECT TVISFC818200."T$ID", TVISFC817200."T$AKTIV", > TVISFC817200."T$DESC", TVISFC818200."T$AGRP", TVISFC817200."T$TYPE" > FROM TVISFC818200 LEFT OUTER JOIN > TVISFC817200 ON TVISFC818200."T$ID" = > TVISFC817200."T$ID" join, you should be using an inner join. You only want to include records from 8182 that have a matching id in 8172, because the ComboBox is only loaded with data from 8172. Secondly if there is a filter (WHERE) on the lookup query then it should also be on the master query (to be safe): SELECT TVISFC818200."T$ID", TVISFC817200."T$AKTIV", TVISFC817200."T$DESC", TVISFC818200."T$AGRP", TVISFC817200."T$TYPE" FROM TVISFC818200 INNER JOIN TVISFC817200 ON TVISFC818200."T$ID" = TVISFC817200."T$ID" WHERE (TVISFC817200."T$AKTIV" = 1 ) > You didn't really say whether you have checked what i talked about in my > ...and the comboBox has a DataSet with following Source (from a 2. > DataAdapter): > SELECT "T$AKTIV", "T$DESC", "T$ID" > FROM TVISFC817200 > WHERE ("T$AKTIV" = 1) > > I am using DESC and ID, with DESC as the visual text the user chooses > from and ID as the entry written in db when user selects from comboBox. > The combobox is loaded with the load of the form. I am not aware of how > to use BindingSource as I am still that new to VB - having mostly being > programming in VB.2003 (two months). Hopefully the above give you an > expression. As long as only one record is loaded with the DataGridView previous reply. Try to execute the two query somewhere, and then verify whether the resultset from the first query does not contain id's that aren't in the resultset for the second query. Hope this helps, Greetings Show quoteHide quote > no errors occur but with more the last mentioned error occur for each > row. Strange. Does this give you any hints about the reason for this ? > Thanks for any responds > > Danny >
AMD/Dual-Core/64 bit: influence on compiled files? - Clients?
Hepl! No accessible 'Main' method with an appropriate signature was found ... Q: primary key Multithreading Can I hide base class properties in a derived class? change IFRAME src Inserting text at the beginning of an existing text file .NET 2.0 question ? executing a .dll? Reading from the COM Port |
|||||||||||||||||||||||