void visiblecolumns() { Settings1 ps = Settings1.Default; for (int i = 0; i < kolvo_stolb; i++) { log.Add(ps.spisotobrstolb + " " + ps.spisindex + " " + ps.spiswidth); if (i >= ps.spisotobrstolb.Length) { ps.spisotobrstolb += "1"; } if (i >= ps.spisindex.Split(';').Length) { ps.spisindex += ";" + i; } if (i >= ps.spiswidth.Split(';').Length) { ps.spiswidth += ";1"; } lb1.Columns[i].Visibility = ps.spisotobrstolb[i] == '1' ? Visibility.Visible : Visibility.Collapsed; lb1.Columns[i].DisplayIndex = Convert.ToInt32(ps.spisindex.Split(';')[i]); lb1.Columns[i].Width = new DataGridLength(double.Parse(ps.spiswidth.Split(';')[i] == "Auto" ? "1": ps.spiswidth.Split(';')[i], CultureInfo.InvariantCulture), DataGridLengthUnitType.Star); } ps.Save(); }
private void Button_Click_1(object sender, RoutedEventArgs e) { string itog = ""; foreach (spissettings spiscolum in spiscolumn) { itog += spiscolum.IsSelected ? '1' :'0'; } Settings1 ps = Settings1.Default; ps.spisotobrstolb = itog; ps.Save(); Close(); }
void save_setting() { Settings1 ps = Settings1.Default; ps.Top = this.Top; ps.Left = this.Left; ps.proporc = proporc.Width.Value; if (this.WindowState == WindowState.Maximized) { ps.SizeToContent = 1; } else { ps.SizeToContent = 0; ps.Width = this.Width; ps.Height = this.Height; } //запомним порядок колонок string spisindex = ""; string spiswidth = ""; try { foreach (var sad in lb1.Columns) { spisindex += sad.DisplayIndex + ";"; spiswidth += (sad.Width.ToString().Equals("*") ? "1" : sad.Width.ToString().Trim('*')) + ";"; } } catch { } spisindex = spisindex.Trim(';'); spiswidth = spiswidth.Trim(';'); ps.spiswidth = spiswidth; ps.spisindex = spisindex; ps.Save(); }