Click here to Skip to main content
15,917,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I have a button that creates a new tabpage in a tabcontrol, a datagridview control in created tabpage. The data source of datagridview is a table with two columns, one with images(type byte[]) and one with a bool (it shows like a checkbox). So I want my second button to save the checked images, I tried passing the table with a selection changed event and mouse leave event but it doesen't work (it only saves the n-1 images that I want to save from n images checked for saving). So here is my question: How can I pass the datasource of datagridview after checking from button1 to button2 for saving? Or how can I find and work on datagridview control in created tabpage? Or is there any other way to do this? (int must be two buttons a created tabpage and a gatagridview control into one button and the saving part into the second)
And here is my code:

C#
DataTable saveimgdataT;
private void button1_Click(object sender, EventArgs e)
{
    tabControl1.TabPages.RemoveByKey("Find Image");
    //create datagridview control
    DataGridView datagrid1 = new DataGridView();
    //create a new tabpage and add control
    Utile.Customtabpage.tabpage(tabControl1, datagrid1, "Find Image");
    // set data source
    datagrid1.DataSource = Utile.Results.addcheck(imlis, name, distance, M, N, ConnectionSTR);
    datagrid1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    datagrid1.SelectionChanged += new EventHandler(datagrid1_CheckChanged);
    datagrid1.AutoResizeColumns();
    datagrid1.AutoResizeRows();
}
void datagrid1_CheckChanged(object sender, EventArgs e)
{
    ((DataGridView)sender).Refresh();
    saveimgdataT = (DataTable)((DataGridView)sender).DataSource;


}

private void button2_Click(object sender, EventArgs e)
{
    if (!tabControl1.TabPages.ContainsKey("Find Image") == false)
    {
        tabControl1.SelectTab("Find Image");

        DataTable dt = saveimgdataT;
        FolderBrowserDialog save = new FolderBrowserDialog();
        if (save.ShowDialog() == DialogResult.OK)
        {
           Results.save(dt, save.SelectedPath);//function that saves the image
        }
    }
}
Posted
Updated 5-Jun-12 6:10am
v3
Comments
SASS_Shooter 1-Jun-12 11:55am    
Providing some code that you've implemented will help you get a faster answer. Include the gridview showing how your binding the data now. Also include what UI style you are using as the answer can change if it is web vs. silverlight. Update your question using the Improve Question button.
aryx123 5-Jun-12 11:58am    
sorry for that, i putt the code also so do you have an ideea?

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