Cannot disable UltraGrid cells - vb.net

I have an UltraGrid in my project. Data can be entered into each cell, which is then saved to the database. I want to be able to disable all of the cells in the current row EXCEPT for one called Product_Code. Once data has been entered into the active row column (this is entered via a ValueList), I then want all of the other cells to become available for entering data into.
So far I have tried
If Me.ugProducts.ActiveRow.Cells("Product_Code").Value.ToString = "" Then
Me.ugProducts.ActiveRow.Cells("Product_Volume").Activation = Activation.Disabled
Else
Me.ugProducts.ActiveRow.Cells("Product_Volume").Activation = Activation.AllowEdit
End If
But to no success. When the project is built, all of the cells are immediately available to type into, despite no value having been entered.
Why is it not working? What is the best way to do this?

I saw a previous comment on here that has since been deleted, for some reason... However, one solve you can try is:
In the form load; add in ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.CellSelect - This will mean all of the cells are disabled, but you'll still be able to select the ValueList for Product_Code
Now, in the CellListSelect event of ugProducts, use the following code ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.Edit (After any validation checks or anything that you have in the method already, it will go in here somewhere, just keep trying things if you aren't too sure where)
Anyway, this should now let you fill them in as you wish.

Related

Editing SWT Table cell. Changed value jumps back immediately to old value as soon as I leave cell. Why?

I have a Dialog and there is a Table (Tableviewer) inside it.
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI);
Certain columns of my table are editable. I click on the cell, I edit the value, I leave the cell and the edited value immediately reverts back to the old one.
What should I configure/set in table/tablehelper to make the edited values last longer than the time I spend in the cell?
EDIT!-----------------------------
We have a Helper class that is responsible for creating CellEditingSupport like this:
`
if ("w".equalsIgnoreCase(hd_bean_mode)) {
CellEditingSupport editingSupport = new CellEditingSupport(viewer,pds[i]);
col.setEditingSupport(editingSupport);
}`
This class itself is quite complex and does a lot of magic through reflexion, etc... The funny thing however is that other tables use this very same Helper class, seemingly with the same configuration and they work!
One more thing: I am conviced that the columns in my table get the Editingsupport. I know it because of the debugger and because the cells are editable. The only problem is that those edits do not last long.

VBA to make it just to the next line and include the if statement above

I have an item number scanned into excel B4 and based on the number, it returns either "Yes" or "No" into C4. If it says "Yes" I would like the item number in B4 to be added to another sheet. If it says "No", nothing needs to happen with this item number. I would like the items numbers to from a list in the separate sheet.
=IF(ISNUMBER(SEARCH("Yes",Sheet7!C4)),Sheet7!B4,)
My if statement is working fine but the issue now lies with a code to make jump to the next row after data has been changed so this can be a continuous process. Right now, after something has been scanned, it provides me with that value i need but as soon as another item is scanned it changes the value to the newest. i want a list of item numbers in the end
I won't write the code for you but look at events.
To get to these open the VBA window [Alt] + [F11] then go onto the sheet you want the event to action on.
Change the top left Drop Down to "Worksheet" and the top right will then let you select different events. for this I would recommend the 'Change' event, this causes the code to trigger whenever a cell is changed.

Unbound DataGridView add row with checkbox error

This is a Windows forms program. I have an unbound DataGridView control with four columns; Feature ID as string, Parts as string, Flats as string and ShowOnEst as boolean. The columns were defined in the form designer and the boolean column is, indeed, set to be a checkbox with tristate set to false.
The user selects a product from a list box and this code is executed to populate the grid
grdFeat.Rows.Clear()
For i = 0 To curProduct.lstFeatures.Count - 1
With (curProduct.lstFeatures(i))
grdFeat.Rows.Add(.FeatureId, .Parts, .Flats, .ShowOnEst)
End With
Next
If AllowUserToAddRows is false, everthing is good. Setting AllowUserToAddRows to true, however, results in the following error:
FormatException
Value '' cannot be converted to type 'Boolean'.
The error is NOT triggered in my code. It's displayed in a new tab titled "No Source Available".
It seems pretty clear that the process that adds the new editing row is trying to set the checkbox to a string value, or perhaps NULL. I'm very new (a few months) to vb.net, so I suspect I'm overlooking some simple setting somewhere, but after several hours of trying to find it, I'm starting to feel a little foolish here.
I'd give you a list of things I've tried already, but it's a long one. :) I even tried to go around the issue by adding a new row manually, .add("","","",False), but that too gives the same error, even though I'm telling it what to put in the checkbox.
What am I missing? Also, can someone point me to an explanation of how that new editing row thingy works?
From what you explained, I have no real explanation for the problem.
A workaround may be to set AllowUserToAddRows to false before populating the DataGridView and set it to true after.
Found it. Hope it helps someone else...
The rows being added are uncommitted rows. To solve it, capture the row added index, set the current cell and notify that the added row is dirty:
grdFeat.Rows.Clear()
For i = 0 To curProduct.lstFeatures.Count - 1
With (curProduct.lstFeatures(i))
Dim p = grdFeat.Rows.Add(.FeatureId, .Parts, .Flats, .ShowOnEst)
End With
grdFeat.CurrentCell = grdFeat.Rows(p).Cells(0)
grdFeat.NotifyCurrentCellDirty(True)
Next
Well, with further experimentation, this isn't a total fix. The problem is still there, but at least now handling the DataError event allows me to do something with it in code. Without these lines, the error occurs before the DataError event is triggered.
Still puzzled.

Copy Value from combo list on login screen to username field on new form

Newer to access...I am trying to copy the value selected from the combobox on the log in screen to a field on the new form that opens after successful login.
The field I need copied is called cmoemployee on the Login form.I need that to go to the username field on the mainframe form.
Any help would be greatly appreciated! I have tried many different ways but I can't seem to get it.
Haha,
I actually know what you mean here. This can be a complete pain as the variables are deleted when you open a new form In general it is better to show what you have tried so people are able to help you fix it. Anyway, I've tried to do this so I know how frustrating it can be. There are two main ways that this can be done. You can open the form with openargs (I do not think this is a good option for you as you will have to have the openargs constantly transferring from one form to the next and will be cleared if one form misses them.
A better option would be to use tempvars which are not deleted. This is the code I used to do something similar:
I am going to assume your combobox is two columns (but only displays one) and the bound column is the primary key to an employee table. In which case this would work (or you can modify it to meet your needs)
Log in:
'Check Password (or however you check it
If StrComp(txt_Password, DLookup("[Password]", "tbl_Employee", "[ID] = " & cmoemployee), 0) = 0 Then
TempVars.Add "MyEmpID", cmoemployee.Value 'TempVars will store the combobox value
Else
Msgbox "Incorrect Password Please try again"
End If
On Load event of mainfraim form:
[UserName] = TempVars!MyEmpID
That should get you started, so you can build the rest. Let me know if you have any questions.

VB in Access: Combo Box Values are not visible in form view but are visible through Debug.Print

Code in Form onLoad:
country_combo.RowSourceType = "Value List"
Code in a reset function:
Dim lListIndex As Long
With Me.country_combo
For lListIndex = .ListCount - 1 To 0 Step -1
.RemoveItem (lListIndex)
Next lListIndex<br/>
End With
Code to populate country combo:
*For n = 1 To numCountries*
*countryCombo.AddItem (countryRS.Fields("countryName"))*
*countryRS.MoveNext*
*Next n*
I'm having a problem that occurs AFTER the code to populate the country combobox runs. The values are there as I can run Debug.Print(countryCombo.Value) and it prints out the name of the selected country, but I can't see the values in the combobox at all. They're invisible, and as far as I know there is no visiblity property for specific items, unless I'm completely mistaken.
comboBoxError.png http://img110.imageshack.us/my.php?image=comboboxerror.png
I think you should probably use Access's GUI tools to do what you're looking for. In design mode, click on the field you are trying to populate, then click the "lookup" tab. You can then specify a table to populate the field with and your forms should automaticly update as well.
I've also seen what you describe here - as far as I can tell, it's a bug within Access (I was using 2007) that only occurs when you programatically mess with the contents of a combo box. It does not happen every time. The issue corrects itself if you highlight the text that is in the combo box.
I am experiencing a similar issue with Access 2003. Based on the selection of one combo box, the row source of a listbox is set to an SQL string Basically a SELECT DISTINCT [MyField_Selected] FROM MyTable. For some fields the values are visible in the list box and others it is not. The values are there however as I can access them via code. To make it more interesting it works fine in Access 2007.
Just found the resolution on another forum. Check the format property of the field(s) in question on the table. In my case, when Access 2007 created the table, it put an # format in there. I removed that and all works great!