Click here to Skip to main content
15,925,444 members
Home / Discussions / C#
   

C#

 
GeneralRe: Multiple forms and datagridviews [modified] Pin
bwood202018-May-09 6:50
bwood202018-May-09 6:50 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute18-May-09 8:18
Henry Minute18-May-09 8:18 
GeneralRe: Multiple forms and datagridviews Pin
bwood202018-May-09 8:44
bwood202018-May-09 8:44 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute18-May-09 9:54
Henry Minute18-May-09 9:54 
GeneralRe: Multiple forms and datagridviews Pin
bwood202018-May-09 12:54
bwood202018-May-09 12:54 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute18-May-09 13:01
Henry Minute18-May-09 13:01 
GeneralRe: Multiple forms and datagridviews Pin
bwood202019-May-09 7:13
bwood202019-May-09 7:13 
GeneralRe: Multiple forms and datagridviews [modified] Pin
Henry Minute19-May-09 8:33
Henry Minute19-May-09 8:33 
Thanks for posting some of your code.

From a quick read through, it seems as if there is some redundant code in there. To help in your future development adventures please try this for me.

Remove or comment out the following lines (commenting is probably better till you confirm it is OK):

//create new dataTable and add new top row for new headers
                              DataTable newDataTable = new DataTable();

                              foreach (DataColumn col in dFill.Columns)
                              {
                                    try
                                    {
                                          newDataTable.Columns.Add(new DataColumn(col.ColumnName));

                                    }
                                    catch (Exception)
                                    {

                                    }
                              }
                              foreach (DataRow row in dFill.Rows)
                              {
                                    string[] rowarr = new string[dFill.Columns.Count];

                                    for (int k = 0; k < dFill.Columns.Count; k++)
                                    {
                                          rowarr[k] = row[k].ToString();
                                    }
                                    newDataTable.Rows.Add(rowarr);

                              }


                              DataRow NewRow;
                              NewRow = newDataTable.NewRow();
                              newDataTable.Rows.InsertAt(NewRow, 0);

As I am not sure of the purpose of the last two three lines of code, you might need to keep them, just change newDataTable to dFill

then change this row as indicated:
// bindingSource1.DataSource = newDataTable;
bindingSource1.DataSource = dFill;


This should give the same results as before. Have a look and let me know, since only you can tell if it is different.

What I then need to know is what you need to happen when when the user double-clicks on dataGridView1 (you are still doing it that way aren't you? Tell me if that has changed.).

For example, something like
"dgv1 has columns for itemName, itemCost and discount (no need to list them all, just enough for me to get an idea what it's about). When dgv1 is double-clicked I want form2 to open and display information about the selected item. Those details come from an Excel spreadsheet/text file/whatever."

cheers

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

modified on Tuesday, May 19, 2009 3:16 PM

GeneralRe: Multiple forms and datagridviews Pin
bwood202019-May-09 9:22
bwood202019-May-09 9:22 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute19-May-09 10:52
Henry Minute19-May-09 10:52 
GeneralRe: Multiple forms and datagridviews Pin
bwood202019-May-09 12:36
bwood202019-May-09 12:36 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute19-May-09 13:48
Henry Minute19-May-09 13:48 
GeneralRe: Multiple forms and datagridviews Pin
bwood202020-May-09 10:02
bwood202020-May-09 10:02 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute20-May-09 10:14
Henry Minute20-May-09 10:14 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute20-May-09 10:19
Henry Minute20-May-09 10:19 
GeneralRe: Multiple forms and datagridviews Pin
bwood202021-May-09 6:25
bwood202021-May-09 6:25 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute21-May-09 7:01
Henry Minute21-May-09 7:01 
GeneralRe: Multiple forms and datagridviews Pin
bwood202021-May-09 8:48
bwood202021-May-09 8:48 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute21-May-09 9:08
Henry Minute21-May-09 9:08 
GeneralRe: Multiple forms and datagridviews Pin
bwood202021-May-09 9:54
bwood202021-May-09 9:54 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute21-May-09 10:42
Henry Minute21-May-09 10:42 
GeneralRe: Multiple forms and datagridviews Pin
bwood202021-May-09 13:01
bwood202021-May-09 13:01 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute22-May-09 9:59
Henry Minute22-May-09 9:59 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute22-May-09 10:05
Henry Minute22-May-09 10:05 
GeneralRe: Multiple forms and datagridviews Pin
Henry Minute22-May-09 10:08
Henry Minute22-May-09 10:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.