ADOtable cells update - ado

Hi here is my problem:
I have EditBox which shows some variable. on the same form I have a ComboBox. Both are bound to an ADOTable, however when I click and change ComboBox..the textBox goes blank. How can I update the record without using Post once I show the variable in the editbox..
Hope that makes sense.
s

Problem is solved. the issue is that the editbox was bound to the database and I was trying to assign value to it..instead I just updated the cell database directly.

Related

Appium doesn't update it's view in list element and subelements

I am working on iOS native app and when trying to read from tableView/tableCells I have a problem getting the updated values. At the first time i enter the page/screen I can see all cells. But , if i create an action that adds another cell to the table view when I try to get the list of cells I see an empty list.
Also, When i change a subelement in that cell I can't see the changed sub element both in inspector and in the code.
I tried switching to a different page and also changing tabs in that page and reread the table/cell and subelements but it didn't help.
I've had this issue before. There is no actual reload elements kind of function that I've seen. However a workaround I've found that works is to simply find an element that exists and it'll reload the elements after it does that.
For example:
yourMethodThatLoadsNewElements();
driver.findElementBy(pathToElementThatExistedBefore);
driver.findElementBy(pathToElementThatWasJustLoaded);

Need to Update a file after a DBGrid Double-Click

I seem to have a mental block with this one.
I need to save recent changes to a Record. I am doing it OK with buttons for "New" "Edit" "Post" "Next" etc but when a user double-clicks a DBGrid, it is now too late to make changes as the DBGrid selection has moved the database cursor to the selected record.
I can't use AutoUpdate as the data that may have been changed is not something the user would have directly entered, it is a value that is changing all the time.
I'll try to describe it better: While the user is reading a Test-page, a timer is counting down or up. When they click the "Next" or "Prior" buttons I can save the timer setting. But, if they Double-Click the DBGrid I have no way of first changing the current Record before the selection moves to the clicked-Record.
I tried using the
Procedure TForm1.tblTestOnBeforeScroll(...
begin
tblTest.Edit;
tblTest.FieldByName('TimerCt').AsInteger:=ClockCtr;
tblTest.Post;
end;
But, that crashed the database, not surprisingly, but I thought I would give it a try before asking here.
How do I deal with the current record? I do not want to disallow the double-click if possible as it seems nice and intuitive for the user.
I'm afraid that what you do on DBGrid is a wrong in concept action.
Key point is DBGrid is a data aware control. So everything you do on it must based on it's datasource then it's dataset.
There is a DblClick event on TDBgrid. But still you have to check it's dataset to see what record is active.
The code you shown above clearly lead you to an endless loop.
When you doing a scroll, the dbgrid will call OnBeforeScroll event, moving the active record
and call OnAfterScroll. Your OnBeforeScroll code does an data update. Then dbgrid abort its operation cause of data change. Then after data update, it try to scroll again, and the data change happen again. Endless loop happen here.
best regard
Apologies in advance if I'm misunderstanding you, but it seems to me that either the premise of your question is wrong or there is something relevant you haven't told us about what you're doing. Please try the following:
If you don't have one already, please temporarily add a DBNavigator to your form and connect it to the same DataSource as your DBGrid. The point of doing this is so that you can more clearly see what's going on.
Then, in your DBGrid's Options, set dgEditing to True.
Finally, comment out or disable your BeforeScroll handler, save and run your program.
Now, click once in some cell in your DBGrid that contains a value which it's ok to change. Click it a second time so that it selects the value in the cell rather than the cell per se.
Make some change to the cell value, but do nothing else for the time being. You should notice that a) the current record indicator of the DBGrid has changed from a black triangle to an I-Beam graphic, like ][ and b) that the tick and cross buttons of the DBNavigator are now enabled.
Now, without doing anything else on the form, click in another row of the DBGrid. You should find that a) the change to what was the current record in step 5 has been saved and b) the current row indicator reverts to the black triangle and the DBNav's tick and cross buttons are disabled.
(If you don't get the behaviour I've just described, create a minimal new project and try that instead, as some other change you've made in your existing project may be interfering with it).
What I've described in 5 & 6 is the default behaviour of a DBGrid and insofar as I understand your q, that seems to be the behaviour you're trying to achieve. If that's not the behaviour you want, please explain exactly how what you do want differs. It's not clear to me where the user double-clicking on the grid comes into your q, except that that action may move the dataset's cursor (if the dbl-click is on a different row than the current one), but as the default DBGrid behaviour will save changes to the current row before it moves the dataset's cursor, it will do what you seem to want automatically.
Btw, what "AutoUpdate" do you mean? Did you mean TDataSource's AutoEdit property?

Disabling editing option on TDBGrid doesn't function

When creating TDBGrid components dynamically at runtime, i can't forbid user to edit values in cells. This is how I am trying to accomplish this type of behaviour:
TDBGrid *DbGrid = new TDBGrid(Owner);
DbGrid->Options = DbGrid->Options >> dgEditing;
When disabling dgEditing in form designer all is functioning correctly. I can't find the difference between these two cases. What should I do to disable edit of DBGrid cells?
The trick is to do this in following way:
DbGrid->Options = TDBGridOptions(DbGrid->Options) >> dgEditing
but I do not know what is the difference.
I have the same problem with the Seattle version of C++Builder in that I am unable to programmatically change whether the DbGrid allows or disallows editing. The DbGrid->Options values CAN be changed without requiring the TDBGridOptions() cast but the DbGrid does not follow what the DbGrid->Options are set to. If they are set in the object inspector for dgEditing enabled, then the DbGrid always allows editing no matter what the state of DbGrid->Options.dgEditing is and if in the object inspector dgEditing is disabled then the DbGrid never allows editing. It at first APPEARS to work (i.e. the highliting of rows vs cells changes). I have tested this using both DbGrid->Options.ToInt() and DbGrid->Options.Contains(dgEditing) to ensure I'm not stumbling over myself.
I finally found a way to make it work.
If you set the dgEditing to true (for the Options of the DBGrid in the Object Inspector), this will let the user edit at any time. Then, set DBGrid->ReadOnly=false when the user should not be allowed to edit.
I did not have any luck trying to set the individual DBGrid->Columns->Items[ii]->ReadOnly=false. The program did not prevent me from doing that, but it did ignore whatever I had in it.
I wrote a special small test program with minimum components and was able to get good results just by setting the dgEditing to true in the object inspector and then changed dgEditing to false when I wanted to prevent the user from editing, but when I put it into my full program, something prevented the DBGrid from working.
The DBGrid->ReadOnly may be a work-around for someone else also.

Simple question, value not being display in DevExpress's LookupComboBox

This is a Delphi project, but I suspect DevExpress's component works similar for Delphi and .NET.
I have a DevExpress GridDBTableView, when selecting a cell in one of the column, I want a LookupComboBox to show up, where user can select an item, and the value gets display in the table cell. Simple.
I've set the column's Properties set to 'LookupComboBox'.
I have ListColumns setup with 'LocationName' and 'QuantityOnHand'.
ListSource is set to a datasource that's linked a dataset of 'LocationID', 'LocationName', and 'QuantityOnhand'.
ListFieldNames is set to 'LocationName;QuantityOnHand'
When I click on the cell, the combo box shows up with locations for me to choose, but when I choose a location, the table cell doesn't show the location name. In fact, I can't type anything in the cell.
What am I missing?
Ideally, I would like to be able to select a location from the combo box, the location name shows up in the table cell, and I can somehow store the corresponding LocationID that was selected.
I think that you should also set the column's Properties.KeyFieldName property to the KeyField of the Lookup DataSource. In this case, everything should work properly.
OK, all the answer is in the Express Editors' help file article 'Using Lookup Editors'.
The only step I missed was setting the LookupComboBox's KeyFieldNames property to 'LocationID'.

DBLookupComboBox and Refreshing of Contents

I have Delphi 7 and I'm using NexusDB for the database.
I have a main form where I have a DBLookupComboBox to list the contents of a Table.
If I press a button I have on the form to add a new item to the list (which opens a 2nd dialog box) and then come back to the main form I want the newly added item to show up immediately
I can't seem to get that to work.
I've tried refreshing the DataSet under the ListSource object.
Anyone have any ideas?
Thanks,
David
DBLookupComboBox1.ListSource.DataSet.Close;
DBLookupComboBox1.ListSource.DataSet.Open;

Resources