Sql and Listview

cnicolapc

Active Member
Licensed User
Longtime User
Hi,
I have this example

Cursor = Sql1.ExecQuery("Select Artista,Titolo,Anno FROM CdAudio ")'....ecc...

For i = 0 To Cursor.RowCount - 1
Cursor.Position = i
cdlist.AddSingleLine(Cursor.GetString("Artist")& Cursor.GetString("Title")ecc....

is it possible to manage in the listview in addition to

cdlist.SingleLineLayout.Label.TextSize = 14
cdlist.SingleLineLayout.Label.TextColor = Colors.Blue
cdlist.SingleLineLayout.Label.Gravity = Gravity.CENTER

the size and alignment of separate columns?(Artist, Title,..ecc)
I hope to be explained
Thanks
 

klaus

Expert
Licensed User
Longtime User
is it possible to use SQL database with table and scrollview or only CSV file?
Yes.
But you need to replace the LoadTableFromCSV routine by your SQL routine and fill the table.
The number of columns can be different.
One limit is that there is no horizontal scrolling.

Best regards.
 
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
i'm a beginner with basic4Android , I'd be very grateful if you do me a practical example with scrollview and Sql. (... if you have time).
Thanks in advance
Nicola
 
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
Hi, Klaus
I do not know how to thank you for your time
You have been of great help to me
thank you very much!
Nicola.
ps: sorry my bad english
 
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
Hi,
I have some questions in regard to scrollview SqlTable example.
1. it is possible to have different widths for the columns?
2. it is possible to hide a column but can still get its value?
example:

a table with the Code, Last Name, First Name.
I would like to hide the column "Code" but
clicking on the row of scrollview (Last Name, First Name.) I would only capture the value of "Code ".
Thank you for your time.
Nicola
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
1. it is possible to have different widths for the columns?
Yes, by changing the individual ColumnWidth value. Needs arrays for ColumnWidth() and ColumnWidth_1() .

2. it is possible to hide a column but ...
Yes, by setting the ColumnWidth(x) value to 1.

... but can still get its value?
Yes, you need to change the Cell_Click routine accordingly

Attached an example.

Best regards.
 

Attachments

  • SQLTable2.zip
    12.4 KB · Views: 886
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
Hi,
I apologize for my insistence,
I have a panel with scrollview where I read the sub "readSQLtable", and a panel for a new record.
when I insert the new record, and returned to scrollview find all records doubled + the new record.
Should I cancel scrollview first to review the table?
How?
Thanks in advance.
Nicola
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You have several possibilities:
- When you add the new record into the database you can call AddRow to add the new record at the end of the scrollview.
- I suppose that you read the database again after adding the record into the database, so you must call ClearAll before reading the SQL file.
- Write a routine to insert a record somewhere in the scrollview.

An example for the last solution is here Rearrange ListView lines post #3, but with only one value per row.

Best regards.
 
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
Hi Klaus,
Sorry about my insistence, but I'm going crazy because of my inexperience with basic4android, to resolve some problems.
1. I added two new fields in my sql database and I set the new value for numberofcoloums. then in the table of scrollview I would like to see the new columns, but it returns this error. as in the photo attached.
2. I created a panel for the addition of new fields, but some of them remain
covered by the keyboard. you can 'manage fields scrollview to move up when the
keyboard appears?
3. can you have a precise error number insthead of a stringa?
example: duplicate value for the index.
I thank you for your patience and sorry if I take advandage of your competence.
Thank You
Nicola
 

Attachments

  • Error_Lista.jpg
    Error_Lista.jpg
    14.3 KB · Views: 499
  • Lista.txt
    654 bytes · Views: 415
  • Lista2.txt
    322 bytes · Views: 389
Upvote 0

klaus

Expert
Licensed User
Longtime User
Hi Nicola,
Sorry for answering somewhat late.
1) It seems you solved it.
2) I would suggest you to put the views for the input panel in a layout and reasd it in a Scrollview, this one can be scrolled by the user and also by code.
3) The error comes from the line
ColumnWidth(4) = sv.Width-sv.Width
the result is ZERO, the minimum possible value is 1 and not 0 because
the real column width is ColumnWidth_1(4) = ColumnWidth(4) - 1
If ColumnWidth(4) = 0 then ColumnWidth_1(4) = -1, which is impossible.

Best regards.
 
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
Multi Select

hi,
How can I change the sub cell_click to select multiple rows? (multiselect)
For example, to delete rows 2 or 3?
thanks in advance.

Sub Cell_Click
Dim l As Label
Dim ctext As String
l = Sender
rc = l.Tag
SelectRow(rc.Row)
activity.Title = "Cell clicked: (" & rc.Row & ", " & rc.Col & ")"
'Activity.Title = "Code = "&GetView(rc.row,0).Text
Prelevacolonna = GetView(rc.row,4).Text

End Sub
 
Upvote 0
Top