In a wxGrid, how do I allow selection of only one cell? - wxgrid

I'm using a wxGrid and would like the user to only be able to select one cell, not a block of cells. (Or possibly multiple cells in the same column, but not necessarily the entire column.) The only idea I've had that had a chance of working was to put ClearSelection() in the EVT_GRID_CMD_RANGE_SELECT but (not too surprisingly) this caused a stack overflow.

Related

How do I prevent unlocked cells from being selected/editable? (VBA)

I have a very specific question that I am looking for help in answering. I have been researching for hours and I feel like I am not able to find what I am looking for. Below is a quick overview of the criteria that my document must follow:
I am using Excel 2013
I will just be using rows for data input (instead of an excel object
table).
The very top/first row will act as my "column header".
This top row will have AutoFilter enabled.
THE DOCUMENT MUST BE PROTECTED (a must-have)!
I will be using VBA code
Now, the final issue I am having with finishing this document are the last two criteria points that I must have:
The first/top row (column headers) must NOT BE EDITABLE.
Each column must be able to SORT AND FILTER.
Now, in a perfect world, I would just "Lock Cells" for the entire first row that acts as my column headers and when I protect the worksheet I would make sure to check the "Sort" and "Use AutoFilter" boxes.
However, this option does not work because there seems to be an issue when I try to sort the data. If I just filter the data there is no problem, but when I try to sort a column in ascending/descending order I will get an error informing me that I can't sort locked cells while in Protected mode. This is because when excel uses the Sort function, it counts the header as part of the data that is being sorted (I found this out through my research) even though I really just want the data below it to be sorted.
I have been trying to brainstorm on how to get past this issue as well as researching different methods, and I am having trouble coming to a final conclusion. However I have narrowed it down to 2 possible solutions:
I want to be able to keep the cells in the first row officially unlocked to allow the AutoFilter's sort command to work as intended, but make it "behave" like the cells are locked when a user tries to make changes to it (AKA, make the entire row un-editable or un-selectable).
The other option would be to keep the first row locked but somehow have an event in VBA that can tell when a user tries to "Sort" the column, which will then temporarily unprotect the worksheet, follow through with the intended sort command, then protect the worksheet again (apparently though, upon my research there is no such event that can trigger off the AutoFilter's sort command alone).
These 2 solutions are the most logical I can think of based off my research, but if someone out there is an Excel genius and knows another way I am open to suggestions.
Thanks in advance for your help/suggestions,
Travo
Consider using two header rows. The top row would be protected and the second row would facilitate filtering and sorting of the data in rows 3 and below.

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?

Excel Suggestion Similar to functionality when you type =formula [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a list of values which i want to populate as the user writes in an excel cell.
I have been trying to replicate an excel feature.
When we type =formula in excel, it shows a dropdown and the list changes as u type in more characters. I want to use a feature like that.
Till now i've tried different methods:
Data validation: The problem here is that i can make the drop down get the substring but i have to click on the arrow to see the values. This makes data entry tedious.
I tried using combo box: The problem is that i have columns A to column H each having different lists and the user can enter n number of rows.
I tried placing the values from the list in the rows and hide them: The problem is that it doesnt show the drop down. It shows only exact values as you type ahead. Hence it doesnt work
I tried using list box: The problem here is that i was not sure how to get the cell value while the cell is in edit mode so that i can populate the list box with strings from the list that contains the string from that cell.
I would appreciate the help.
What you are after is usually called "autocomplete" or "type ahead". You've already listed the tools that Excel provides out of the box.
Another possibility is to enter all desired values at the top of the column and then hide these rows.
Thanks brettdj for your involvement.
I have finally managed to solve this problem.
Macro cannot be run when any cell is in edit mode. hence one cannot get the values that are being typed. Unless one tries to use API. But then using an API is very tricky and we cannot predict what could go wrong.
Solution:
What i've done is, when on a particular cell, i would place a text box on that cell and keep pasting the values in active cell behind. also i would use the value in the text box to populate the values in the list box using instr function.

Should Loop be used if the source data is always changing? OR is there a better method? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
So in sheet 1 i have lets say formulas from cell B2 to E6 f(CN#) that is dependent on the values in A2 to A6, lets call them customer numbers (CN#).see picture below.
these customer numbers would be the same for all the formulas in columns next to it so the whole range is A1-E5 These lines of formulas can increase or decrease monthly so it could be in any given month A1-E5 or A1-E8 or A1-E3.
My problem is that i need to copy and paste these ranges one after another and change the customer numbers or CN# each time a new range is posted. These CN# are located on sheet2
Sorry for the bad grammar but this thing is kicking my butt
Edit:
the formulas f(CN#) are all different. I guess i should explain what i am doing currently.
I take A2-E5 and copy it down to A6-E11. I then change the Value CN1 to CN2. wash rinse and repeat till i get to my last CN#.
If the number lines and columns were static that was an easy fix, but they are not and they change monthly.
The issue is repeating the formulas (B2toE6) which varies then copying them. lets call that a set. so i'd need a set for each customer number. i was thinking of using a dynamic range like
Range(Cells(1,2),Cells(1,Columns.Count).End(xlToLeft)).Select
but im lost from that point forward.
You will have to have a helper cell somewhere: something that tells excel how many times to repeat - this will mean changing a single cell, rather than trying to work things out for multiple cells.
I made a couple of assumptions, which should be relatively easy to modify.
Your list you want to make starts at A2
Your list of customers starts at Sheet2!A2
Your helper cell is at B1
Your formula, starting in A4 and running down would be:
=OFFSET(Sheet2!$A$2,INT(ROW()-ROW($A$2))/$B$1,0)
The list will start producing 0 when you run out of customers. If you wanted to be tidy, you could wrap the function in an IF statement
=IF(OFFSET(Sheet2!$A$2,INT(ROW()-ROW($A$2))/$B$1,0)=0,"",OFFSET(Sheet2!$A$2,INT(ROW()-ROW($A$2))/$B$1,0))
Or you could use conditional formatting to set the cell color and the font color to be the same to make it "hidden"

VBA to transfer a figure from one sheet to another based on matching values other col

I am working on a spreadsheet which is being used to transfer a product from one location to another. Each day I will have a new list of products that needs sending to another location and I already have a "pre-populated" sheet that has suitable locations listed for where these products can be sent to.
I've already worked out the formula's to use which defines the location these products can be sent to (through index and match formula) but once this has been completed, I'd like to update the "pre-populated" sheet with the quantity I'm sending these locations so that limits can be deducted accordingly.
Essentially, I want to copy the figure from column G in ("Task") into column I in ("interstore transfer") where the two "REF" columns in either sheet match. The "New Limit" column will then automatically populate with the new limit based on the figure input into Column I. Once its finished working its way down the list in the sheet ("Task") then end.
I've had a rough attempt at this, but I'm coming stuck with defining the appropriate variables and how it should update.
Any ideas to better my approach would be appreciated.
A VBA solution with variables may not be your best approach for this. Variables declared within VBA code usually have a limited lifetime based on their scope, so when the code ends the values in the variable will be lost.
Another alternative may be to set aside another cell as a counter. Perhaps a good place for this would be next to the "New Limit" column?
Cell values are retained even when VBA code isn't running. Of course cell values also are saved when the workbook saves, so when you get a new list of products at the beginning of the day you can compare to or edit the previous day's work.
To get started with this, I'd recommend getting familiar with how to reference cells and ranges. And, there is some useful information here on Stack Overflow on how to reference well in Excel VBA.