How to make a flexgrid column to a checkbox column - checkbox

I have a flexgid with 3 columns. I need to make the first column a checkbox column so that users can check and uncheck there. And i need the other column values which are checked. ` MSFlexGridBrg.Width = "3200"
For Bea = 1 To NbBearg
MSFlexGridBrg.Rows = NbBearg + 1
MSFlexGridBrg.Cols = 3
'MSFlexGridBrg.CellFontName = "Wingdings"
MSFlexGridBrg.TextMatrix(0, 0) = "Select"
If MainUnitIn Then
MSFlexGridBrg.TextMatrix(0, 2) = "Cu (N)"
Else
MSFlexGridBrg.TextMatrix(0, 2) = "Cu (lbf)"
End If
MSFlexGridBrg.Row = 1
MSFlexGridBrg.col = 1
MSFlexGridBrg.TextMatrix(0, 1) = "Bearing No."
MSFlexGridBrg.Row = Bea
MSFlexGridBrg.Text = Bea & ". "
MSFlexGridBrg.col = 1
MSFlexGridBrg.TextMatrix(MSFlexGridBrg.Row, 2) = Cu_Value_Estimate(Bea)
Next`
The output is attached as the image. I want the column named Select as the Checkbox column.

You can't do that in your current first column, as it is a fixed column which doesn't allow edit. Add a new column and inside your formatting loop (which isn't clearly to see in your code sample, but i see there is the next at the very bottom) use a standard formatting code:
If myBooleanVar = True Then
MSFlexGridBrg.TextMatrix(i, 0) = "Yes"
Else
MSFlexGridBrg.TextMatrix(i, 0) = "No"
End If
If you need to use the first cell of the column to select all the rows, you may use the MSFlexGridBrg_Click() and then check for MSFlexGridBrg.MouseCol = -1 and MSFlexGridBrg.MouseRow = -1 - but a checkbox won't never appear.

Related

How to enable button according to the number of checked checkboxes powerbuilder?

I have a datawindow with checkboxes and a button 'OK'. The button is disabled until at least one of the checkboxes is checked. The problem is that if I have more than one checkbox checked and I want to uncheck one the button disables. I wrote the code in itemchanged event:
int li_ind
long ll_row
choose case dwo.name
case "ind"
for row = 1 to this.RowCount()
if data ='1' then
li_ind++
end if
next
if li_ind <> 0 then
parent.cb_ok.enabled = true
else
parent.cb_ok.enabled = false
end if
end choose
What am I doing wrong?
Thanks!
You could put a hidden computed field in the detail band of your datawindow named cf_ind_count.
Define cf_ind_count
sum( if( ind = '1', 1, 0 ) )
replace your script with
long ll_count
long ll_rows
boolean lb_enable = false
ll_rows = this.rowcount()
if ll_rows < 1 then
lb_enable = false
else
ll_count = long( this.object.cf_ind_count[1] )
if ll_count > 0 then
lb_enable = true
else
lb_enable = false
end if
end if
parent.cb_ok.enable = lb_enable
The variable 'data' only applies to the current row. You need to use getitemstring.

One line of code in Loop gives undesirable results

The code below copies the values of the selected record to all records on my form.
But, this line in the code is giving me undesirable results
.Fields("ResultsID").Value = Me.TestResultID.Value
Instead of copying the TestResultIDs of each record into ResultsID, it makes all ResultsID the same as the selected record's TestResultsID.
Where would be the best place to move that line of code to?
With Me.RecordsetClone
.MoveFirst
Do While .EOF = False
If .Fields("[Ordered Analyte]").Value = Me.[Ordered Analyte].Value Then
.Edit
.Fields("DateStarted").Value = Me.DateStarted.Value
.Fields("TimeStarted").Value = Me.TimeStarted.Value
.Fields("DateCompleted").Value = Me.DateCompleted.Value
.Fields("TimeCompleted").Value = Me.TimeCompleted.Value
.Fields("Result").Value = Me.Result.Value
.Fields("Count").Value = Me.[txtCount].Value
.Fields("ResultsID").Value = Me.TestResultID.Value
.Update
End If
.MoveNext
Loop
End With
replace
.Fields("ResultsID").Value = Me.TestResultID.Value
with
.Fields("ResultsID").Value = .Fields("TestResultsID").Value
to use the TestResultsID from each individual record instead of just the current one.
The code below copies the values of the selected record to all records
on my form.
and:
it makes all ResultsID the same as the selected record's TestResultsID.
Thus, your code works exactly as intended.

How to create drop-down list in SSRS based on WHERE clause below?

At my organization we using UI third party tool that communicates with SQL database. I have access to a database, but not to the tool.
Based on a stored procedure below user able to choose from drop-down list DairyStatus "Open", "Closed", or "Both"
ALTER Procedure
AS
#ShowOpen bit = 0,
#ShowClosed bit = 0
SELECT
FROM
WHERE
AND
(
(CASE WHEN (#ShowOpen = 1) THEN
CASE WHEN (tblNoteRecipients.CompletedDate IS NULL and tblNoteRecipients.IsDiary = 1) or tblNoteRecipients.UserGUID is null THEN 1 ELSE 0 END
ELSE
1
END = 1)
AND
(CASE WHEN (#ShowClosed = 1) THEN
CASE WHEN (tblNoteRecipients.CompletedDate IS NULL) THEN 0 ELSE 1 END
ELSE
1
END = 1)
OR ((#ShowOpen = 1) AND (#ShowClosed = 1))
)
So my question is how can I make same drop-down list in SSRS?
What would be the data-set in order to populate this drop-down list?
create a parameter in ssrs with 3 static values(open closed both)
in where clause it should be something like :
( #DairyStatus = 'open' and ((tblNoteRecipients.CompletedDate IS NULL and tblNoteRecipients.IsDiary = 1) or tblNoteRecipients.UserGUID is null)) or
( #DairyStatus = 'closed' and tblNoteRecipients.CompletedDate IS not NULL) or
#DairyStatus = 'both'

Gembox get count of all rows (including blank) of specfic column

I am trying to get count of last used row for a specific column, but was only able to get count of max rows occupied. Test data is shown in attached snap. Please help. Snap Attached Here
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
ExcelFile ef = ExcelFile.Load("test.xlsx");
CellRange rcount = ef.Worksheets[0].Columns[1].Cells;
Console.WriteLine(ef.Worksheets[0].Rows.Count);
ef.Save("test.xlsx");
Console.ReadKey();
Cells are internally allocated in rows, not in columns. In other words, you could get the last used column for each row with ExcelRow.AllocatedCells.Count.
For getting the last used row in a specific column you can use something like the following:
ExcelFile ef = ExcelFile.Load("test.xlsx");
ExcelWorksheet ws = ef.Worksheets[0];
ExcelColumn column = ws.Columns[1];
int rowIndex = ws.Rows.Count - 1;
while (rowIndex >= 0 && column.Cells[rowIndex].ValueType == CellValueType.Null)
--rowIndex;
Console.WriteLine(rowIndex);
I hope this helps.

How to fill a textBox automatically with a special format of autoNumbering when selecting a value from a comboBox in ms-access-2010?

I have a form containing a combBox and a textBox. The comboBox is getting it's data from a table witch has only three values (JED,RUH and DMM). What I want is when the user pick any of the three values in the comboBox, the textBox will be filled automatically with a special format of autoNumbering. For example if the user picked JED the format will be j0000a ("j": is static and it's a shotcut of JED, "0000": is a regular number that increases sequentially, "a": is an alphabetical letter that will never change unless the 0000 reaches it's limit witch is 9999). Note that each value in the comboBox has it's special format of autoNumbering and it's unique.
How can I do it ?
Thanks in advance.
If you are storing the value in a table then some VBA code in the drop down's afterupdate() event would do it.
I will take some liberties here because I don't know your exact structure.
Table_ABRV
ID | ABRV
1 | JED
2 | RUH
3 | DMM
And another table.
Table_Auto
ID | CustomID | ABRVID
1 | j0000a | 1
And the code to make this work is
Private Sub cmbABRV_AfterUpdate()
Dim seed, autoVal, autoRemainder, autoAlpha
'[ABRV][####][a]
seed = DCount("ID", "Table_Auto", "ABRVID = " & DLookup("ID", "Table_ABRV", "ABRV = '" & cmbABRV.Text & "'"))
autoVal = Round(seed / 10000, 0) + 1 'this will be used for the alpha character
autoRemainder = seed Mod 10000 'this will be used for numeric value
autoRemainder = Format(autoRemainder, "000#") 'Add preceeding 0's
autoAlpha = ConvertToLetter(autoVal) 'convert the autoVal to Alpha
txtAuto.Value = Left(cmbABRV.Text, 1) & autoRemainder & autoAlpha 'Create string
End Sub
Function ConvertToLetter(Val) As String
'Convert a letter to a numeric equivalent
Dim iAlpha As Integer
Dim iRemainder As Integer
iAlpha = Int(Val / 27)
iRemainder = Val - (iAlpha * 26)
If iAlpha > 0 Then
ConvertToLetter = Chr(iAlpha + 64)
End If
If iRemainder > 0 Then
ConvertToLetter = ConvertToLetter & Chr(iRemainder + 64)
End If
End Function
The form text box will display the auto number after a value is picked from the drop down.

Resources