From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Add Row in table and copy the properties from previous row

Hello,

i have a table with just one row (and 7 columns). The cells (columns) are
all of different types, f.e. ring, numeric, string.....On runtime the user
can add more rows to the table. I'm looking for a function to copy a row
with all the cell propertis (cell type, format, text style....) and insert
as a new row. Is there an easy way to do this?

Thanks

Norbert


0 Kudos
Message 1 of 9
(5,137 Views)

Supposing column properties are not changing at runtime from the default, simply adding a row with

  InsertTableRows (..., ..., ..., ..., VAL_USE_MASTER_CELL_TYPE);

automatically creates a new row with default settings for every column. For this to work, the table must be set incolumn mode either programmatically or in the UIR editor.

 

As per copying values from a row to another, you could use clipboard functions for table as described in this thread.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 9
(5,133 Views)
Thanks Roberto,

i already used InsertTableRows with VAL_USE_MASTER_CELL_TYPE, but i dont
understand what is meant by default settings. At program start there is
already one row defined and i want the settings of the table cells of the
first row to be "default". In the first row the first column is a ring
(already filled with som values), the second is numeric, the third is
string.....the text style of all cells is set to CENTER CENTER ....... And i
want the next rows to look the same, and have the same contens as the first
row (my default row).
But using InsertTableRows with VAL_USE_MASTER_CELL_TYPE doesnt work in that
way.....

Any other idea....?

Norbert.






"Roberto Bozzolo" <x@no.email> schrieb im Newsbeitrag
news:1271767213927-1114670@exchange.ni.com...
> Supposing column properties are not changing at runtime from the default,
> simply adding a row with InsertTableRows (..., ..., ..., ...,
> VAL_USE_MASTER_CELL_TYPE);automatically creates a new row with default
> settings for every column. For this to work, the table must be set
> incolumn mode either programmatically or in the UIR editor. As per copying
> values from a row to another, you could use clipboard functions for table
> as described in <a
> href="http://forums.ni.com/ni/board/message?board.id=180&amp;view=by_date_descending&amp;message.id=38863#..."
> target="_self">this thread</a>.


0 Kudos
Message 3 of 9
(5,124 Views)

Norbert,

 

Roberto's method allows you to create your new cells with the cell attributes that you have defined for each column. Once you define these attributes by configuring each column in the UI Editor (Edit Table>>Edit Column>>Edit Default Cell Values), you can ensure that each new cell created under that column inherits those attributes. By attributes, I'm referring to items such as the cell type, or the text style.

 

Sadly, however, you can't inherit the cell values themselves.

 

One thing you could do is to go ahead and create the new cells and then use the functions ClipboardGetTableVals and ClipboardPutTableVals to copy the values from the first row to the new row. However, you will still have a problem with your ring cells, since the entire list of items that each ring cell holds is not considered an attribute (therefore, you can't define it ahead of time in the column) but it also is not copied to the clipboard. Only the current value is copied, I believe. So you'll have to recreate this list for new ring cells each time.

 

I'm sorry that this isn't as easy as it should be...

 

Luis

 

Message 4 of 9
(5,113 Views)
Thank you Luis,

thats exactly how i thought it shoul work. I created a table with 7 columns
and 1 Row and in the UI Editor i configured each column. The first column is
set to ring, second colum is a set to numeric (default val 0.0000), double,
with the precision 4 and the text justification set to CENTER CENTER. On
runtime the user pushes a button that calls the function
InsertTableRows(panel, PRUEFKREIS_TABLE, -1, 1, VAL_USE_MASTER_CELL_TYPE);
That there are no default values in the new line is ok following your
explanation, but when i enter a value in the second column of the new row i
expect to get it formated with precision 4 and jaustification CENTER CENTER,
but that doesnt work. If i enter a 2 i expect to get 2.0000 in the center of
the cell, but i just get 2 in the upper left corner.

i'm using LabWindows/CVI 2009 Version 9.1.0 (427).

Any idea what i'm doin wrong ? The table mode is set to column. I also
removed the ring columns to test if they cause the probplem, but still got
the same error.

Norbert


"LuisG" <x@no.email> schrieb im Newsbeitrag
news:1271783426419-1115012@exchange.ni.com...
> Norbert, Roberto's method allows you to create your new cells with the
> cell attributes that you have defined for each column. Once you define
> these attributes by configuring each column in the UI Editor (Edit
> Table&gt;&gt;Edit Column&gt;&gt;Edit Default Cell Values), you can ensure
> that each new cell created under that column inherits those attributes. By
> attributes, I'm referring to items such as the cell type, or the text
> style. Sadly, however, you can't inherit the cell values themselves. One
> thing you could do is to go ahead and create the new cells and then use
> the functions ClipboardGetTableVals and ClipboardPutTableVals to copy the
> values from the first row to the new row. However, you will still have a
> problem with your ring cells, since the entire list of items that each
> ring cell holds is not considered an attribute (therefore, you can't
> define it ahead of time in the column) but it also is not copied to the
> clipboard. Only the current value is copied, I believe. So you'll have to
> recreate this list for new ring cells each time. I'm sorry that this isn't
> as easy as it should be... Luis


0 Kudos
Message 5 of 9
(5,093 Views)

Norbert, are you sure you formatted the column (Edit table >> Choose column >> Edit column >> Edit default cell values) and not individual cells in the first row (Edit table >> Select a cell>> Edit cell in the lower right corner of the panel)?

If you edit the column default values they automatically reflecs on new cells. If you are editing the column defaults after creating the first row, when you terminate the function CVI will ask you"Would you like to apply those changes to the existing cell(s) of this column?".

 

Anyway, InsertTableRows acts exactly as the Insert Row button in table edit panel: if adding a new row maintains the attributes you have correctly set column defaults, otherways you haven't: it can be tested just to be sure the application will work correctly at runtime.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 9
(5,085 Views)
Roberto,

yes, thats what i did wrong, i used edit cell in the lower right corner.
But even edit column -> edit default cell values doesn't seem to work,
because the new row is still not formatted the way i want (the ring is not a
ring, but a num, the precision is not set to 4 ...... no idea what i'm still
doing wrong.
So i decided to do it programatically. By adding a new row i use
SetTableCellAttribute to set up the new row as needed.

Thanks for your help

Norbert


"Roberto Bozzolo" <x@no.email> schrieb im Newsbeitrag
news:1271857214271-1115673@exchange.ni.com...
> Norbert, are you sure you formatted the column (Edit table &gt;&gt; Choose
> column &gt;&gt; Edit column &gt;&gt; Edit default cell values) and not
> individual cells in the first row (Edit table &gt;&gt; Select a
> cell&gt;&gt; Edit cell in the lower right corner of the panel)?If you edit
> the column default values they automatically reflecs on new cells. If you
> are editing the column defaults after creating the first row, when you
> terminate the function CVI will ask you"Would you like to apply those
> changes to the existing cell(s) of this column?". Anyway, InsertTableRows
> acts exactly as the Insert Row button in table edit panel: if adding a new
> row maintains the attributes you have correctly set column defaults,
> otherways you haven't: it can be tested just to be sure the application
> will work correctly at runtime.


0 Kudos
Message 7 of 9
(5,071 Views)

Hi Norbert,

 

I realize that by now you have already worked around this problem, but it's still bothering me a bit that this didn't work for you. I'm wondering if there might some bug in CVI that's causing this.

 

If you still have your .uir, how do you feel about sending it to me, so that I could investigate further? You could attach it here in a post, or if you'd rather not have it out in public, you could upload it to our secure ftp site.

 

Luis

NI

0 Kudos
Message 8 of 9
(5,060 Views)
Thank you Luis,

right now i have to go on with my actual project, but sure i appreciate that
you will investigate further an i will send you my uir within the next days.
On another project i also created a table and before i inserted any row i
created the columns and set the default configuration for each column. When
i add a new row than, it seems to be formatted the way i set the default
values, so it seems to work right. Maybe the trouble with my other table is
that i lready created a row, before i changed the default settings for each
column...... but thats just a guess..... As i said before, right now i'm
running out of time, but i will contact you next week.

Thank you

Norbert


"LuisG" <x@no.email> schrieb im Newsbeitrag
news:1271956230275-1116856@exchange.ni.com...
> Hi Norbert, I realize that by now you have already worked around this
> problem, but it's still bothering me a bit that this didn't work for you.
> I'm wondering if there might some bug in CVI that's causing this. If you
> still have your .uir, how do you feel about sending it to me, so that I
> could investigate further? You could attach it here in a post, or if you'd
> rather not have it out in public, you could upload it to our <a
> href="ftp://ftp.ni.com/incoming/" target="_self">secure ftp site.</a>
> LuisNI


0 Kudos
Message 9 of 9
(5,048 Views)