Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Resize uitable

Subject: Resize uitable

From: Robin

Date: 21 Aug, 2010 07:55:16

Message: 1 of 6

Hi Matlab users

I have a GUI with a uitable. When I run the code under and try to maximize the GUI window the table also resize, but now the width and heigh of the columns are not resized.I have used normalized units. How do I make sure it also resize?

f=figure('name','',...
    'numbertitle','off',...
    'menubar','none',...
    'color',[0.85, 0.85, 0.85],...
    'units','normalized',...
    'position',[0 0.1 0.95 0.87]);


ht5=uicontrol('style','text',...
    'units','normalized',...
    'position',[0.46,0.15,0.3 0.1],...
    'backgroundcolor',col,...
    'string','',...
    'HorizontalAlignment','center',...
    'fontsize',10);


Data={1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27}
dat = Data';
cnames = {''};
rnames = {''};

T = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
            'RowName',rnames,'Position',[550 235 532 479],'backgroundcolor',col,'RowStriping','on',...
            'ColumnWidth',{500},'units','Normalized');
        
   set([ht5],'string','')
   bongo='Price'
   set(ht5,'string',bongo)

Best Regards

Robin

Subject: Resize uitable

From: Naresh Pai

Date: 21 Aug, 2010 20:08:03

Message: 2 of 6

"Robin " <robinh887@hotmail.com> wrote in message <i4o0p4$1bc$1@fred.mathworks.com>...
> Hi Matlab users
>
> I have a GUI with a uitable. When I run the code under and try to maximize the GUI window the table also resize, but now the width and heigh of the columns are not resized.I have used normalized units. How do I make sure it also resize?
>
> f=figure('name','',...
> 'numbertitle','off',...
> 'menubar','none',...
> 'color',[0.85, 0.85, 0.85],...
> 'units','normalized',...
> 'position',[0 0.1 0.95 0.87]);
>
>
> ht5=uicontrol('style','text',...
> 'units','normalized',...
> 'position',[0.46,0.15,0.3 0.1],...
> 'backgroundcolor',col,...
> 'string','',...
> 'HorizontalAlignment','center',...
> 'fontsize',10);
>
>
> Data={1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27}
> dat = Data';
> cnames = {''};
> rnames = {''};
>
> T = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
> 'RowName',rnames,'Position',[550 235 532 479],'backgroundcolor',col,'RowStriping','on',...
> 'ColumnWidth',{500},'units','Normalized');
>
> set([ht5],'string','')
> bongo='Price'
> set(ht5,'string',bongo)
>
> Best Regards
>
> Robin

Robin,

The units property of uitable should be placed before the position property.

> T = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
> 'RowName',rnames,'units','Normalized','Position',[550 235 532 479],'backgroundcolor',col,'RowStriping','on',...
> 'ColumnWidth',{500});
Hope that helps.

Naresh

Subject: Resize uitable

From: Robin

Date: 21 Aug, 2010 21:19:03

Message: 3 of 6

"Naresh Pai" <npai@uark.edu> wrote in message <i4pbn3$177$1@fred.mathworks.com>...
> "Robin " <robinh887@hotmail.com> wrote in message <i4o0p4$1bc$1@fred.mathworks.com>...
> > Hi Matlab users
> >
> > I have a GUI with a uitable. When I run the code under and try to maximize the GUI window the table also resize, but now the width and heigh of the columns are not resized.I have used normalized units. How do I make sure it also resize?
> >
> > f=figure('name','',...
> > 'numbertitle','off',...
> > 'menubar','none',...
> > 'color',[0.85, 0.85, 0.85],...
> > 'units','normalized',...
> > 'position',[0 0.1 0.95 0.87]);
> >
> >
> > ht5=uicontrol('style','text',...
> > 'units','normalized',...
> > 'position',[0.46,0.15,0.3 0.1],...
> > 'backgroundcolor',col,...
> > 'string','',...
> > 'HorizontalAlignment','center',...
> > 'fontsize',10);
> >
> >
> > Data={1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27}
> > dat = Data';
> > cnames = {''};
> > rnames = {''};
> >
> > T = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
> > 'RowName',rnames,'Position',[550 235 532 479],'backgroundcolor',col,'RowStriping','on',...
> > 'ColumnWidth',{500},'units','Normalized');
> >
> > set([ht5],'string','')
> > bongo='Price'
> > set(ht5,'string',bongo)
> >
> > Best Regards
> >
> > Robin
>
> Robin,
>
> The units property of uitable should be placed before the position property.
>
> > T = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
> > 'RowName',rnames,'units','Normalized','Position',[550 235 532 479],'backgroundcolor',col,'RowStriping','on',...
> > 'ColumnWidth',{500});
> Hope that helps.
>
> Naresh

Hi Naresh

It did not work. I think the problem is the columnwidth it cannot be normalized. I tried:

f=figure('name','',...
    'numbertitle','off',...
    'menubar','none',...
    'color',[0.85, 0.85, 0.85],...
    'units','normalized',...
    'position',[0 0.1 0.95 0.87]);

col=get(f,'color');



ht5=uicontrol('style','text',...
    'units','normalized',...
    'position',[0.46,0.15,0.3 0.1],...
    'backgroundcolor',col,...
    'string','',...
    'HorizontalAlignment','center',...
    'fontsize',10);


Data={1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27}
dat = Data';
cnames = {''};
rnames = {''};

T = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
            'RowName',rnames,'units','Normalized','Position',[0.4 0.25 0.483 0.525],'backgroundcolor',col,'RowStriping','on',...
            'ColumnWidth',{610});
        
   set([ht5],'string','')
   bongo='Price'
   set(ht5,'string',bongo)

Best Regards

Robin

Subject: Resize uitable

From: Robin

Date: 25 Aug, 2010 18:26:20

Message: 4 of 6

"Robin " <robinh887@hotmail.com> wrote in message <i4pfs7$nos$1@fred.mathworks.com>...
> "Naresh Pai" <npai@uark.edu> wrote in message <i4pbn3$177$1@fred.mathworks.com>...
> > "Robin " <robinh887@hotmail.com> wrote in message <i4o0p4$1bc$1@fred.mathworks.com>...
> > > Hi Matlab users
> > >
> > > I have a GUI with a uitable. When I run the code under and try to maximize the GUI window the table also resize, but now the width and heigh of the columns are not resized.I have used normalized units. How do I make sure it also resize?
> > >
> > > f=figure('name','',...
> > > 'numbertitle','off',...
> > > 'menubar','none',...
> > > 'color',[0.85, 0.85, 0.85],...
> > > 'units','normalized',...
> > > 'position',[0 0.1 0.95 0.87]);
> > >
> > >
> > > ht5=uicontrol('style','text',...
> > > 'units','normalized',...
> > > 'position',[0.46,0.15,0.3 0.1],...
> > > 'backgroundcolor',col,...
> > > 'string','',...
> > > 'HorizontalAlignment','center',...
> > > 'fontsize',10);
> > >
> > >
> > > Data={1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27}
> > > dat = Data';
> > > cnames = {''};
> > > rnames = {''};
> > >
> > > T = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
> > > 'RowName',rnames,'Position',[550 235 532 479],'backgroundcolor',col,'RowStriping','on',...
> > > 'ColumnWidth',{500},'units','Normalized');
> > >
> > > set([ht5],'string','')
> > > bongo='Price'
> > > set(ht5,'string',bongo)
> > >
> > > Best Regards
> > >
> > > Robin
> >
> > Robin,
> >
> > The units property of uitable should be placed before the position property.
> >
> > > T = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
> > > 'RowName',rnames,'units','Normalized','Position',[550 235 532 479],'backgroundcolor',col,'RowStriping','on',...
> > > 'ColumnWidth',{500});
> > Hope that helps.
> >
> > Naresh
>
> Hi Naresh
>
> It did not work. I think the problem is the columnwidth it cannot be normalized. I tried:
>
> f=figure('name','',...
> 'numbertitle','off',...
> 'menubar','none',...
> 'color',[0.85, 0.85, 0.85],...
> 'units','normalized',...
> 'position',[0 0.1 0.95 0.87]);
>
> col=get(f,'color');
>
>
>
> ht5=uicontrol('style','text',...
> 'units','normalized',...
> 'position',[0.46,0.15,0.3 0.1],...
> 'backgroundcolor',col,...
> 'string','',...
> 'HorizontalAlignment','center',...
> 'fontsize',10);
>
>
> Data={1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27}
> dat = Data';
> cnames = {''};
> rnames = {''};
>
> T = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
> 'RowName',rnames,'units','Normalized','Position',[0.4 0.25 0.483 0.525],'backgroundcolor',col,'RowStriping','on',...
> 'ColumnWidth',{610});
>
> set([ht5],'string','')
> bongo='Price'
> set(ht5,'string',bongo)
>
> Best Regards
>
> Robin

Anybody that can help?

Best Regards

Robin

Subject: Resize uitable

From: Yair Altman

Date: 25 Aug, 2010 18:49:04

Message: 5 of 6

"Robin " <robinh887@hotmail.com> wrote in message <i4o0p4$1bc$1@fred.mathworks.com>...
> Hi Matlab users
>
> I have a GUI with a uitable. When I run the code under and try to maximize the GUI window the table also resize, but now the width and height of the columns are not resized. I have used normalized units. How do I make sure it also resizes?


uitable row height and column width are unrelated to the table's dimensions, since a table can contain any number of rows/cols. This is why the table has scrollbars. For this reason, resizing the table only affects the so-called scrollbars viewport, and does *NOT* affect any internal aspect such as row height or column width.

You can trap the resizing callback and programmatically modify the row height and column width depending on the new table size. However, I suggest to NOT do this because most users are used to the current behavior, not just in Matlab but in most GUI-based applications.

Yair Altman
http://UndocumentedMatlab.com

Subject: Resize uitable

From: Robin

Date: 7 Sep, 2010 14:25:22

Message: 6 of 6

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message <i53oj0$gdd$1@fred.mathworks.com>...
> "Robin " <robinh887@hotmail.com> wrote in message <i4o0p4$1bc$1@fred.mathworks.com>...
> > Hi Matlab users
> >
> > I have a GUI with a uitable. When I run the code under and try to maximize the GUI window the table also resize, but now the width and height of the columns are not resized. I have used normalized units. How do I make sure it also resizes?
>
>
> uitable row height and column width are unrelated to the table's dimensions, since a table can contain any number of rows/cols. This is why the table has scrollbars. For this reason, resizing the table only affects the so-called scrollbars viewport, and does *NOT* affect any internal aspect such as row height or column width.
>
> You can trap the resizing callback and programmatically modify the row height and column width depending on the new table size. However, I suggest to NOT do this because most users are used to the current behavior, not just in Matlab but in most GUI-based applications.
>
> Yair Altman
> http://UndocumentedMatlab.com


Thanks Yair for your explanation.

Best Regards

Robin

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us