Pointing on specific cell in uitable of Matlab from the code - matlab-uitable

Does somebody know, how to point on specific cell in uitable of Matlab from the code (like it's done for listbox: set(handles.listbox1, 'Value', 25) - pointing on row 25 of listbox) ?

Related

Excel ActiveX ListBox Shrinks with each update

I have a set of linked subs which work like this:
A user types into an ActiveX TextBox
A Change Event in that TextBox calls a sub in a Module
That Module sub drives updating a named range in a sheet
The range value drives updating a table of Excel cells that uses lookup functions based on the range value
The table values are copied and pasted to a another range (to eliminate links to formulas)
That pasted range is put into a ListBox using this (props to Rory for his patience):
ActiveSheet.ListBox1.List = Sheets("Search Criteria Control").Range("G1:G21").Value
The result is that for every character the user types in the TextBox the ListBox is updated.
The problem I have is that the ListBox shrinks a bit with every keystroke in the TextBox referred to in #1 above. Is this normal behavior and I'm misusing ListBoxes, am I doing something wrong or do I need to respecify the dimensions of the ListBox every time it is updated with something like this?
ActiveSheet.OLEObjects("ListBox1").Top = 35
ActiveSheet.OLEObjects("ListBox1").Left = 650
ActiveSheet.OLEObjects("ListBox1").Width = 550
ActiveSheet.OLEObjects("ListBox1").Height = 610
Thanks in advance for any thoughts on this.
I was having trouble with the same thing. My ActiveX listbox would move around on the sheet and change size for no reason that I could see.
While I did go ahead and develop some code to reset size and coordinates, that wasn't satisfactory since there had to be a mechanism to trigger that code - something I didn't want to burden end-users with.
I found a better answer in another user forum. There's a Listbox Property called IntegralHeight whose default property is True - something to do with screen resolution and optimal display of listbox contents. Simply set that to False. I did that with some ActiveX boxes that were giving me fits, and I was able to disable the "adjustment" code and, so far, so good!

set cell focus in data grid view .NET

In my datagridview (Mydgv1),I want to set fourth cell into focus and edit it, after i leave the first cell.
On first cell's leave event , i have written the code to focus the 4th cell, it comes into focus, but there is no cursor in it, and then the focus shifts to second cell and second cell becomes blue(by default highlighted cell in datagridviews). Please post some code for it. So far I have tried this.
Mydgv1.ClearSelection()
Mydgv1.CurrentRow.Cells(3).Selected = True
Mydgv1.BeginEdit(False)
BeginEdit will only have effect on the current cell (marked by the CurrentCell property of the DataGridView object). Selecting it won't help (especially since you can select multiple cells in some DataGridView configurations). Instead try this:
Dim ColumnIndex As Integer = 3
Mydgv1.CurrentCell = Mydgv1.CurrentRow.Cells(ColumnIndex)
Mydgv1.BeginEdit(False)

Handling tableview cell selection from other view controllers

I have a tableView with custom table cells which displays a list of sayings. While selecting a cell (say "saying1") from the tableView, the cell will get selected and will moves to next view controller for showing an explanation of selected saying. In that view controller two buttons "Previous" and "Next" are there for navigating to previous and next saying. So user may select next button for seeing next saying (say "saying2"). But the problem here is, In this stage when i navigate back to my tableview, the cell selected will be "saying1" not "saying2".
In order to solve this problem, i collected the currently selected sayings ("saying2's") index from array (ie,index will be 1) and passed it to the previous tableView through segue and converted that value into NSIndexpath. After this step i don't know what to do. Please help me in solving this.
You can specifically select a cell by calling following method present in UITableView class :
selectRowAtIndexPath:animated:scrollPosition:
refere to following link : https://developer.apple.com/library/ios/documentation/uikit/reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableView/selectRowAtIndexPath:animated:scrollPosition:

Array with selectItemAtIndexPath of a UICollectionView

I'm trying to programmatically select cells in a UICollection view. I'm new to Obj-C and I'm not quite sure how to use the selectItemAtIndexPath property. I can grab an array of the images the user has previously selected. It is just an array of numbers corresponding to named images. But I'm not sure how to use that information with selectItemAtIndexPath.
I've looked for examples of someone using
- (void)selectItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UICollectionViewScrollPosition)scrollPosition
But I'm not sure how to use it with my UICollectionView so I can have the right cells selected when the view loads and thus be highlighted. I have multiple selection on.
You should call selectItemAtIndexPath: for each cell you want to highlight, like so:
[self.collectionView selectItemAtIndexPath:path animated:NO scrollPosition:UICollectionViewScrollPositionNone]
Note that for one item (and one only!) you probably want to set the animated property to YES and provide a scroll position (one item only because otherwise you're going to be making a lot of needless animation calls).
You'll first need to get the index paths of the cells you want to select. The index path consists of two numbers: the section the cell is in and the row number (or order, if your collection view doesn't have rows) of the cell inside that section.
If you store the index paths of the cells the user has selected in an array then you can just iterate through. Otherwise you'll need to find the index path out, using a UICollectionView method such as indexPathForCell.

Can't create an NSImage?

Whenever I do:
xxx = [NSImage imageNamed:#"Package.png"];
xxx loads but it's width and height remain 0. And whenever I try loading it into an NSImageCell I get this error:
NSImageCell's object value must be an NSImage.
Can someone help me out? I've never had this problem before.
Edit: Sorry, I've missed this bit out. So when I do it in the data source delegate it does not work and it shows the above error after 'return cell;'.
NSImageCell* cell = [[NSImageCell alloc] init];
[cell setObjectValue:xxx]; // Using imageNamed doesn't help either
Edit 2: This is becoming aggravating. I don't understand what happened but the image loads height and width properly, but it still complains when I add it to an NSImageCell.
I see—so the table view aspect is relevant after all.
As the data source, your job is to return (and receive, in the case of user editing) the object values for the cells in the columns.
But you're not returning such a value; you're returning a cell. Thus, you're trying to set an image cell (created by the data source) as the value of an image cell (the existing one owned by the column).
The log message suggests that you have already set the column's cell as an image cell when you created the column, so all you need to do now is change your data source to always return the object value for the column, not a cell. For an image column, return the image. For a text column, return the string.
Note that NSTableView does not work like UITableView, where UITableViewCells are UIViews and you have as many cells as rows on the screen; in NSTableView, each NSTableColumn gets one and only one data cell, and that one cell is used to draw that column of every row. The cell draws its object value, which you provide to the cell, which you do by returning it (the object value) from your data source method.
The documentation about controls (an NSTableView is a kind of NSControl) and their cells is the Control and Cell Programming Guide.
My guess is it's returning nil, in which case getting the width/height will return 0.
Try:
xxx = [NSImage imageNamed:#"Package"]; // the extension is not needed on the desktop or iOS 4
and make sure the image is actually being copied into your application's Resources folder!
Having established that you are, in fact, receiving an NSImage instance (not nil) whose width and height are zero, the next step is to determine why that happens.
Can you open Package.png in Preview?
If so: What's its width and height in Preview's Info window? Does it have any resolution (DPI or pixels-per-meter) information? If so, what does that say?
If you crack open your application bundle, can you open that copy of Package.png in Preview?
When you log the description of the image, what's the output?
What's the output of logging the image's representations array? (This should be included in the image's own description, but I include it explicitly in case not.)
What happens if you delete your build folder and re-build?