Prev: memmapfile error
Next: I cant solve this error in ANFIS
From: Thomas Bernacki on 17 Apr 2007 16:58 Hi, I am trying to use the MSFlexGrid ActiveX control, and I have it working for the most part - setting the numbers of rows and columns, putting data in, etc. However, I've tried to set the column widths and I can't figure out how to do this. The MSDN database says something like this should set the width of column 1 to 1000: htable.ColWidth(1)=1000 but I get an error; in fact that property isn't even listed if I do get(htable). It does list CellWidth however, so I tried that. Here's the line of code I used: htable.CellWidth=1000 but I get: ??? Invoke Error: Incorrect number of arguments If I try htable.CellWidth(1)=1000 I get the same error. Here's a bit of code I've been playing with to try to figure this out. The very last line is the one giving me trouble, I've tried everything I can think of. Does anyone have any ideas? %instantiate grid displaying data htable = ... actxcontrol('MSFlexGridLib.MSFlexGrid.1',... [20,20,400,200]); htable.Rows=5; htable.Cols=5; htable.FixedRows=1; htable.FixedCols=2; % insert the header row htable.Row=0; htable.Col=0; htable.Text='Long Text That Doesn't Fit'; htable.Col=1; htable.Text='Text'; htable.Col=2; htable.Text='10'; htable.Col=3; htable.Text='20'; htable.Col=4; htable.Text='30'; % insert header columns for i=1:4 for j=1:2 htable.Row=i; htable.Col=j-1; htable.Text=sprintf('%d',i*j); end end for i=1:4 for j=3:5 htable.Row=i; htable.Col=j-1; htable.Text=sprintf('%0.0f',rand*100); end end htable.CellWidth=1800 Thanks in advance, Thomas Bernacki
From: Yair Altman on 17 Apr 2007 19:14 Try methodsview(htable) or methods(htable,'-full') to see the full method signatures. Also look at msdn for online help (that was the first Google link - come on!): <http://msdn2.microsoft.com/en-us/library/aa228849(VS.60).aspx> Yair Altman
From: Thomas Bernacki on 18 Apr 2007 11:01 Hi, I did in fact go to the MSDN page first... that's where I got the details on the method in the first place! And most of the stuff that was there did indeed work fine - setting numbers of columns, rows, putting data in, etc. It was just the ColWidth that was giving me the unusual error. I actually tried the MSFlexGrid control in VB, and the command htable.ColWidth(0)=2000 works fine (that's the way MSDN says to do it with MSFlexGrid). In Matlab though when I run that command it tells me: ??? No public field ColWidth exists for class COM.MSFlexGridLib_MSFlexGrid_1. I have tried everything, and I can't get the thing to work. I was hoping that perhaps someone had actually tried it in Matlab and gotten it to work, or whether this is actually some kind of bug. I'm running Matlab R14 SP3 by the way. Thanks! Thomas Bernacki Yair Altman wrote: > > > Try methodsview(htable) or methods(htable,'-full') to see the full > method signatures. Also look at msdn for online help (that was the > first Google link - come on!): <http://msdn2.microsoft.com/en-us/library/aa228849(VS.60).aspx> > > Yair Altman
From: Richard Lang on 18 Apr 2007 11:27 Thomas Bernacki wrote: > Hi, > > I did in fact go to the MSDN page first... that's where I got the > details on the method in the first place! And most of the stuff that > was there did indeed work fine - setting numbers of columns, rows, > putting data in, etc. > It was just the ColWidth that was giving me the unusual error. I > actually tried the MSFlexGrid control in VB, and the command > > htable.ColWidth(0)=2000 > > works fine (that's the way MSDN says to do it with MSFlexGrid). In > Matlab though when I run that command it tells me: > ??? No public field ColWidth exists for class > COM.MSFlexGridLib_MSFlexGrid_1. > > I have tried everything, and I can't get the thing to work. I was > hoping that perhaps someone had actually tried it in Matlab and > gotten it to work, or whether this is actually some kind of bug. I'm > running Matlab R14 SP3 by the way. > > Thanks! > Thomas Bernacki > > Yair Altman wrote: >> >> Try methodsview(htable) or methods(htable,'-full') to see the full >> method signatures. Also look at msdn for online help (that was the >> first Google link - come on!): <http://msdn2.microsoft.com/en-us/library/aa228849(VS.60).aspx> >> >> Yair Altman Thomas, In Matlab, COM properties that require an argument to get or set them (in this case the column index) can only be set using the "set" command. This should work: set(htable, 'ColWidth', 0, 1800); Richard
From: Yair Altman on 18 Apr 2007 22:24
I see... A while back I used MSComctlLib.ListViewCtrl.2 and in that case the ColWidth was set when I added column headers via one of the params (like in your case it was in the 1000's). In run-time, the column width was modified like this: hColHeaders = get(hActiveX,'ColumnHeaders'); for idxHeader = 1 : hColHeaders.Count hColHeaders.Item(idxHeader).Width = newWidth; end hope it helps Yair |