Add text from listbox into datagrid column

M

Melson

Hi

Can anyone help me. I've a datagrid with 3 columns which are employeeID,
name and age in form1. I've another form, form2 which list the employeeID in
the listbox. I would like the employeeID in the listbox(form2) insert into
the employeID in the datagrid when I choose the employeeID from the listbox
in form2.

Can anyone help. Thanks.

Regards
Melson
 
E

Elton Wang

Hi Melson,

Is your form Webform (mostly we use webpage) or Winform?

Elton Wang
(e-mail address removed)
 
M

Melson

Hi Elton

Its Winform.I'm creating windows application. Pls help. Thanks.

Regards
Melson
 
E

Elton Wang

Hi Melson,

First of all, you should have reference of form1 in form2.
You can pass form1 to form2 either by constructor or by a
write only public property.

Then secondly, you can create a public method, e.g.
SetEmployeeToDataGrid, in form1 that receives a parameter,
employeID, and inserts the employeID, with name and age,
into the datagrid (maybe from underlying datasource).

Thirdly, in form2's listbox selectedIndexChanged event,
you can call the method SetEmployeeToDataGrid and pass
listbox.Text as parameter.

HTH. If you still have questions, please let us know.

Elton Wang
 
M

Melson

Hi Elton

I'm really appreciate your help. The hardest part is how to insert the
employeeID(with name and age) into the datagrid in Step 2. If you could show
me the code for Step 2, I can do the rest of the job. I'm new to vb.net, can
you help please. Thanks.

Regards
Melson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top