Вопрос по c# – Как сохранить элементы управления, созданные во время выполнения, в Windows Forms

1

Error: User Rate Limit Exceeded

private void make_Book(int x, int y, string name)
{
    #region Creating Book

    // this code is initializing the book(button)
    Button book1 = new Button();
    Image img = button1.Image;
    book1.Image = img;
    book1.Name = name;
    book1.Height = img.Height;
    book1.Width = img.Width;
    book1.Location = new Point(44 + x, 19 + y);            
    book1.Click += new EventHandler(myClickHandler);
    groupBox1.Controls.Add(book1);

    #endregion            
}

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceededx, yError: User Rate Limit Exceededname. Adam Houldsworth
Error: User Rate Limit Exceeded Arsalan Saleem
Error: User Rate Limit Exceeded Adam Houldsworth
Error: User Rate Limit Exceeded SimpleVar
Error: User Rate Limit Exceeded jrb

Ваш Ответ

2   ответа
2

Error: User Rate Limit ExceededStringCollection user setting (EDIT: In your comment you're saying that this will not be persisted when closing the application. That's not true, as this is the entire point of using user settings...).

Error: User Rate Limit Exceeded

120;140;MyName

Error: User Rate Limit ExceededStringCollectionError: User Rate Limit Exceeded

private void make_BookButtonAndStore(int x, int y, string name)
{
    make_Book(x,y,name);

    Properties.Settings.Default.ButtonStringCollection.Add(String.Format("{0};{1};{2}", book1.Location.X, book1.Location.Y, book1.Name));
    Properties.Settings.Default.Save();
}

private void make_Book(int x, int y, string name)
{
    // this code is initializing the book(button)
    Button book1 = new Button();
    Image img = button1.Image;
    book1.Image = img;
    book1.Name = name;
    book1.Height = img.Height;
    book1.Width = img.Width;
    book1.Location = new Point(44 + x, 19 + y);            
    book1.Click += new EventHandler(myClickHandler);
    groupBox1.Controls.Add(book1);
}

Error: User Rate Limit ExceededStringCollectionError: User Rate Limit Exceededmake_bookError: User Rate Limit ExceedednotError: User Rate Limit Exceededmake_BookButtonAndStoreError: User Rate Limit Exceeded

Error: User Rate Limit ExceededStringCollectionError: User Rate Limit ExceedednewError: User Rate Limit Exceeded

EDIT
Error: User Rate Limit ExceededButtonStringCollectionError: User Rate Limit ExceededSystem.Collections.Specialized.StringCollectionError: User Rate Limit ExceededUser.

Error: User Rate Limit Exceeded

if (Properties.Settings.Default.ButtonStringCollection == null)
    Properties.Settings.Default.ButtonStringCollection = new StringCollection();

Error: User Rate Limit ExceededLoadError: User Rate Limit Exceeded

foreach (string line in Properties.Settings.Default.ButtonStringCollection)
{
    if (!String.IsNullOrWhitespace(line))
    {
        // The line will be in format x;y;name
        string[] parts = line.Split(';');
        if (parts.Length >= 3)
        {
            int x = Convert.ToInt32(parts[0]);
            int y = Convert.ToInt32(parts[1]);

            make_Book(x, y, parts[2]);
        }
    }
}
Error: User Rate Limit Exceededuser settingError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded Arsalan Saleem
Error: User Rate Limit Exceeded Arsalan Saleem
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
0

Error: User Rate Limit Exceededmake_BookError: User Rate Limit Exceededmake_BookError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded Arsalan Saleem

Похожие вопросы