Click here to Skip to main content
15,563,471 members
Home / Discussions / C#
   

C#

 
AnswerRe: C++ Pin
OriginalGriff28-Oct-22 19:49
mvaOriginalGriff28-Oct-22 19:49 
QuestionC++ Pin
Mathooanyane Khoeli28-Oct-22 11:02
Mathooanyane Khoeli28-Oct-22 11:02 
AnswerRe: C++ Pin
Dave Kreskowiak28-Oct-22 12:46
mveDave Kreskowiak28-Oct-22 12:46 
AnswerRe: C++ Pin
OriginalGriff28-Oct-22 19:47
mvaOriginalGriff28-Oct-22 19:47 
QuestionC# vs C++ process standard out redirection differences Pin
Member 1490333523-Oct-22 8:52
Member 1490333523-Oct-22 8:52 
AnswerRe: C# vs C++ process standard out redirection differences Pin
OriginalGriff23-Oct-22 9:16
mvaOriginalGriff23-Oct-22 9:16 
QuestionLoading a Data Table form a DataGrid view but still no joy. Pin
Ozzie Mozzie23-Oct-22 0:59
Ozzie Mozzie23-Oct-22 0:59 
AnswerRe: Loading a Data Table form a DataGrid view but still no joy. Pin
OriginalGriff23-Oct-22 1:51
mvaOriginalGriff23-Oct-22 1:51 
If I use your code, but replace the ImportRow with your commented out Rows.Add code, it works fine for me:
private void MyOtherButton_Click(object sender, EventArgs e)
    {
    DataTable dataTable = new DataTable();

    foreach (DataGridViewColumn col in myDataGridView.Columns)
        {
        dataTable.Columns.Add(col.Name);
        }

    foreach (DataGridViewRow row in myDataGridView.Rows)
        {
        DataRow drow = dataTable.NewRow();
        foreach (DataGridViewCell cell in row.Cells)
            {
            drow[cell.OwningColumn.Name] = cell.Value;
            }
        // The drow (DataRow) has all the Data in its ItemArray property but it does not get saved into the datatable row.
        dataTable.Rows.Add(drow);
        dataTable.AcceptChanges();
        //The columns load but the data rows do not add or import

        }
    MyOtherDataGridView.DataSource = dataTable;
    }
I get identical DGV's side by side ...

So what am I doing that you aren't?
And why are you doing this ass backwards? Normally you use the DataGridView.DataSource to populate data, not the actual rows and columns ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Loading a Data Table form a DataGrid view but still no joy. Pin
Ozzie Mozzie23-Oct-22 2:19
Ozzie Mozzie23-Oct-22 2:19 
GeneralRe: Loading a Data Table form a DataGrid view but still no joy. Pin
OriginalGriff23-Oct-22 2:46
mvaOriginalGriff23-Oct-22 2:46 
GeneralRe: Loading a Data Table form a DataGrid view but still no joy. Pin
Ozzie Mozzie23-Oct-22 3:05
Ozzie Mozzie23-Oct-22 3:05 
GeneralRe: Loading a Data Table form a DataGrid view but still no joy. Pin
OriginalGriff23-Oct-22 3:37
mvaOriginalGriff23-Oct-22 3:37 
GeneralRe: Loading a Data Table form a DataGrid view but still no joy. Pin
Ozzie Mozzie23-Oct-22 15:36
Ozzie Mozzie23-Oct-22 15:36 
GeneralRe: Loading a Data Table form a DataGrid view but still no joy. Pin
Ozzie Mozzie23-Oct-22 17:03
Ozzie Mozzie23-Oct-22 17:03 
GeneralRe: Loading a Data Table form a DataGrid view but still no joy. Pin
OriginalGriff23-Oct-22 22:35
mvaOriginalGriff23-Oct-22 22:35 
QuestionC# Save DataGrid Only MultiSelected Rows to File Pin
CodaNV22-Oct-22 18:03
CodaNV22-Oct-22 18:03 
AnswerRe: C# Save DataGrid Only MultiSelected Rows to File Pin
Dave Kreskowiak22-Oct-22 18:50
mveDave Kreskowiak22-Oct-22 18:50 
GeneralRe: C# Save DataGrid Only MultiSelected Rows to File Pin
CodaNV22-Oct-22 19:11
CodaNV22-Oct-22 19:11 
GeneralRe: C# Save DataGrid Only MultiSelected Rows to File Pin
Dave Kreskowiak22-Oct-22 19:24
mveDave Kreskowiak22-Oct-22 19:24 
GeneralRe: C# Save DataGrid Only MultiSelected Rows to File Pin
CodaNV22-Oct-22 19:47
CodaNV22-Oct-22 19:47 
QuestionArduino canot control computer. Pin
Member 1549382322-Oct-22 11:38
Member 1549382322-Oct-22 11:38 
AnswerRe: Arduino canot control computer. Pin
OriginalGriff22-Oct-22 11:53
mvaOriginalGriff22-Oct-22 11:53 
QuestionReliable COM Port Communication Pin
Member 1495533221-Oct-22 2:36
Member 1495533221-Oct-22 2:36 
QuestionSimple Snake Game - Snake Head is not moving after ReadKey() Pin
Programmable Physics20-Oct-22 1:12
Programmable Physics20-Oct-22 1:12 
AnswerRe: Simple Snake Game - Snake Head is not moving after ReadKey() Pin
jsc4220-Oct-22 1:23
professionaljsc4220-Oct-22 1:23 

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.