0

Hi All
I have to forms (frmMain & frmEditMonth).

frmMain has a tabControl on the 12 tabs (1 for each month) and a datagridview showning the days and the times and hours worked
frmEditMonth (used as a edit Dialog pop-up) allows the user to edit the hours worked

what i need to is pass information from DatagridView called dgv_xxx (where xxx is the name of the tab, Jan/Feb/Mar etc).
over to the frmEditMonth and populate it's comboboxes

here is the problem
i bring in the name of the tab as a string, when passing this over, I get a "overload method" as i can convert the string to a DataGridView

 // run monthly data (jan-Feb)             
                private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
                {  
                    string _tabname =  tabControl1.SelectedTab.Name;
                    switch (tabControl1.SelectedTab.Name)
                    {
                        default:
                            {
                                dgv_CellContentClick(_tabname,null,null);

// here is the error message 
// The best overloaded method match for 'FlexRecorder.frmMain.dgv_CellContentClick(System.Windows.Forms.DataGridView, object, System.Windows.Forms.DataGridViewCellEventArgs)' has some invalid arguments

                            }
                            break;
                    }

                }     

// on click of DatagridView pass information form this.datgriview to frmEditMonth and populate its comboboxes
                private void dgv_CellContentClick(DataGridView  _tabName,object sender, DataGridViewCellEventArgs e)
                {

                 frmEditMonth frm = new frmEditMonth();
                    if (e.RowIndex >= 0)
                    {
                        DataGridView  tabname = _tabName;
                        DataGridViewRow row = tabname.Rows[e.RowIndex];
                        frm.cboDayType.Text = row.Cells["DayType"].Value.ToString();
                        frm.cboDayStart.Text = row.Cells["DayStart"].Value.ToString();
                        frm.cboLunch.Text = row.Cells["Lunch"].Value.ToString();
                        frm.cboDayEnd.Text = row.Cells["DayEnd"].Value.ToString();
                        frm.tboNotes.Text = row.Cells["Notes"].Value.ToString();
                    }

                    frm.ShowDialog();
                     frm.Dispose();
                }

            }

thanks in advance for all and any help

3
Contributors
2
Replies
17
Views
2 Years
Discussion Span
Last Post by arunkumars
0

frmMain has a tabControl on the 12 tabs (1 for each month) and a datagridview showning the days and the times and hours worked frmEditMonth (used as a edit Dialog pop-up) allows the user to edit the hours worked

Minor design nitpick: If you find yourself with more than a handful of tabs, a tab control probably isn't the right way to display your data. I'd be more inclined to use a list box and a user control nested in a split container where selecting a month in the list box loads that month into the user control.

0

the best option would be what deceptikon has suggested.

for your problem, seems like the method call has some issues,
call dgv_CellContentClick(_tabname,sender,e);
instead of dgv_CellContentClick(_tabname,null,null);
lets see if this works.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.