Dear Friends, I am facing a problem, I have two forms,
Form1 Has one DataGrideview and Button redirect to Form2, which has Button(Browse Excel File) and combobox(Sheet No of excel file) and Button to load Excel file list in Datagrideview ,
want to show excel file list in Datagrideview of Form1).
Please, help me any idea?

anybody can help me please,

Perhaps this can help you out.

thx ddanbe,
but these articles did'nt help me...
I have 2 forms For,1 and form2.Form 1 has Datagridview and one button to show Form2 and Form2 has button for browse Excel file , one combobox to Sheet no. of worksheet of excle file and Button Load to load , when i click Load button it load this sheet on Form1 and Form2 should be closed.
i didnt get any idea for this problem please, help me.

oky , first of all i want to transfer data from Fòrm2 to datagridview on Form1.....spose i have two textbox on form2 and one button to load data of textbox1 and textbox2 in Datagridvew on Form1. what to do.
here is code of button for load on Form2

public partial class Form2 : Form
    {
        public static string datas;
        public Form2()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            textBox1.Text = datas;
            Form1 f1 = new Form1();
            f1.Show();
            this.Close();
        }
        and here is code of Form1 

private void btnAdd_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
            f2.ShowDialog();

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string firstColum = Form2.datas;

            string[] row = { firstColum };
            dataGridView1.Rows.Add(row);
        }

You could use something like this, instead of what you did with the Row.
And then continue whit this article from the link I already gave

dear ddanbe,
I think u didnt understand my problem,maybe i could not clearlly explain. Please, read again my problem, maybe any soluton in ur mind.
I can read Excle file in C# on same form where i browse, but can not put this excel file data on datagridview on the other form.

Passing data between forms has been asked many times. The easiest way is to use a custom property to pass data or a reference to control to hold the data.

public partial class Form3 : Form // This is your Form1
{
    public Form3()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Form2 oForm; // This is your Open & Load Excel form

        oForm = new Form2();
        oForm.ExcelView = this.dataGridView1; // Pass this form's DGV to be filled
        oForm.ShowDialog();
        oForm = null; // Dispose Excel form
    }
}

// This is your Form2

    public partial class Form2 : Form
{
    public DataGridView ExcelView { get; set; }

    public Form2()
    {
        InitializeComponent();
    }

    // Add code to open Excel file and load data to ExcelView

    private void button1_Click(object sender, EventArgs e)
    {
        this.Close(); // Return to calling form
    }
}

I hope this helps.

Teme @ windevblog.blogspot.com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.