Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8000369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:46:19+00:00 2026-06-04T15:46:19+00:00

here’s my code private void make_Book(int x, int y, string name) { #region Creating

  • 0

here’s my code

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            
}

this code is making a button every time I click on a button,, now i want to save the created button and its property so that they could appear every time application starts..

coded in C# visual studio 2010…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:46:21+00:00Added an answer on June 4, 2026 at 3:46 pm

    One solution could be to use a StringCollection 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…).

    In every line, you need to save the position and the name of a control as a string, for example like

    120;140;MyName
    

    When the user adds a new button, create an item in the StringCollection like so:

    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);
    }
    

    Then you’d need code that creates the buttons from every item in the StringCollection by reading each line, extracting the location and name and calling make_book again (not my new make_BookButtonAndStore method, as this would double the button).

    Note that you may need to create the StringCollection with the new keyword before adding the first button.

    EDIT
    To explain how to create such a setting: Go to your project properties to the “Settings” tab. Create a new setting named ButtonStringCollection, select type System.Collections.Specialized.StringCollection and scope User.

    In your form’s constructor, add the following line:

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

    Then, add the code I’ve provided above to create the buttons. Also, in the form’s Load event handler, add something like the following:

    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]);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my class: public class A{ private void doIt(int[] X, int[] Y){ //change
Here's the code in AlertTableView: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSInteger index = 12345; NSLog(@AlertTableView:
Here is a code snippet I was working with: int *a; int p =
Here is my code (Say we have a single button on the page that
Here is what I am trying to achieve in PHP: I have this string:
Here's my code: string strSQL = SELECT * from tMedia where SKU = '
Here is the code: Function getData(ByVal id As String) Dim reader As SqlClient.SqlDataReader Dim
here is code: <script type=text/javascript> function doit(){ $('table td').each(function () { if ($(this).text().trim() !=
here is the code public static final String DATE_TIME_FORMAT = yyyy-MM-dd kk:mm:ss; public static
Here is my code (seen on Google App Engine) public void doGet(HttpServletRequest request, HttpServletResponse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.