I use three component to save same data : TDBGRid, TDatasource and a MessageTable.
I set the edition mode for my DBGrid
MessageDBGrid.Options := MessageDBGrid.Options + [dgEditing];
My question is simple but i can't do that : how can display a DBGrid without any row ? At start, i need to display juste the header for fields.
There is no way to display a DBGrid with zero rows. It will always have one data row, even for an empty table, and even with no datasource assigned it shows an empty row (that is one column wide).
See, for instance, this DBGrid, dropped on a new, blank VCL form in a new, empty VCL application with no other controls:
Related
In a google sheet linked with a google form, I am putting
=ARRAYFORMULA(Responses!$A$2:R500)
in a blank sheet(namely dataList) to copy raw data from the response sheet so it is more readable and manageable.
After submitting some test data, I need to clear them and publish the form for production use. If I simply select the rows and hit "delete" on my keyboard, when new submission comes in, it will not appear on the first row(or row 2), instead it remembers how many rows there were and put the new data on the next row, thus leaving the first rows blank on both of the sheets, which is unacceptable. So I select the rows with test data in the sheet Response and delete the rows:
Now when new submission comes in, it does appear on row 2 in Sheet Response; however, when I go to my "dataList" sheet, it is like this
The A1 notation which is supposed to be absolute has been altered, hence my dataList sheet doesn't get the new submission data from sheet Response.
How to deal with this unwanted behavior?
you can freeze it like:
=INDIRECT("Responses!A2:R500")
instead of your:
=ARRAYFORMULA(Responses!$A$2:R500)
If you want to avoid string ranges or INDIRECT, you could use INDEX:
=INDEX(Responses!A:A,2):INDEX(Responses!R:R,500)
This always takes the second row from A:A and 500th row of R:R regardless of the deleted rows.
Advantage:
This can be drag filled. It can change based only on certain conditions.
I'm trying to create a live quiz with results from a Google form. It inserts rows into my custom sheet, but one of the values which is a sum() of specific cells is ignored on insertion, is there a way to set the default value of a specific cell when a new row is inserted to the specific sum formula I require?
I have seen various examples but all are more complex than I need an I am unable to unpick them.
Is it also possible to specify a checkbox in a cell as well?
try:
={"TOTAL"; ARRAYFORMULA(IF(A9:A="",,MMULT(FILTER(D9:CE,
MOD(COLUMN(D9:CE)-1, 2)=0)*1, ROW(INDIRECT("A1:A"&COLUMNS(D:CE)/2))^0)))}
spreadsheet demo
I am working on Windows application with c#.
I have a word document.
I am removing headers & footers in word file programatically.
I am doing this with Microsoft.Office.Interop.Word.
after removing headers and footers, I found some tables got split in pages.
I want to set AllowBreakAcrossPages property to each row of every table.
How to do this in C# code?
Please help me
You need loop all the tables in this word document. note the index start with 1, not 0 if you just want one specific table to set.
For each oTable As Word.Table in appWord.ActiveDocument.Tables
oTable.AllowPageBreaks = False
oTable.Rows.AllowBreakAcrossPages = False 'This line is very important to make it work
next
Check your word document to see whether your target table is embedded in some other, make sure the loop access the target table for the property setting.
I want to get data out of a specific cell in a DBGrid ? How can I do this in Delphi 7 ? I know with a Stringgrid it was easy you only used StringGrid1.Cells[2,1] if you wanted to show to row 2 column 1, but is there any way to accomplish this with a DBGrid ?
The TDBGrid doesn't contain any data; that comes from the connected TDataSet. So to retrieve information, you read the database itself. The current row in the DBGrid is the current record (row) in the DataSet, and the column is the TField connected to the column in that row.
So if you want to read from the third column in the grid, and that column is attached to a field named 'Customer' in the dataset, you'd just read that field:
Customer := DBGrid1.DataSource.DataSet.FieldByName('Customer').AsString;
Or, of course better (since you should have access to the dataset directly in your code):
Customer := CustomerTable.FieldByName('Customer').AsString;
I have a DBLookupComboBox that is wired to a database query. That part is working fine. When I run the program the DBLookupComboBox is populated with the results of the query. I'd like to to see the DBLookupComboBox populated with the first item "Please Select" when the program first runs or when a new item action is initiated. (See below image)
Also, if I'm loading a previously saved database record that had selected Index 2 "Quick Elimination" how would I get the DBLookupComboBox to display that selected entry?
Yes, "Please Select" is index 0 and it is retreived as part of the query.
You could try this (I know you've probably solved it by now, as you asked over 2 years ago), but in case anyone else was interested...
dbluLookup.KeyValue := dbluLookup.ListSource.DataSet.FieldByName(dbluLookup.KeyField).Value;
That simply sets KeyValue to the first record in the ListSource dataset, which should be the row 'Please Select'.
My guess would be that the value of the underlying table field is NULL rather than zero, which tells the DBComboBox that no value has yet been selected and it displays accordingly.
If the value in the table were zero, I thinkg the text in the edit field of the combo would be selected to indicate that, but I may recall this incorrectly.
Anyway, just check for Field1.IsNull (or IsEmpty) and then set it to zero. It does mean that you can no longer distinguish between an "unknown value" (NULL) and "no selected value" (zero), unless you prevent the zero value from making it back into the table...
One way of doing this would be to add 'Please select' to the underlying table from which you are selecting, where the key to this tuple would be 0. Then when you display the combobox and the value of the connected field is 0, 'Please select' would be displayed. Of course, you have to make sure that this value is never selected!
The DBLookupComboBox displays by default the ListField(s) whose KeyField in the ListSource matches the DataField in the DataSource. So, to ensure to display some value for the DataField being NULL, you have to provide a KeyField of NULL in the ListSource. But one could imagine not wanting a NULL value in the underlaying table associated to the ListSource.
One way to circumvent this is to add the NULL value to the dataset behind the ListSource with a UNION SELECT. That should work just fine, since that dataset does not have to be editable.
Now, to assure this special dataset is only available when you are adding a new record to the dataset associated to the DataSource, manage the query for ListSource.DataSet in DataSource.OnStateChange. When DataSource.State = dsInsert, then update ListSource.DataSet.
Modification for Steve Childs answer in TwwDBLookupCombo, InfoPower component
cboFilterTravel1.LookupValue := cboFilterTravel1.LookupTable.FieldByName(cboFilterTravel1.LookupField).Value;
Thanks Steve It's works for me