Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Programatically creating a table with rows (Read 2944 times)
Charter
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Feb 19th, 2007
Programatically creating a table with rows
Feb 19th, 2007 at 11:28pm
Print Post  
I would like to create a one-column table that is populated with row data:

Here is some code:

FlowChart chart = new FlowChart();
Table         table = new Table(chart);

chart.Behavior = BehaviorType.DoNothing;

table.ColumnCount = 1;
for(int i = 0; i < 10; i++)
{
       table.AddRow();
      table[0,i].Text = "Hello";
}
table.ResizeToFitText();
chart.Add(table);

However when I attempt to add the chart to a Windows Form, nothing appears.

Ideas as to where I am going wrong?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Programatically creating a table with rows
Reply #1 - Feb 20th, 2007 at 5:52am
Print Post  
Do you mean the flowchart control doesn't appear, or the table? That code has some compilation errors - maybe you haven't noticed them and ran an older version of the compiled exe -

error CS1501: No overload for method 'ResizeToFitText' takes '0' arguments

You must pass a boolean argument that specifies whether the caption text should be measured as well when calculating the table size.
  
Back to top
 
IP Logged
 
Charter
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Feb 19th, 2007
Re: Programatically creating a table with rows
Reply #2 - Feb 20th, 2007 at 4:56pm
Print Post  
Oops...sorry about forgetting the boolean. In any event, that does not seem to make any difference. So change that to:

table.ResizeToFitText(true);

After the creation code from the previous post (along with the correction above) I have this line of code in my Windows Form:

this.Controls.Add(chart);

I tried adding the Table directly, but it does not seem to derive from Control, whereas FlowChart does. Also, if I just drag a FlowChart object from the Toolbox to the form, the above instantiation code is what is generated. Nevertheless, the control does not appear on the form.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Programatically creating a table with rows
Reply #3 - Feb 20th, 2007 at 5:29pm
Print Post  
What if you set the flowChart.Bounds after adding it to the form? Also try setting flowchart.Visible and call BringToFront, or otherwise the control might remain hidden.
  
Back to top
 
IP Logged
 
Charter
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Feb 19th, 2007
Re: Programatically creating a table with rows
Reply #4 - Feb 20th, 2007 at 7:13pm
Print Post  
OK, setting chart.Bounds did the trick. It turns out that  chart.Visible was already set to True and BringToFront() did not need to be called.

It's strange though: I would have thought that the FlowChart should expand to display all tables (or boxes, etc.) added to it automatically.

More assumptions broken  Smiley. Thanks for the help.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint