Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / May 2005

Tip: Looking for answers? Try searching our database.

Combobox and Grid on Windows Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeremy - 16 May 2005 18:32 GMT
I have a combo box and a grid on the windows form. I have the grid
populated with data from a query with on simple join to show the user
friendly description of the ID that is in the table. When I click on
one row of the grid, I will show the value in the combo box. When the
user changes the value of the combo box, I want to have that value
reflected in the appropriate column in the grid. When the user is done
making the changes, a button will be pressed to commit all of the
changes to the database. Just so you know, in grid editing is out of
the question for this project. The standard is to have a seperate combo
box to do all of the editing. What is the best way of going about this?
I currently have it set up so that the grid is bound to a dataset
containing all of the information with the join query. I looked into
having a dataset with two datatables with a datarelation, but then the
grid will not display the way I want it to. I dont see an easy way to
display the unique values in the combo box without binding it to its
own dataset, then manually finding the record in the other dataset and
updating the appropriate column. I dont mind doing that, but I want to
know if there is a better method.

thanks!
Cor Ligthert - 16 May 2005 19:13 GMT
Jeremy,

I renewed my sample for this yesterday a little bit..

It is in this message.

http://groups-beta.google.com/group/microsoft.public.dotnet.languages.vb/msg/ea7
4f19f45843ec3?hl=en


I hope it helps,

Cor
Jeremy - 16 May 2005 19:36 GMT
Hi Cor,
Thanks for the quick response. This code sample highlights the problem
I am dealing with. There is a problem, though. Lets say that table1
contains just foreign key information. If I change your code to read
this:
       dtName.LoadDataRow(New Object() {"0", "Herfried K. Wagner",
"0"}, True)
       dtName.LoadDataRow(New Object() {"1", "Cor Ligthert", "2"},
True)
       dtName.LoadDataRow(New Object() {"2", "Armin Zingler", "1"},
True)
       dtName.LoadDataRow(New Object() {"3", "Ken Tucker", "4"}, True)
       dtName.LoadDataRow(New Object() {"5", "Terry Burns", "5"},
True)

Where your first table has just the key, how do I then display in my
grid the user-friendly description of the number. The number is
meaningless to the end user. How do I do this without a join?
Jeremy - 16 May 2005 20:06 GMT
The other problem I have which this does not address is that I am only
updating one table in the database, but am displaying data from 2. So I
need to choose a value in the combo box, then update the hidden field
with the correct id to write to the database while showing the correct
user-friendly value. I used to do this in VB6 all the time, but I am
trying to do this "the .NET way" I am wondering if I just need to write
all the plumbing code that I had to before. I was hoping there was a
way that ADO.NET handled this kind of situation.
Cor Ligthert - 16 May 2005 20:14 GMT
Jeremy,

> Where your first table has just the key, how do I then display in my
> grid the user-friendly description of the number. The number is
> meaningless to the end user. How do I do this without a join?

Do you know what was one of the greatest changes with the old sample, beside
a what clumsy adding of rows in the old: I removed the datagridstyles,
because therefore the sample looked more on a style sample than a sample for
this problem. Therefore do I advice you to use those styles for your problem
as you describe it now.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fSystemWindowsFormsDataGridTableStyleClassTopic.asp


By the way. I answered 5 minutes ago as well a question from Jeremy in the
newsgroup VBNet. I expected it was the same Jeremy, now I saw from the mail
address that it are two different persons.  (My assumption was direct that
you were using VBNet)

I hope this helps,

Cor
Jeremy - 16 May 2005 20:59 GMT
It looks like the grid styles are not going to help me since i am using
an Infragistics grid to do this. they have completely changed the model
for alot of stuff. There doesn't seem to be an easy way to do this.

On a somewhat related topic, I am reading the ADO.NET book by David
Sceppa published by Microsoft. They seem to be recommending moving away
from joined queries. If I can't get a VERY simple example of grid to
combo mapping working in this new scheme, I will have no choice but to
force some kind of ugly solution to this problem. Especially once I
start coding complex data entry forms that could have 3 or 4 related
tables. Any thoughts on this? Surely I can't be the only one trying to
do this!?!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.