Hierarchical Datagridviewcomboboxcolumn 3,7/5 6256votes

Hi freinds, i have a datagridview with 3 datagridviewcomboboxcolumn, i want fill colProductIdCombo1,colProductIdCombo2 and colProductIdCombo3 based on colProductIdCombo. This is my code: Dim dt_sanad_hesabdari As New System.Data. DataTable Dim dt_hesab_moin As New System.Data. DataTable Dim dt_hesab_tafzili As New System.Data.

DataTable Using objSqlServer As New System.Data.SqlClient. SqlConnection( 'Data Source='Accounting-pc';Initial Catalog='rasol';Integrated Security='sspi';') objSqlServer.Open() Dim strSql As String strSql = 'select b.code,a.sathe_4,a.sathe_5,a.sathe_6,a.sharh,a.bed,a.bes,a.arz_name from sanad_hesabdari a,hesab_tafzili b where a.kod_tafzil = b.code' Dim sqlCmd As New System.Data.SqlClient. SqlCommand(strSql, objSqlServer) dt_sanad_hesabdari.Load(sqlCmd.ExecuteReader) sqlCmd.CommandText = 'SELECT id_moin,moin_name From hesab_moin order by id_moin' dt_hesab_moin.Load(sqlCmd.ExecuteReader) strSql = 'SELECT * from dbo.hesab_tafzili a inner JOIN(select * from dbo.hesab_moin a cross apply dbo.fn_SplitString(a.id_sath_4,','))b on a.id_moin = b.id_moin and a.sath = b.value' Dim sqlCmd1 As New System.Data.SqlClient. Hello, If you want to filter on colProductIdCombo the best thought is to get the value from colProductIdCombo when the user changes it's value thru the event EditingControlShowing, hook up an event to the DataGridViewComboBox for SelectionChangeCommitted where you can cast sender param to DataGridViewComboBoxEditingControl followed by getting at the Text property. Once you have the Text you can do your filter.

I have an example which uses this logic that when the user changes the selection in the DataGridView ComboBox cell it updates a secondary ComboBox cell in the same DataGridView, this logic can be used to do what you want in another DataGridView too.. Base logic taken from the project that has a BindingSource that has a DataTable for the data source then the DataGridView's data source is the BindingSource where the BindingSource Current property gives us a DataRowView which we can cast if needed to a DataRow then access any field for a given row which is a caveat for using a BindingSource. In your case it does not matter but something to consider. Hi everybody, i am working in vb 2010, i am trying to populate and filter data into combobox2 by selection item from combobox2 but it dose not work properly.only it dose populate all data from 'code' field and not filter with selecting item from combobox1. Hi everybody, i am working in vb 2010, i am trying to populate and filter data into combobox2 by selection item from combobox2 but it dose not work properly.only it dose populate all data from 'code' field and not filter with selecting item from combobox1. Hi carl, how are you, 1.Do you received my vb.sln and database backup files in skydrive?

I have a datagridview with 3 datagridviewcomboboxcolumn, i want fill. In my winapp the hierarchy of data entry is as follow. If we just remove all combobox, and just show the records in datagridview without any datagridviewcomboboxcolumn, how will you code to show that records?

-if not, because i have not any mail or hotmail address from you to add my persons. The above example that you paste, is one of my trying for solve the Question ' how to filter datagridviewcomboboxcolumn based on selection of another datagridviewcomboboxcolumn in vb.net' with smaller sample. 3.my hotmail is 'rasolhanifi@hotmail.com'.

Hierarchical Datagridviewcomboboxcolumn

Please help me to solve the Question ' how to filter datagridviewcomboboxcolumn based on selection of another datagridviewcomboboxcolumn in vb.net'. Best regards. Hi everybody, i am working in vb 2010, i am trying to populate and filter data into combobox2 by selection item from combobox2 but it dose not work properly.only it dose populate all data from 'code' field and not filter with selecting item from combobox1. 3.my hotmail is 'rasolhanifi@hotmail.com'. Please help me to solve the Question ' how to filter datagridviewcomboboxcolumn based on selection of another datagridviewcomboboxcolumn in vb.net'.

Best regards. Hi, I am afraid that we are not able to send any emails to you, we hope you could share the link from skydrive, and of course we will try to help you solve the issue: ' how to filter datagridviewcomboboxcolumn based on selection of another datagridviewcomboboxcolumn in vb.net'. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click to participate the survey. Hi, thank you, Already, i had a thread with this description: how to join data from multiple comma separated values in single field using sql 2008?

Pls see rasol's threads. I have two tables called: hasab_moin & hesab_tafzili. Here are those structure: CREATE TABLE [dbo]. [hesab_moin] ( [id] [int] IDENTITY ( 1, 1 ) NOT NULL, [id_moin] [int] NOT NULL primary key, [id_kol] [int] NOT NULL, [type_hesab] [nvarchar] ( 70 ) NOT NULL, [moin_name] [nvarchar] ( 70 ) NOT NULL, [id_sath_4] [nvarchar](120) NULL, [id_sath_5] [nvarchar](120) NULL, [id_sath_6] [nvarchar](120) NULL, [hesab_state] [bit] NOT NULL ) GO CREATE TABLE [dbo]. [hesab_tafzili] ( [id_tafzili] [int] IDENTITY ( 1, 1 ) NOT NULL, [code] [int] NOT NULL, [caption] [nvarchar] ( 70 ) NOT NULL, [company_type] [nvarchar] ( 70 ) NULL, [ekhtesar_name] [nvarchar] ( 70 ) NULL, [kode_ekhtesadi] [nvarchar] ( 70 ) NULL, [shenase_meli] [nvarchar] ( 70 ) NULL, [onvan_latin] [nvarchar] ( 70 ) NULL, [name_latin] [nvarchar] ( 70 ) NULL, [sath] [nvarchar](70) NULL, [id_moin] [int] NOT NULL Foreign key ) GO also i have third table as follow: CREATE TABLE [dbo]. Hi, I am tring to reproduce this sample, but we need some sample data to test. Would you mind creating a sample and package it witn an backup file of sql database, and uploading it to skydrive, then sharing the link of that file with us?

You can share the download link in your post. You could refer to “ Get a link” in this to get more information about how to share your files in SkyDrive with a link. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time.

Thanks for helping make community forums a great place. Click to participate the survey.

Hi, We could start with this way to solve this issue. First, we need to make sure what we need. To combobox: • Before 'select' the item, we need to add items to combobox which we could treat as opitions: These items contains these things: Display, Value So before 'select' the item, we need to add all situations to the items.

Then let's 'select' the items of datagridviewcomboboxcolumn: >>So when 'select' the item, we need to get the Value we will 'select' To colProductIdCombo, the Value is 'id_moin', To colProductIdCombo1,colProductIdCombo2 and colProductIdCombo3, the Value is 'code'. So what we need are 'id_moin' and 'code'. StrSql = 'select b.code, a.id_moin from sanad_hesabdari a,hesab_tafzili b where a.kod_tafzil = b.code' Dim sqlCmd As New System.Data.SqlClient.SqlCommand(strSql, objSqlServer) dt_sanad_hesabdari.Load(sqlCmd.ExecuteReader) Then we could get that value showed in these comboboxes of datagridview as following: Regards. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click to participate the survey. Hi, If you change that lines to these ones belw, what the result of your application? Hi, We could start with this way to solve this issue. First, we need to make sure what we need. To combobox: • Before 'select' the item, we need to add items to combobox which we could treat as opitions: These items contains these things: Display, Value So before 'select' the item, we need to add all situations to the items. Then let's 'select' the items of datagridviewcomboboxcolumn: >>So when 'select' the item, we need to get the Value we will 'select' To colProductIdCombo, the Value is 'id_moin', To colProductIdCombo1,colProductIdCombo2 and colProductIdCombo3, the Value is 'code'. So what we need are 'id_moin' and 'code'.

StrSql = 'select b.code, a.id_moin from sanad_hesabdari a,hesab_tafzili b where a.kod_tafzil = b.code' Dim sqlCmd As New System.Data.SqlClient.SqlCommand(strSql, objSqlServer) dt_sanad_hesabdari.Load(sqlCmd.ExecuteReader) Then we could get that value showed in these comboboxes of datagridview as following: Regards. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click to participate the survey. This step we need the data which will bind to datagridview.

And its the main step to filter the data. For combobox, we do not need to do any filtering, since it will show based on the 'code' of the data which we get from: strSql = 'select b.code, a.id_moin from sanad_hesabdari a,hesab_tafzili b where a.kod_tafzil = b.code' Dim sqlCmd As New System.Data.SqlClient.SqlCommand(strSql, objSqlServer) dt_sanad_hesabdari.Load(sqlCmd.ExecuteReader) Regards. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click to participate the survey.

Hi, In order to get what we could solve this issue, please create a sample and package it with an backup file of sql database, and uploading it to skydrive, then sharing the link of that file with us? You can share the download link in your post. You could refer to “ Get a link” in this to get more information about how to share your files in SkyDrive with a link. I think that will help you solve this issue more quickly. Best Regards. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click to participate the survey. I find I made a mistake. We could do the filtering in the second step which collect the data and bind the data to datagridview. I suggest you check this one below: strSql = 'select b.code, a.id_moin from sanad_hesabdari a,hesab_tafzili b inner JOIN(select * from dbo.hesab_moin a cross apply dbo.fn_SplitString(a.id_sath_4,','))c on b.id_moin = c.id_moin and b.sath = c.value where a.kod_tafzil = b.code' Dim sqlCmd As New System.Data.SqlClient.SqlCommand(strSql, objSqlServer) dt_sanad_hesabdari.Load(sqlCmd.ExecuteReader) Regards. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click to participate the survey. Hi, Thanks a lot! Glad that we have got the direction to solve this issue now. But we could not get the sample from the email. I have edited your reply to remove the password for security. You could upload it to Thanks for your understanding.

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click to participate the survey. Hi carl, Thank you, in my winapp the hierarchy of data entry is as follow: 1.hesab_kol table. 2.hesab_moin table.

3.hesab_tafzili table. 4.sanad_hesabdari table. (sanad_hesabdari table get the data from 'id_moin' of hesab_moin table(into colProductIdCombo),related'code'from hesab_tafzili table(into colProductIdCombo1),related'code'from hesab_tafzili table(into colProductIdCombo2)and related'code'from hesab_tafzili table(into colProductIdCombo3)). Yet I could not solve getting data from 'hesab_moin' and 'hesab_tafzili'. Best regards. Hi carl, Thank you, in my winapp the hierarchy of data entry is as follow: 1.hesab_kol table. 2.hesab_moin table.

3.hesab_tafzili table. 4.sanad_hesabdari table. (sanad_hesabdari table get the data from 'id_moin' of hesab_moin table(into colProductIdCombo),related'code'from hesab_tafzili table(into colProductIdCombo1),related'code'from hesab_tafzili table(into colProductIdCombo2)and related'code'from hesab_tafzili table(into colProductIdCombo3)). Yet I could not solve getting data from 'hesab_moin' and 'hesab_tafzili'. Best regards.

Hi, Sorry, I don't understand why we could get that data showed with an empty table, since sanad_hesabdari is empty. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click to participate the survey.

Hi carl, thank you for your Patience. According your order, I have insert data into 'sanad_hesabdari', and upload again database backup (rasol_1392-09-23.bak). After inserting data into 'sanad_hesabdari', i have this result: best regards. Hi, Sorry for my delay.

Is that result is the one you wanted? If not, would you minding sharing the result you want to show in datagridview? We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time.

Thanks for helping make community forums a great place. Click to participate the survey. Hi dear carl, 1. I want to get data from 3 combobox for Prevent mistakes, but with clicking on comboboxes into datagridview it dose not return arbitrary results. It returns all of defined detail accounts, not related 'code', where 'hesab_moin.id_sath_4' = 'hesab_tafzili.sath' into colProductIdCombo1,'hesab_moin.id_sath_5' = 'hesab_tafzili.sath' into colProductIdCombo2 and 'hesab_moin.id_sath_6' = 'hesab_tafzili.sath' into colProductIdCombo3. At new ledger account defining, user can relate ledger account with 3 level of detail accounts.by this relation, appearance of detail accounts into 3 comboboxs Be determined. Datagridview should display all records.

Thank you carl. Hi, Sorry for no helping. We could start with this step: 2. Datagridview should display all records If we just remove all combobox, and just show the records in datagridview without any datagridviewcomboboxcolumn, how will you code to show that records? If possible, please share that code with us based on the data you shared with us with the skydrive. Best Regards.

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click to participate the survey.

Hi rasol, Merry Christmas! The key point of this issue is that whether this scenario below exitsts: If there is a datagridview cell, its value is i.e '4', and the DataGridViewComboBoxColumn doesn't contain '4'. This scenario just is the one as following: >>1. I want to get data from 3 combobox for Prevent mistakes, but with clicking on comboboxes into datagridview it dose not return arbitrary results. It returns all of defined detail accounts, not related 'code', where 'hesab_moin.id_sath_4' = 'hesab_tafzili.sath' into colProductIdCombo1,'hesab_moin.id_sath_5' = 'hesab_tafzili.sath' into colProductIdCombo2 and 'hesab_moin.id_sath_6' = 'hesab_tafzili.sath' into colProductIdCombo3.' Datagridview should display all records.

So task 2 will get this value which the combobox of task 1 doesn't contain, and will get that error, since task 2 show all records but task do filtering. I am afraid that if that scenario exists, it doesn't make scene, if that scenario doesn't exists, your orignal way should not get that error.

And I find that you have got that error in the other therads of yours, If you have any concern, please feel free to let me know. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

Click to participate the survey. Hi carl, Merry Christmas, sory, in original i have four comboboxs in my datagridview, But because 'colProductIdCombo' is working fine(by clicking on, display all 'id_moin' from 'hesab_moin' table), in speaking I ignored it. Datagridview should display all records but about item(2),datagridview should display all related records of stored data into 'sanad_hesabdari' table, so that 'id_sanad' from 'sanad_header' table be match to 'id_sanad' from 'sanad_hesabdari' table, so by clicking on 'last,up,down and first' buttons inside of 'Accounting Document Issue' tab, we should see all related records. I'm sorry that I could not express it properly. Best regards.

Hi, >>sory, in original i have four comboboxs in my datagridview, But because 'colProductIdCombo' is working fine(by clicking on, display all 'id_moin' from 'hesab_moin' table), in speaking I ignored it. First, I just show a sample to solve the similar issue, and we just focus on one combobox, since it is similar as the other, if we could make one combobox which has that issue, it is quite easy to solve the issues of the other. Second, I am quite clear that you have 4 comboboxes, and the first works fine, and the other comboboxes has binded with the same database, so I just focus one combobx. >>but about item(2),datagridview should display all related records of stored data into 'sanad_hesabdari' table, so that 'id_sanad' from 'sanad_header' table be match to 'id_sanad' from 'sanad_hesabdari' table, so by clicking on 'last,up,down and first' buttons inside of 'Accounting Document Issue' tab, we should see all related records.

I don't think there is any problem using the way to show all related records, since how to get all that records is a specific issue about SQL, and you have posted some issues in that forum, so about sql issues, please post in that forum for more dedicated support. What is the result of using the way I suggested uses DataGridViewComboBoxCell?

Please share that code and the image of that error message. Please post it in your new reply. >>I'm sorry that I could not express it properly. If you have problem expressing it with words, you could use images as the way of mine.: ) Regards. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time.

Thanks for helping make community forums a great place. Click to participate the survey. But i dont understand result of these tests.

Hi, I didn't mean using the same code as mine, you should change it to the one fit for your project. >>The datatable dtccb1 doesn't contain '4', you could treat it as the one which will bind to the datagridviewcomboboxcolumn, to your project is dt_hesab_tafzili. I just showed a way to solve a common issue which is similar with yours, so you should find how it works and use that way to solve your issues. Best Regards. We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click to participate the survey.

A long thread. Nevertheless I see the for me obvious solution not stated. • Use for the two dependent comboboxes instead of a datatable. The DataView representation with a filter likewise the value of the first combo. • Use for the two dependent comboboxes every time a new gotten table using a where clause in the database with a where clause. I would go for the second solution most connections are currently that fast that getting fist a whole table is mostly a waste of time.

Transformers Playstation Game more. For the selection of the first combobox you can use the code Kevin has provided you in the first reply in this thread.

Coments are closed
Scroll to top