C
chh.552
Guest
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace EXPORT
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
[DllImport('kernel32')]
public static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport('kernel32')]
public static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
public Form1()
{
InitializeComponent();
dataGridView1.AllowUserToAddRows = true;
dataGridView1.AutoGenerateColumns = false;
}
private void button1_Click(object sender, EventArgs e)
{
for (int j = 0; j < dataGridView1.RowCount - 1; j++)
{
if (j < = 140)
{
WritePrivateProfileString(dataGridView1[0, 0].Value.ToString(), dataGridView1[1, j].Value.ToString(), dataGridView1[2, j].Value.ToString(), @'D:\MCSC_Agent.ini');
}
else
{
WritePrivateProfileString(dataGridView1[0, 4].Value.ToString(), dataGridView1[1, j].Value.ToString(), dataGridView1[2, j].Value.ToString(), @'D:\MCSC_Agent.ini');
}
}
MessageBox.Show('EXPORT successfully to *.INI format');
}
private void button2_Click(object sender, EventArgs e) //ADD_ROW Button
{
DataGridViewButtonColumn button = new DataGridViewButtonColumn();
{
dataGridView1.Rows.Add();
}
}
//private void WriteInFile(string section, string key, string value, string path)
//{
// WritePrivateProfileString(section, key, value, path);
// if (value == null)
// {
// throw new ArgumentException();
// }
//}
I have about 10 sections.I want to make an ini file.
And if the grid view section is empty, I want to enter the value with the upper section.
If you enter url below[This is the image that is shown when you run the code above.] there is an .ini form and a grid view form that I want.
image
Continue reading...
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace EXPORT
{
public partial class Form1 : DevExpress.XtraEditors.XtraForm
{
[DllImport('kernel32')]
public static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
[DllImport('kernel32')]
public static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
public Form1()
{
InitializeComponent();
dataGridView1.AllowUserToAddRows = true;
dataGridView1.AutoGenerateColumns = false;
}
private void button1_Click(object sender, EventArgs e)
{
for (int j = 0; j < dataGridView1.RowCount - 1; j++)
{
if (j < = 140)
{
WritePrivateProfileString(dataGridView1[0, 0].Value.ToString(), dataGridView1[1, j].Value.ToString(), dataGridView1[2, j].Value.ToString(), @'D:\MCSC_Agent.ini');
}
else
{
WritePrivateProfileString(dataGridView1[0, 4].Value.ToString(), dataGridView1[1, j].Value.ToString(), dataGridView1[2, j].Value.ToString(), @'D:\MCSC_Agent.ini');
}
}
MessageBox.Show('EXPORT successfully to *.INI format');
}
private void button2_Click(object sender, EventArgs e) //ADD_ROW Button
{
DataGridViewButtonColumn button = new DataGridViewButtonColumn();
{
dataGridView1.Rows.Add();
}
}
//private void WriteInFile(string section, string key, string value, string path)
//{
// WritePrivateProfileString(section, key, value, path);
// if (value == null)
// {
// throw new ArgumentException();
// }
//}
I have about 10 sections.I want to make an ini file.
And if the grid view section is empty, I want to enter the value with the upper section.
If you enter url below[This is the image that is shown when you run the code above.] there is an .ini form and a grid view form that I want.
image
Continue reading...