Setting up a chain

D

David

Hi,

Apologies for the title, but I am not sure what to call it or even how to
search google for it.

I want to set up a system, like so...

PageClass MyPage = new PageClass();
MyPage.WriteText = "Dave is trying to program";
MyPage.WriteText = "Dave is writing a second line";
MyPage.Tables.Add(2, 2);
MyPage.Tables.Row[0][0].WriteText = "Add something into the 1st row, 1st
column of the table I have defined";
MyPage.Tables.Row[0][1].WriteText = "Add text in the next column

I can see that the initial WriteText is just a function within the class
PageClass. However, I haven't got a clue how to do the Tables part.

In an earlier post, I thought it would be a class within a class, but
seemingly not. How do I tell PageClass that it has something called Tables,
then how do I tell Tables that it has other objects such as .Add or .Row?

What would you call what I am trying to achieve?

All help is appreciated.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
C

Clint Hill

I think what your are looking for is a class set up like this:

using System;

namespace NewsGroupHelpASPNET
{
/// <summary>
/// Summary description for MyPage.
/// </summary>
public class PageClass
{
private Table[] tables;

public PageClass()
{
this.tables[0].Rows[0].Cells[0].Text = "Hello World!";
}

public void WriteText(string textToWrite)
{

}

public Table[] Tables
{
get { return this.tables; }
set { this.tables = value; }
}
}
public class Table
{
private Row[] rows;
public Table()
{

}
public Row[] Rows
{
get { return this.rows; }
set { this.rows = value; }
}
}
public class Row
{
private Cell[] cells;
public Row()
{

}
public Cell[] Cells
{
get { return this.cells; }
set { this.cells = value; }
}
}
public class Cell
{
private string cellText;
public Cell()
{

}
public string Text
{
get { return this.cellText; }
set { this.cellText = value; }
}
}
}

Notice the classes Table, Row, Cell are all carried in a "chain" so to
speak through the use of Properties (get,set).

Is this what you meant?

Clint Hill
H3O Software
http://www.h3osoftware.com
 
D

David

Hi Clint,

I think so, though until I try and put it in place, I am not sure.

What would you call this scenario?

Best regards,
Dave Colliver.
http://www.DerbyFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


Clint Hill said:
I think what your are looking for is a class set up like this:

using System;

namespace NewsGroupHelpASPNET
{
/// <summary>
/// Summary description for MyPage.
/// </summary>
public class PageClass
{
private Table[] tables;

public PageClass()
{
this.tables[0].Rows[0].Cells[0].Text = "Hello World!";
}

public void WriteText(string textToWrite)
{

}

public Table[] Tables
{
get { return this.tables; }
set { this.tables = value; }
}
}
public class Table
{
private Row[] rows;
public Table()
{

}
public Row[] Rows
{
get { return this.rows; }
set { this.rows = value; }
}
}
public class Row
{
private Cell[] cells;
public Row()
{

}
public Cell[] Cells
{
get { return this.cells; }
set { this.cells = value; }
}
}
public class Cell
{
private string cellText;
public Cell()
{

}
public string Text
{
get { return this.cellText; }
set { this.cellText = value; }
}
}
}

Notice the classes Table, Row, Cell are all carried in a "chain" so to
speak through the use of Properties (get,set).

Is this what you meant?

Clint Hill
H3O Software
http://www.h3osoftware.com
Hi,

Apologies for the title, but I am not sure what to call it or even how to
search google for it.

I want to set up a system, like so...

PageClass MyPage = new PageClass();
MyPage.WriteText = "Dave is trying to program";
MyPage.WriteText = "Dave is writing a second line";
MyPage.Tables.Add(2, 2);
MyPage.Tables.Row[0][0].WriteText = "Add something into the 1st row, 1st
column of the table I have defined";
MyPage.Tables.Row[0][1].WriteText = "Add text in the next column

I can see that the initial WriteText is just a function within the class
PageClass. However, I haven't got a clue how to do the Tables part.

In an earlier post, I thought it would be a class within a class, but
seemingly not. How do I tell PageClass that it has something called
Tables, then how do I tell Tables that it has other objects such as .Add
or .Row?

What would you call what I am trying to achieve?

All help is appreciated.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
C

Clint Hill

Well, technically I can't think of a name, I have never called it
anything other than property recursion. But that is my language and not
necessarily accurate.

Clint Hill
H3O Software
http://www.h3osoftware.com
Hi Clint,

I think so, though until I try and put it in place, I am not sure.

What would you call this scenario?

Best regards,
Dave Colliver.
http://www.DerbyFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


I think what your are looking for is a class set up like this:

using System;

namespace NewsGroupHelpASPNET
{
/// <summary>
/// Summary description for MyPage.
/// </summary>
public class PageClass
{
private Table[] tables;

public PageClass()
{
this.tables[0].Rows[0].Cells[0].Text = "Hello World!";
}

public void WriteText(string textToWrite)
{

}

public Table[] Tables
{
get { return this.tables; }
set { this.tables = value; }
}
}
public class Table
{
private Row[] rows;
public Table()
{

}
public Row[] Rows
{
get { return this.rows; }
set { this.rows = value; }
}
}
public class Row
{
private Cell[] cells;
public Row()
{

}
public Cell[] Cells
{
get { return this.cells; }
set { this.cells = value; }
}
}
public class Cell
{
private string cellText;
public Cell()
{

}
public string Text
{
get { return this.cellText; }
set { this.cellText = value; }
}
}
}

Notice the classes Table, Row, Cell are all carried in a "chain" so to
speak through the use of Properties (get,set).

Is this what you meant?

Clint Hill
H3O Software
http://www.h3osoftware.com
Hi,

Apologies for the title, but I am not sure what to call it or even how to
search google for it.

I want to set up a system, like so...

PageClass MyPage = new PageClass();
MyPage.WriteText = "Dave is trying to program";
MyPage.WriteText = "Dave is writing a second line";
MyPage.Tables.Add(2, 2);
MyPage.Tables.Row[0][0].WriteText = "Add something into the 1st row, 1st
column of the table I have defined";
MyPage.Tables.Row[0][1].WriteText = "Add text in the next column

I can see that the initial WriteText is just a function within the class
PageClass. However, I haven't got a clue how to do the Tables part.

In an earlier post, I thought it would be a class within a class, but
seemingly not. How do I tell PageClass that it has something called
Tables, then how do I tell Tables that it has other objects such as .Add
or .Row?

What would you call what I am trying to achieve?

All help is appreciated.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
D

David

Hi again,

That is almost what I need to do, but I am struggling to understand what I
am doing myself in order to make it work.

How I envisaged it is first to create a table. If I equate this to HTML
rather than what I am trying to do, it might make it easier...

PageClass.Table.Add(2, 2);
would create the <table> tag. The 2, 2 would be put into properties so that
I couldn't accidentally add more cells than is required.

I can't visualise creating a HTML table by:
this.tables[0].Rows[0].Cells[0]
as I could end up with more than one table. (I don't appear to be explaining
myself very well. :-( )

Basically, only the row/(col/cell) will need to be indexed after I create
the table. I don't think I need to index the table itself at this point.

To add to this, I can see that you are adding the values as properties.
Ultimately, I will need to pass the table, row, cell and text definitions
into a stringbuilder set up in the earlier class. I think for this, I will
probably need some form of trigger mechanism, such as
this.tables.close();
which will then add the generated string into the stringbuilder that is
managed in WriteText()

Best regards,
Dave Colliver.
http://www.CoventryFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


Clint Hill said:
I think what your are looking for is a class set up like this:

using System;

namespace NewsGroupHelpASPNET
{
/// <summary>
/// Summary description for MyPage.
/// </summary>
public class PageClass
{
private Table[] tables;

public PageClass()
{
this.tables[0].Rows[0].Cells[0].Text = "Hello World!";
}

public void WriteText(string textToWrite)
{

}

public Table[] Tables
{
get { return this.tables; }
set { this.tables = value; }
}
}
public class Table
{
private Row[] rows;
public Table()
{

}
public Row[] Rows
{
get { return this.rows; }
set { this.rows = value; }
}
}
public class Row
{
private Cell[] cells;
public Row()
{

}
public Cell[] Cells
{
get { return this.cells; }
set { this.cells = value; }
}
}
public class Cell
{
private string cellText;
public Cell()
{

}
public string Text
{
get { return this.cellText; }
set { this.cellText = value; }
}
}
}

Notice the classes Table, Row, Cell are all carried in a "chain" so to
speak through the use of Properties (get,set).

Is this what you meant?

Clint Hill
H3O Software
http://www.h3osoftware.com
Hi,

Apologies for the title, but I am not sure what to call it or even how to
search google for it.

I want to set up a system, like so...

PageClass MyPage = new PageClass();
MyPage.WriteText = "Dave is trying to program";
MyPage.WriteText = "Dave is writing a second line";
MyPage.Tables.Add(2, 2);
MyPage.Tables.Row[0][0].WriteText = "Add something into the 1st row, 1st
column of the table I have defined";
MyPage.Tables.Row[0][1].WriteText = "Add text in the next column

I can see that the initial WriteText is just a function within the class
PageClass. However, I haven't got a clue how to do the Tables part.

In an earlier post, I thought it would be a class within a class, but
seemingly not. How do I tell PageClass that it has something called
Tables, then how do I tell Tables that it has other objects such as .Add
or .Row?

What would you call what I am trying to achieve?

All help is appreciated.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top