Подскажите плиз,как правильно сохранять параметры DataGrida:
сохраняю так:
public static void LoadColumnsOrder(DataGridView grid, string settingsEntry)
{
if (Salary.Properties.Settings.Default.EmployeeFormDGridIndexes == null) return;
int[] displayIndexes = (int[])
Salary.Properties.Settings.Default.EmployeeFormDGridIndexes[0];
if (displayIndexes == null || displayIndexes.Length != grid.Columns.Count)
return;
for (int i = 0; i < grid.Columns.Count; i++)
grid.Columns[i].DisplayIndex = displayIndexes[i];
}
// System.Collections.ArrayList
public static void SaveColumnsOrder(DataGridView grid, string settingsEntry)
{
int[] displayIndexes = new int[grid.Columns.Count];
for (int i = 0; i < grid.Columns.Count; i++)
displayIndexes[i] = grid.Columns[i].DisplayIndex;
Salary.Properties.Settings.Default.EmployeeFormDGridIndexes = new ArrayList();
//Salary.Properties.Settings.Default.EmployeeFormDGridIndexes[0]=new int[grid.Columns.Count];
Salary.Properties.Settings.Default.EmployeeFormDGridIndexes.Add(displayIndexes);
Salary.Properties.Settings.Default.EmploeePos = 5;
}
private void EmployeeForm_Closed(object sender, FormClosedEventArgs e)
{
SaveColumnsOrder(EmployieGridView1,"EmployeeFormDGridIndexes");
Salary.Properties.Settings.Default.EmploeePos = 765;
//Salary.Properties.Settings.Default.Save();
Properties.Settings.Default.Save();
}
Но как только закрою приложение,настройки опять обнуляются! и моя переменная EmploeePos опять равна 0,а не 765
16.06.08 00:22: Перенесено модератором из '.NET' — AndrewVK
Здравствуйте, baranovda, Вы писали:
B>Почитайте про IPersistComponentSettings и ApplicationSettingsBase
Спасибо, помогло

Реализовал вот так:
sealed class FormSettings : ApplicationSettingsBase
{
[UserScopedSetting()]
public int[] EmployeeGridOrder
{
set { this["EmployeeGridOrder"] = value; }
get { return (int[])this["EmployeeGridOrder"]; }
}
дальше дело техники...