S
S
Shayden2021-10-08 20:24:35
C++ / C#
Shayden, 2021-10-08 20:24:35

How can I edit the dataGridView data of a text file from the form, from which the dataGridView rows are displayed in the form?

There is a program that reads data from the text file "data.cfg" and outputs them to the dataGridvView rows.
Let's say the "data.cfg" file contains: account|password|. The dataGridView displays:

private void Form1_Load(object sender, EventArgs e)
       {
           int num2;
           ManagementObjectCollection instances = new ManagementClass("win32_processor").GetInstances();           
           string[] strArray = File.ReadAllLines("данные.cfg", Encoding.UTF8);            
           Application.ApplicationExit += new EventHandler(this.OnApplicationExit);
           for (num2 = -0; num2 < strArray.Length; num2++)
               {
                    if (strArray[num2][0] != '#')
                    {
                       string[] strArray2 = strArray[num2].Split(new char[] { '|' });                       
                       this.dataGridView1.Rows.Add();
                       this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[1].Value = strArray2[0];
                       this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[2].Value = strArray2[1];
                       string аккуант = strArray2[0];
                       string пароль = strArray2[1];
                    }
               }
        }

How to make it so that when one or more lines are selected in the form and after, when a certain key is pressed, already in the "data.cfg" file, before the account | password | (namely, before the word account) the symbol # is put / saved

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question