Author Topic: Adding a row to a table  (Read 11568 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
Re: Adding a row to a table
« Reply #15 on: March 16, 2006, 09:33:30 PM »
Thanks Mick, it does not work... I open a new topic on the arx forum, and removed the function from here.

Glenn R

  • Guest
Re: Adding a row to a table
« Reply #16 on: March 16, 2006, 10:53:12 PM »
Luis,

You may want to add this:

pSomeTablePointer->generateLayout();

Kerry, this:
Code: [Select]
Table tbl = (Table)trans.GetObject(entRes.ObjectId, OpenMode.ForWrite, true);


is probably better written like this (how I do it now):
Code: [Select]
Table tbl = trans.GetObject(entRes.ObjectId, OpenMode.ForWrite, true) as Table;

The reason..............no exception will be thrown if the direct cast fails, which it can do.
All you should do then is check tbl != null.

Just an observation.

Cheers,
Glenn.




Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Adding a row to a table
« Reply #17 on: March 17, 2006, 12:25:03 AM »
.......
Code: [Select]
Table tbl = (Table)trans.GetObject(entRes.ObjectId, OpenMode.ForWrite, true);

is probably better written like this (how I do it now):
Code: [Select]
Table tbl = trans.GetObject(entRes.ObjectId, OpenMode.ForWrite, true) as Table;

The reason..............no exception will be thrown if the direct cast fails, which it can do.
All you should do then is check tbl != null.

Just an observation.

Cheers,
Glenn.

interesting .. very elegant !

thanks Glenn.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Joel Roderick

  • Guest
Re: Adding a row to a table
« Reply #18 on: March 17, 2006, 09:28:24 AM »
LE,
Isn't there an udpate method?  Maybe regen the drawing?

LE

  • Guest
Re: Adding a row to a table
« Reply #19 on: March 17, 2006, 09:57:36 AM »
LE,
Isn't there an udpate method?  Maybe regen the drawing?

Hi Joel;

Have a look into here:

http://www.theswamp.org/index.php?topic=9125.0

The code is now working... it is in ObjectARX


Luis Esquivel

MickD

  • King Gator
  • Posts: 3637
  • (x-in)->[process]->(y-out) ... simples!
Re: Adding a row to a table
« Reply #20 on: July 03, 2006, 08:23:25 PM »
Let it be said that tables s*%k hard!

Well, it's ok now I've worked them out (for my needs anyhow) but what an effort! There is very little info on the implementation of these things with code.
Anyway, for those interested here's what works for me.
Code: [Select]
Table mTable = tr.GetObject(entRes.ObjectId,OpenMode.ForWrite)as Table;

int j = 1;
string item = "n/a";
foreach(DataRow dr in dt.Rows)
{
if(dr["itemno"].ToString() == "tbc")
{
item = j.ToString();
j++;
}
else
{
item = dr["itemno"].ToString();
}
mTable.InsertRows(2,1.0,1);
ed.WriteMessage("\n" + item + " " + dr["qty"]);
mTable.SetTextString(2, 0, item );
mTable.SetTextString(2, 1, dr["qty"].ToString());
mTable.SetTextString(2, 2, dr["material"].ToString());
mTable.SetTextString(2, 3, dr["length"].ToString());
mTable.SetTextString(2, 4, dr["mass"].ToString());
}

Note I have a title and header rows in my table style. And the output -
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien