Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How would i call upon all the information in the gridview and sort out how many oof each item there are into listboxes


What I have tried:

if (dataGridView1.ToLower().Contains('int'))
                {
                    foreach (DataGridViewRow row in dataGridView1.SelectedRows)
                    {
                        label1.Text = pad.Tostring;
                    }
                }
Posted
Updated 8-Aug-20 19:50pm

1 solution

Partly, this is a repost: How do I change value of selected cell on gridview[^] - you need to learn how to apply information to related circumstances.

But ... look at your code:
foreach (DataGridViewRow row in dataGridView1.SelectedRows)
{
    label1.Text = pad.Tostring;
}
THat can only ever put the last row (which is probably empty) into the label as you overwrite the previous content each time round the loop.

If you want summary info, then use the DataSource rather than the Row and Column info and summarise that. That will require you to (probably) add numbers together, rather than try to copy strings ...
 
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