1

I am trying to make a table programatically. So far I have managed to create the table with the relevant number of rows and columns. But the problem is that the cells do not wrap around its contents residing in them.

For example, there is a textbox, the user types something in and that word appears in the table. In my case, if the user typed in 'web', it'll appear, but if they type anything larger than 7 characters, then it does not appear.

I've currently got this in my code:

tableLayoutPanel1.Controls.Clear();
tableLayoutPanel1.ColumnStyles.Clear();
tableLayoutPanel1.RowStyles.Clear();
tableLayoutPanel1.ColumnCount = getNumber();
tableLayoutPanel1.RowCount = courseObj.Level_41.Count;

I've used clear() first to clear the table because I will soon be implementing a delete button next to the words. E.g. the user can press a button next to the relevant word to delete it.

EDIT = fixed it. Had to make the autoSize of my label be true.

Tarikh
  • 29
  • 4
  • How do you add the "TextBox? Do you specify the width of the TextBox when you add to the TableLayoutPanel? – jdweng Apr 14 '16 at 14:39
  • I do it by `tableLayoutPanel1.Controls.Add(textbox)` where textbox is an instance of the textbox. Before adding it it, I have changed the text property of the textbox hence i should use the width of the textbox, right? – Tarikh Apr 14 '16 at 14:47
  • The width of the tableLayoutPanel must be larger than the width of the textbox. The panel won't automatically size to be larger than the textbox. See posting : http://stackoverflow.com/questions/30714980/flowlayoutpanel-autosize – jdweng Apr 14 '16 at 14:51
  • the width of my tablepanel is alright. Its just the width of the columns do not dyanmically resize based on the users input. Any idea on how to do that? – Tarikh Apr 14 '16 at 15:37
  • Did you look at the link? Look what is done with the button. – jdweng Apr 14 '16 at 15:42
  • Oh i see now. I made my labels' autosize property be set to true and now it works. Thanks – Tarikh Apr 14 '16 at 15:51
  • @Tarikh If you found the answer to your question please post an answer to your question describing what you did to achieve your goal and mark said answer as accepted. – Tyler Benzing Apr 14 '16 at 15:54

0 Answers0