winform table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gilit golit
    New Member
    • Feb 2011
    • 27

    winform table

    Hi !
    I want to show a table in the user form
    Every line represents the fields of one costumer
    The user enters the values for each entry in a line.
    I have used :
    TableLayoutPane l , and put the buttons in the cells of it.

    In the user form, I don't see the table cell borders.
    usualy, it is good,
    But I wanted the user to see it in a table
    my questions are :
    1. I have defined the property "cellBorderStyl e" (of the TableLayoutPane l) : to single or any other value.
    Then it got crazy and started jumping all the time !
    Is it a Microsoft bug ? am I doing something wrong ?
    2. Is there a better standard way to do it ?
    3. a different issue:
    I dont want to copy all the buttons from line to line
    Will at work with an array of buttons ?
    How will I combine it to the code that is generated automaticall ??
  • adriancs
    New Member
    • Apr 2011
    • 122

    #2
    em.. your question is not clear.

    what do you mean by

    "it got crazy and started jumping all the time !"

    what is started jumping? and define "crazy".

    Your problem is, the DataGridView won't show up the cell border? and now you want to make it shown?

    Comment

    • gilit golit
      New Member
      • Feb 2011
      • 27

      #3
      1. The answer is WindowsGridView

      2. all the form screan was jumping. some bug (?). But it is not relevant

      Comment

      • adriancs
        New Member
        • Apr 2011
        • 122

        #4
        **Update Post(2/5/2011):
        Hi, I have forgot to add the difinition/declaration of the variable "buttons" in the code below. Please take note of that.
        **End of Update(2/5/2011)

        If you wish the user to enter values for each entry in a line, using DataGridView is a better choice.

        DataGridView is much easier to handle than using TableLayoutPane l.

        If you don't want the TableLayoutPane l to resize automatically, you can disable it by this command:

        this.tableLayou tPanel1.AutoSiz e = false;

        or you can adjust the grow and shrink properties with this:

        this.tableLayou tPanel1.AutoSiz eMode = System.Windows. Forms.AutoSizeM ode.GrowOnly;
        or
        this.tableLayou tPanel1.AutoSiz eMode = System.Windows. Forms.AutoSizeM ode.GrowAndShri nk;

        This will allow you do add button programatically into TableLayoutPane l, you can do it with this:
        Code:
        Button button1;
        
        // Update(2/5/2011): I have missed out this line
        List<Button> buttons = new List<Button>();
        // End of update(2/5/2011)
        
        void CreateNewButton()
        {
            buttons.Add(button1);
            int i = buttons.Count - 1;
            buttons[i] = new Button();
            buttons[i].Click += new EventHandler(buttons_Click);
            buttons[i].Text = "button" + buttons.Count;
            this.tableLayoutPanel1.Controls.Add(buttons[i]);
        }
        
        void buttons_Click(object sender, EventArgs e)
        {
            // Do something
        }

        Comment

        • adriancs
          New Member
          • Apr 2011
          • 122

          #5
          Hi, I have forgot to add the difinition/declaration of the variable "buttons" in the code below. Please take note of that.

          This line has been added to the code above:

          List<Button> buttons = new List<Button>();

          Comment

          Working...