Click here to Skip to main content
15,918,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
guys i have datagridview like this

emails     passwords
email1     pass1
email2     pass2
email3     pass3


and in checkedlistbox only email column rows showen,so i want whenever an item checked get its pass from datagridview

What I have tried:

i get the email column rows showen in checked listbox
Posted
Updated 10-Aug-17 17:18pm
v2
Comments
Graeme_Grant 10-Aug-17 21:25pm    
Please click on "Improve question" widget and share your code. We can't see it from here!
Ilyas Zahir 10-Aug-17 21:45pm    
its not code just instruction what i have in my form and what i want to do
Graeme_Grant 10-Aug-17 21:50pm    
We are not a coding service. Please share your code and highlight your problem to get advice.

1 solution

try this

private void button1_Click(object sender, EventArgs e)
       {
           List<string> lstCheckedEmails = new List<string>();
           foreach (var item in checkedListBox1.CheckedItems)
           {
               string email = item.ToString();
               lstCheckedEmails.Add(email);
           }


           foreach (DataGridViewRow row in dataGridView1.Rows)
           {
               string email = row.Cells["EmailColumnName"].ToString();
               if (lstCheckedEmails.Contains(email)) {
                   // read all the necessary columns from this the row object
                   string pass = row.Cells["PasswordColumnName"].ToString();
               }
           }
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900