How to prevent only one row to be ordered-obj c - objective-c

I have a table view. And I have multiple rows. While doing the reorder in editing mode, I want one row to stay in the first index all the time. So, if a user wants to swap a row with the first row, it shouldnt allow it. But it should be possible between the second and the third row.
How can I do this?
Thank you very much in advance

Set the first table view cell's showsReorderControl to NO and return NO in tableView:canMoveRowAtIndexPath: for the first row.
You can also implement the UITableViewDelegate method tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:
Here you can return an alternate index path if the proposed one is (0, 0).
Return Value
An index-path object locating the desired row destination
for the move operation. Return proposedDestinationIndexPath if that
location is suitable.
Discussion
This method allows customization of the target row for a
particular row as it is being moved up and down a table view. As the
dragged row hovers over a another row, the destination row slides
downward to visually make room for the relocation; this is the
location identified by proposedDestinationIndexPath.

Related

NSTableView, [table selectedCell] suddenly gives nil value

I must have changed something to break this line of code in my project:
[table selectedCell] //it gives nil value
but the table row is selected (it's highlighted).
Table is cell based.
What could be the reason?
UPDATE: I've just seen in the documentation that this method has been deprecated in 10.10. But then what should I use to get the current selected cell?
It really depends on what you are trying to do. -selectedCell isn't specific to NSTableView; it's inherited from NSControl and isn't particularly useful to a table view. Individual cells can't be "selected", but rows or columns can.
Cells can be edited, however. Is that what you're trying to find out? Which cell is currently being edited? If so, you can use -editedRow and -editedColumn.
Otherwise, you can get either the selected row / row indexes or the selected column / column indexes, but row and column selection are mutually exclusive and either would encompass multiple cells. Since NSControl's -selectedCell can only ever give you one cell, you'll never truly be able to get an answer that makes sense using that method on a table view. But of course only one cell can be edited at a time.
So is it selection or editing you're looking for?

Adding a row (not a column) of a type (checkbox,dropdown) in datagridview

I have a datagridview that is only two or three rows long. It has 7 text columns, one for each day of the week (Monday - Sunday). I'm creating a scheduler, so basically on the left side I have added text to the row headers to assign to it. I.e. Enabled (let's say for Tuesday), start time and end time. This allows the user to schedule as need be.
Here's a picture of it right now:
What I want to do is possibly change the enabled row, or the start/end time to a particular type. So the enabled will be a checkbox and the start/end times will be drop down menus instead of these text boxes.
My question is, what's the "best" way to add a row of a certain type? Obviously columns are done easily, but is there a common method for a row type other than looping through and adding individual cells of that type to the datagridview?
The type of each cell can only be pre-determined by the column, not the row. As a result, you're going to have to add each cell individually. You can actually put a cell of any type anywhere you want. You simply create a cell of the desired type and assign it to the Item property of the grid, e.g.
myDataGridView(columnIndex, rowIndex) = newCell
You will simply have to use a For loop to do that for each valid column index with a single row index. Note that you'll have to create a new cell for each column, not reuse the same one.

Is it possible to set vb.net datagridview cell alignment without modifying whole column?

I am trying to set the alignment of a specific cell in a row/column to be right aligned. However I do not want to set the whole row, or whole column to right aligned. Is it possible to set the cell only? From what I've seen online I'm starting to think it isn't possible.
You would need to hook up to the RowDataBound event. This fires as each row is databound. Check that the row is a data row (as opposed to a header or footer). Then check the value in the column you are interested in. If the value meets your criteria for right justification then apply that to the column in question.
Note if you are using AlternateItemTemplate then check both Item rows and AlternateItem rows.
I've used this method to say change the backround colour of values that fall outside a range.

Make the first row fixed while scrolling or sorting in NSTableView

I have a NSTableView in I want the the first row to be fixed.
I do not want the first row to be sorted while clicking on the header of any table column. The row should also be fixed while scrolling.
I think there are two ways to go:
Add a proprety to the objects in the tableview. For instance a boolean named 'isFirstRow'. Set this object to YES for the row you want first and add a sortDescriptor based on this property.
(I think this is the most clean solution).
Or remove the row from the tableArray, build the table and add this row back on the first position.

How t add new rows atomatically, on scrolling the table view

I want to make an application in which I need a functionality of automatic addition on new rows to the table view. say at first the table view has 5 rows in it, after that when I scroll the table then more 5 rows should be added to the end of the table.
please help me!!!!
Hey!! You can try the idea as implemented on following post
http://iphoneappmonster.blogspot.com/2011/04/insert-rows-to-table-view-on-click-of.html
The way you would do this is to implement tableView:willDisplayCell:forRowAtIndexPath in your UITableViewDelegate, and watch for the last row being displayed (using the indexPath argument).
When the last row is about to be displayed, set a flag and call -reloadData on your UITableView. This will force the table view's recalculation, and call your datasource where you should see the flag and add (say) 5 rows to the previous total number of rows (and also clear the flag).
Now, the row that will display will no longer be the last row (it will have 5 rows below it) and presto! Infinitely-scrolling table view.
Keeping track of the total number of rows (and their content) is left as an exercise for the reader.