473,725 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combo Boxes in Datagrids

Ok, ill try again.....

It seems fairly simple.

I have two combo boxes in a datagrid. The datagrid is bound to a a table in
a dataset.

The two combo boxes are bound to a single data table in a different dataset.

One combo box is displaying the Employees payroll ID. The other is
displaying the Employees name.

The users are entering timesheet hours for employees. They want to be able
to select the employee by either payroll id, or employee name.

If they select a payroll id from the first combo box, I need the second
combo box to display the matching employee surname.

I cannot see anyway to do this.

I can only seem to get the selected index of the combo box being selected.
(by using the editing control event and casting the datagrid comboboxcolumn
to a combo box). However, I dont know how I can set the selected index of
the other combo box.

Can anyone help? (besides telling me to buy some third party control!)

thankyou

Oct 9 '06 #1
7 1848
Hi there,

Sounds like you've had problems getting help.
I'll try as best I can but need you to provide some more info first.

1. Windows or web application? .NET 1.1 I presume?
2. Post some code; specifically where you do your binding/fill the
combos.

If you can get a reference to the actual combobox in question, then it
should not be too hard to select the right item. But assigning the
right information to the combobox in the first place is the important
part. For example, in windows app, you can iterate through the items
collection and check each item's bound row for a match to the ID
selected in the other cbx.

Steven

Oct 9 '06 #2
Im using version 2.0

This is a windows form.

I am using the standard DatagridView. This is bound to a dataset generated
by the dataset designer.

I have gone into the designer for the DataGridView and changed the
properties of the two columns previously mentioned to combo boxes (instead of
text boxes).

On the form load, I create a dataset and use stored procedures to populate
various tables with lookup data.

I then bind the combo boxes in the datagrid to these dataset tables

eg
with DataGridCombo1
.DisplayMember = "EmpCode"
.ValueMember = "Surname"
.DataSource = dsLookups.Table s("EmplsCodeLoo kup")
end with

now...teh comboboxes that are embedded in the datagrid do not have the
selectedindex property available...

so, if the user selects a value in one combo box, to get the selected index
of that combo box I have to do the following
Private Sub TblTimeSheetHou rsDataGridView_ EditingControlS howing(ByVal sender
As Object, ByVal e As
System.Windows. Forms.DataGridV iewEditingContr olShowingEventA rgs) Handles
TblTimeSheetHou rsDataGridView. EditingControlS howing
Dim combo As ComboBox = CType(e.Control , ComboBox)
If (combo IsNot Nothing) Then

Select Case TblTimeSheetHou rsDataGridView. CurrentCell.Col umnIndex
Case 2
RemoveHandler combo.SelectedI ndexChanged, _
New EventHandler(Ad dressOf
EmplCodeComboBo x_SelectedIndex Changed)
....
....
....
end sub

Which is all well and good, I now have the selected index of the combo box
the user has just selected. However, I now need to programmaticall y set the
index of the other combo box....

What i want to know is.....how do I do this (given that the editing control
event had to be raised to get the selected index of the other combo!!).

Surely this is possible somehow!?

Please help

Oct 9 '06 #3
Hi again,

No problems. If you can wait on the problem for another 24 hours, I
will attempt to recreate your problem at home tonight and find an
answer for you. Unfortunately I do not have 2.0 here at work (yes we
are a little behind the times).

Cheers,
Steven

Ausclad wrote:
Im using version 2.0

This is a windows form.

I am using the standard DatagridView. This is bound to a dataset generated
by the dataset designer.

I have gone into the designer for the DataGridView and changed the
properties of the two columns previously mentioned to combo boxes (instead of
text boxes).

On the form load, I create a dataset and use stored procedures to populate
various tables with lookup data.

I then bind the combo boxes in the datagrid to these dataset tables

eg
with DataGridCombo1
.DisplayMember = "EmpCode"
.ValueMember = "Surname"
.DataSource = dsLookups.Table s("EmplsCodeLoo kup")
end with

now...teh comboboxes that are embedded in the datagrid do not have the
selectedindex property available...

so, if the user selects a value in one combo box, to get the selected index
of that combo box I have to do the following
Private Sub TblTimeSheetHou rsDataGridView_ EditingControlS howing(ByVal sender
As Object, ByVal e As
System.Windows. Forms.DataGridV iewEditingContr olShowingEventA rgs) Handles
TblTimeSheetHou rsDataGridView. EditingControlS howing
Dim combo As ComboBox = CType(e.Control , ComboBox)
If (combo IsNot Nothing) Then

Select Case TblTimeSheetHou rsDataGridView. CurrentCell.Col umnIndex
Case 2
RemoveHandler combo.SelectedI ndexChanged, _
New EventHandler(Ad dressOf
EmplCodeComboBo x_SelectedIndex Changed)
...
...
...
end sub

Which is all well and good, I now have the selected index of the combo box
the user has just selected. However, I now need to programmaticall y set the
index of the other combo box....

What i want to know is.....how do I do this (given that the editing control
event had to be raised to get the selected index of the other combo!!).

Surely this is possible somehow!?

Please help
Oct 9 '06 #4
Ausclad,

If you want help, than give correct questions, the help for a Combobox in a
DataGrid is much more work and completely different than for a DataGridView.

The way you ask your questions gives me not the right feeling to help you.

Maybe the next time, when you let us not first search to a complete
different solution just because you are no lazy to write correctly your
problem.

Just my thought,

Cor

"Ausclad" <Au*****@discus sions.microsoft .comschreef in bericht
news:D6******** *************** ***********@mic rosoft.com...
Im using version 2.0

This is a windows form.

I am using the standard DatagridView. This is bound to a dataset
generated
by the dataset designer.

I have gone into the designer for the DataGridView and changed the
properties of the two columns previously mentioned to combo boxes (instead
of
text boxes).

On the form load, I create a dataset and use stored procedures to populate
various tables with lookup data.

I then bind the combo boxes in the datagrid to these dataset tables

eg
with DataGridCombo1
.DisplayMember = "EmpCode"
.ValueMember = "Surname"
.DataSource = dsLookups.Table s("EmplsCodeLoo kup")
end with

now...teh comboboxes that are embedded in the datagrid do not have the
selectedindex property available...

so, if the user selects a value in one combo box, to get the selected
index
of that combo box I have to do the following
Private Sub TblTimeSheetHou rsDataGridView_ EditingControlS howing(ByVal
sender
As Object, ByVal e As
System.Windows. Forms.DataGridV iewEditingContr olShowingEventA rgs) Handles
TblTimeSheetHou rsDataGridView. EditingControlS howing
Dim combo As ComboBox = CType(e.Control , ComboBox)
If (combo IsNot Nothing) Then

Select Case
TblTimeSheetHou rsDataGridView. CurrentCell.Col umnIndex
Case 2
RemoveHandler combo.SelectedI ndexChanged, _
New EventHandler(Ad dressOf
EmplCodeComboBo x_SelectedIndex Changed)
...
...
...
end sub

Which is all well and good, I now have the selected index of the combo box
the user has just selected. However, I now need to programmaticall y set
the
index of the other combo box....

What i want to know is.....how do I do this (given that the editing
control
event had to be raised to get the selected index of the other combo!!).

Surely this is possible somehow!?

Please help



Oct 9 '06 #5
Wow Cor, I think you came in a little too strong this time.
If you want help, than give correct questions
People can't always word the question as perfectly as we would like.
That's why I asked the clarification questions. Now days, if anyone
ever asks about DataGrids, I always first check what framework version
they are running, just in case. It so happens that this time it paid
off.
I suppose I got lucky...
The way you ask your questions gives me not the right feeling to help you.
I guess thats up to you. You are well within your rights to refuse to
answer anyones questions.
Maybe the next time, when you let us not first search to a complete
different solution just because you are no lazy to write correctly your
problem.
I don't think laziness has anything to do with it in this posting. The
OP merely ommitted a single word "View" that simply happened to have a
large impact on the solution. While I concur that this can be
frustrating, I think a more educational approach for the OP is to
simply advise them of the impact of their error and the consequences.
This lets the OP have a chance at apologising for their mistake. But
coming out and attacking straight off the bat is not going to help
anyone.

Anyway, lets see if we can find an answer for him, shall we? I don't
have .NET2.0 here but I can look at it tonight if no one else can help
now...

Steven

Oct 9 '06 #6
Steven,

I do not like those people who give a lot of work, for the same case I would
have send some links for combobox datagrids and given some help. You can use
the DataGrids in any version of Net.

What is wrong to describe a question good, instead of something as.

"I have a problem with my Combo Boxes in Datagrids" Who says that it is in
this case about Comboboxes and not about a Calendar Control.

It can in my opinion not be a problem. My message was also meant to show to
others that we should not help in these cases that people don't take even
the time to put there question right, in my idea have those people not even
investigated their problems and do I completely agree what Boo often
writes..

But feel free to help.

Cor

"Steven Nagy" <le*********@ho tmail.comschree f in bericht
news:11******** ************@i3 g2000cwc.google groups.com...
Wow Cor, I think you came in a little too strong this time.
>If you want help, than give correct questions

People can't always word the question as perfectly as we would like.
That's why I asked the clarification questions. Now days, if anyone
ever asks about DataGrids, I always first check what framework version
they are running, just in case. It so happens that this time it paid
off.
I suppose I got lucky...
>The way you ask your questions gives me not the right feeling to help
you.

I guess thats up to you. You are well within your rights to refuse to
answer anyones questions.
>Maybe the next time, when you let us not first search to a complete
different solution just because you are no lazy to write correctly your
problem.

I don't think laziness has anything to do with it in this posting. The
OP merely ommitted a single word "View" that simply happened to have a
large impact on the solution. While I concur that this can be
frustrating, I think a more educational approach for the OP is to
simply advise them of the impact of their error and the consequences.
This lets the OP have a chance at apologising for their mistake. But
coming out and attacking straight off the bat is not going to help
anyone.

Anyway, lets see if we can find an answer for him, shall we? I don't
have .NET2.0 here but I can look at it tonight if no one else can help
now...

Steven

Oct 9 '06 #7
Well thanks Cor for that complete and utter gibberish.

The whole point of these forums, I thought, was for people who do not have a
complete understanding of the .net framework to seek some guidance from those
who do.

Since I am new to .net I was not aware that there was/is a datagrid and a
datagridview. Since my version only shipped with a DataGridView I (wrongly)
assumed the generic term "datagrid" was adequate. My humble apologies!

Given that I spent a good 5-6 hours attempting this task and googling to
find a solution first I think I have at least given it reasonable thought
before posting the question.

Given the way you write, there no way I could convert my question into
something you could possibly understand anyway.

Steven, thanks for being the kind of person this forum needs. I look
forward to any further help you are able to provide.

thanks
Oct 9 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3320
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in about 3 years and I'm more rusty than I thought I was. Anyway, in a nutshell: The scenario: 2 combo boxes (comboLastName and comboStateorProvince) on a form with 30 text boxes, the form's recordsource has been set to a query, both combo boxes and...
0
3536
by: Krisa | last post by:
Hello all, I just discovered something (stop me if you've heard this before....) that was causing me a significant performance hit when opening a form with subforms. To speed up loading the form, I set the rowsources of its, and its subforms', combo boxes in the "Enter" events of the combo boxes. That's the standard trick for not loading the rowsource unless/until the user actually needs the combo box. For example:
0
1602
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number of text and combo boxes on it (in panels on the tab). These combos were originally simple drop down lists - i.e. you had to select from the list and couldn't enter anything of your own. At that time everything worked fine. Now, the users...
2
1624
by: Ausclad | last post by:
How Would you implement this? I have an existing Access application that needs to be converted to .net I am restricted to use the existing database design. One of the areas is a timesheet data entry screen. The existing Access app writes to a table (tblTimesheetHours). In the data entry screen, the fields, like employee name, job, etc are bound to combo
4
2361
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. The idea behind the database is for a user to search/ select desired information in any kind of combination between the 4 combo boxes. Then the user clicks a button (btnSearch) and subsequently a query ("Search Function") is run that shows all 4...
6
3681
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
2907
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a main form (RD Form) with 4 combo boxes (i.e. cbo1, cbo2, etc) and a subdatasheet (the subform...let's call it subInfo) below the combo boxes on the RD Form. I hope this eliminates any confusion of the
2
3268
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once selecting from the combo box, I have all the combo boxes, using afterupdate, populating their respective list boxes. These text boxes are directly correlated to the combo box selection using SQL. Here is an example from the afterupdate event in the...
2
2302
by: someshbakliwal | last post by:
Hi, I have created some autopopulating combo boxes on my HTML page (script- Javascript). so these combo boxes are autopopulated with choices made in previous combo boxes. The problem I am facing is that the combo boxes resize according to the length of the autopulating string. For example if the combo box autopopulates with option 'United States of America', the combo box will become wider and if it autopopulates with value 'NY' the combo box...
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.