Click here to Skip to main content
15,565,747 members
Home / Discussions / C#
   

C#

 
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 
Having a problem with one line of code to save only a DataGrid's Rows that have been Multi-selected.
The code works correctly to save all the rows to file, however code line 04 is incorrectly formatted
to save only those rows which have been multi-selected. Appreciate any help. With thanks.

// Export DataGridView Selected Rows to Text File
TextWriter writer = new StreamWriter(FilePathName);

if (dataGridView1.SelectedRows.Count != 0)
{
    foreach (DataGridViewRow row in dataGridView1.SelectedRows)
    {
        for (int i = dataGridView1.Rows(row.Index); i++)
            {
            for (int j = 0; j < dataGridView1.Columns.Count; j++)
            {
                if (j == dataGridView1.Columns.Count - 1)
                {
                    writer.Write("\t" + dataGridView1.Rows[i].Cells[j].Value.ToString());
                }
                else
                    writer.Write("\t" + dataGridView1.Rows[i].Cells[j].Value.ToString() + "\t" + "|");
            }

            writer.WriteLine("");
        }
    }
writer.Close();


modified 23-Oct-22 0:09am.

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 
Questionget string from if statement in c# Pin
Sycho AN19-Oct-22 12:04
Sycho AN19-Oct-22 12:04 
AnswerRe: get string from if statement in c# Pin
OriginalGriff19-Oct-22 12:32
mvaOriginalGriff19-Oct-22 12:32 
GeneralRe: get string from if statement in c# Pin
Sycho AN19-Oct-22 13:24
Sycho AN19-Oct-22 13:24 
GeneralRe: get string from if statement in c# Pin
Dave Kreskowiak19-Oct-22 13:33
mveDave Kreskowiak19-Oct-22 13:33 
AnswerRe: get string from if statement in c# Pin
Gerry Schmitz19-Oct-22 15:10
mveGerry Schmitz19-Oct-22 15:10 
AnswerRe: get string from if statement in c# Pin
Pete O'Hanlon21-Oct-22 9:20
mvaPete O'Hanlon21-Oct-22 9:20 
QuestionHow to know if 2 ASCII created lines in a command prompt has the same length? Pin
Programmable Physics18-Oct-22 3:19
Programmable Physics18-Oct-22 3:19 
AnswerRe: How to know if 2 ASCII created lines in a command prompt has the same length? Pin
Richard Deeming18-Oct-22 3:35
mveRichard Deeming18-Oct-22 3:35 

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.