7
I need to load a combobox with the data from an SQL DEPARTMENT table (with code and description/ the description is displayed in the combobox but what is caught is the code)
I used a datasource (the one configured automatically by clicking on the > above the combobox (graphic editing mode)).
so far perfect: It perfectly loads the data and passes the code but here comes my problem: My application is composed of a form divided into two (split.panel) on one side has navigation and on the other side some panels overlapped one for each type of registration etc... One of these panels is the DEPARTMENT register, when I register a department and I go to the other panel where has this combobox this new department that I registered does not appear... Only those already registered before I open the application appear. If I close my application and open again from there appears everything.
What I have been researching the datasource does not have what I need (it is 'static'). Is there another way to do this? You don’t even have to post me all the code if you don’t want to (I can’t show you my code already done because I’m at work), you can tell me only the resources I should use or a generic example.
I tried using Combobox.Refresh(); but it didn’t help at all.
Grateful ^^
Thanks for the answer but I wanted something "no Ambi", say I resolve to increment this program and put the functionality to delete records?! How will I update the combobox? Will I have to add the Item.Remove (I don’t know the command) and if there are two modules (which are): one more web? Two people (at least) inserted and removing... This solution is not suitable... I need something that looks DIRECTLY FROM THE BANK and 'real-time' (at least the most current until the combobox is generated)!
– Mariana Sempe
Okay, that’s not "Ambi". You could create method that receives a delegate to inform the method that must be executed after deleting/saving a department. in this case, the method would be the same as filling the combobox with the database data.
– Italo Pessoa
It is much more natural and simply consult in the database and fill in Combobox with this data, keep adding lines and deleted each time some department is inserted/deleted is not a very 'natural' reasoning. And I wasn’t kidding when I said gambiarra :) I think I even found the solution, I will be and if it works put here for the rest of the staff. If you have any other suggestions, thank you ^^
– Mariana Sempe
the list of elements has the Clear() method, you can use this before filling the entire datasource. this way it will always remove and add everything from the bank.
– Italo Pessoa
Wow!!! I will test this for sure. Put this comment as a response ^^
– Mariana Sempe
I added in the description of the same answer, since they are two possible solutions :)
– Italo Pessoa