Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

uitable - Create 2-D graphic table GUI component

Syntax

uitable
uitable('PropertyName1', value1,'PropertyName2',value2,...)
uitable(parent,...)
handle = uitable(...)

Description

uitable creates a 1-by-1 uitable object in the current figure window, using default property values. If no figure exists, a new figure window opens.

uitable('PropertyName1', value1,'PropertyName2',value2,...) creates a uitable object with specified property values. Properties that you do not specify assume the default property values. See the Uitable Properties reference page for information about the available properties.

uitable(parent,...) creates a uitable object as a child of the specified parent handle parent. The parent can be a figure or uipanel handle. If you also specify a different value for the Parent property, the value of the Parent property takes precedence.

handle = uitable(...) creates a uitable object and returns its handle.

After creating a uitable object, you can set and query its property values using the set and get functions.

Remarks

Users can change values in a table if the ColumnEditable property is true for the column they attempt to edit. By default, this property is false for all columns. If the column contains pop-up choices, only the current choice is visible (and not the pop-up menu control) when its column cannot be edited.

After editing a value, the edited value is displayed and the CellEditCallback fires when the user does any of the following:

When the CellEditCallback callback executes, the underlying data matrix (the table's Data property) contains the value that is displayed in the cell.

Examples

Example 1

This example creates a table in the current figure. If no figure exists, one is created.

t = uitable; 

As the table has no content (its Data property is empty), it initially displays no rows or columns. Provide data (a magic square), and set column widths to 25 pixels uniformly to make the entire table visible.

set(t,'Data',magic(10))
set(t,'ColumnWidth',{25})

The uitable ColumnWidth property is specified as a cell array. It can contain:

If a list has n entries, where n is smaller than the number of columns, it sets the first n column widths only. You can substitute 'auto' for any value in the cell array to have the width of that column calculated automatically.

Example 2

This example creates a table with a 3-by-3 data matrix. This example specifies the column names, parent, and position of the table:

f = figure('Position',[100 100 300 150]);
dat = rand(3); 
cnames = {'X-Data','Y-Data','Z-Data'}; 
t = uitable('Data',dat,'ColumnName',cnames,... 
            'Parent',f,'Position',[20 20 250 100]);

Example 3

This example creates a table with a 3-by-4 array that contains numeric, logical, and string data in the following columns:

f = figure('Position',[100 100 400 150]);
dat =  {6.125, 456.3457, true,  'Fixed';...
        6.75,  510.2342, false, 'Adjustable';...   
        7,     658.2,    false, 'Fixed';};
columnname =   {'Rate', 'Amount', 'Available', 'Fixed/Adj'};
columnformat = {'numeric', 'bank', [], {'Fixed' 'Adjustable'}}; 
columneditable =  [false false true true]; 
t = uitable('Units','normalized','Position',...
            [0.1 0.1 0.9 0.9], 'Data', dat,... 
            'ColumnName', columnname,...
            'ColumnFormat', columnformat,...
            'ColumnEditable', columneditable);
              

For more information about working with uitables, see the following examples in the MATLAB Creating Graphical User Interfaces documentation:

See Also

figure, format, inspect, uicontrol, uimenu, uipanel

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS