Beatrix,<br><br>Now I have ported the code to <a href="http://VB.NET">VB.NET</a> and I can agree to populate a listbox via iteration. However, for more records I would like to see that I can use the following approach:<br>
<br>Dim con As String = "Driver={Valentina ODBC Driver};IsDatabaseLocal=yes;Database=FirstDB.vdb"<br> Dim sql As String = "SELECT FirstName FROM Person"<br> Dim connection As New OdbcConnection(con)<br>
Dim dataadapter As New OdbcDataAdapter(sql, connection)<br> Dim ds As New DataSet()<br> dataadapter.Fill(ds, "Person_Table")<br><br> Me.GenBox.DataSource = ds.Tables("Person_Table")<br>
Me.GenBox.ValueMember = "FirstName"<br> Me.GenBox.DisplayMember = "FirstName"<br><br><br>In other words, the same solution as for the DataGridView.<br><br>Thanks,<br>Dennis<br><br>PS. I took a closer look on Your (?) site and it was interesting to see Your tool :-)<br>
<br><div class="gmail_quote">2011/1/8 Dennis Wallentin <span dir="ltr"><<a href="mailto:xldennis@gmail.com">xldennis@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Beatrix,<br><br>Thanks for the input and I will look into it.<br><br>Kind regards,<br>Dennis<br><br><div class="gmail_quote">2011/1/8 Beatrix Willius <span dir="ltr"><<a href="mailto:bwillius@gmx.de" target="_blank">bwillius@gmx.de</a>></span><div>
<div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">For a normal listbox you need to loop through the cursor and add a row for each record. With a few 1.000 rows this is pretty slow. For Realbasic there is a control called DataGrid, which loads only the visible rows. I'm sure there will be something similar for .Net.<br>
<br>
Code from Listbox:<br>
<br>
Private Sub AddRowsOfListbox(theCursor as VCursor)<br>
<br>
dim theCol as integer<br>
dim FieldCount as Integer = theCursor.FieldCount<br>
dim ValentinaString as new HandleValentinaString<br>
<br>
Do<br>
Me.addrow "" '<------ row added here<br>
theCol = 0<br>
<br>
dim RowIDInformation as new Dictionary<br>
For currentField as Integer = 1 to FieldCount<br>
if InStr(theCursor.Field(currentField).Name, "ID") = 0 then<br>
Me.cell(Me.lastIndex, theCol) = ValentinaString.GetString(theCursor.Field(currentField)) '<---- add data to cells<br>
theCol = theCol + 1<br>
else<br>
RowIDInformation.Value(theCursor.Field(currentField).Name) = theCursor.Field(currentField).GetString<br>
end if<br>
<br>
next<br>
me.RowTag(me.LastIndex) = RowIDInformation<br>
loop until not theCursor.NextRecord<br>
<br>
End Sub<br>
<br>
<br>
Code from RequestRowData in DataGrid:<br>
<br>
Sub RequestRowData(RowNumber as Integer,Row as DataGridRow) '<--- no cursor here, just the row number<br>
<br>
me.LockDrawing = true<br>
<br>
dim theCol as integer = 1<br>
dim FieldCount as Integer = DataCursor.FieldCount<br>
dim ValentinaString as new HandleValentinaString<br>
dim RowIDInformation as new Dictionary<br>
DataCursor.Position = RowNumber '<--- set position of cursor<br>
<br>
For currentField as Integer = 1 to FieldCount<br>
<br>
if InStr(DataCursor.Field(currentField).Name, "ID") = 0 then<br>
Row.CellText(theCol) = ValentinaString.GetString(DataCursor.Field(currentField))<br>
theCol = theCol + 1<br>
else<br>
RowIDInformation.Value(DataCursor.Field(currentField).Name) = DataCursor.Field(currentField).GetString<br>
end if<br>
next<br>
<br>
Row.ItemData = RowIDInformation<br>
me.LockDrawing = false<br>
<br>
End Sub<br>
<br>
HTH<br>
<div><br>
On 08.01.2011, at 15:27, Dennis Wallentin wrote:<br>
<br>
> Thanks for the valuable input which is appreciated. No, I didn't find among the examples what I'm asking about.<br>
><br>
> However, as usual ODBC comes to rescure but I still want to use .NET features to do it. The below code shows what I like to achieve:<br>
><br>
> Dim con As String = "Driver={Valentina ODBC Driver};IsDatabaseLocal=yes;Database=FirstDB.vdb"<br>
> Dim sql As String = "SELECT * FROM Person"<br>
> Dim connection As New OdbcConnection(con)<br>
> Dim dataadapter As New OdbcDataAdapter(sql, connection)<br>
> Dim ds As New DataSet()<br>
> dataadapter.Fill(ds, "Person_Table")<br>
><br>
> 'Populate the DataGridView with data.<br>
> Me.dgwVDB.DataSource = ds<br>
> Me.dgwVDB.DataMember = "Person_Table"<br>
><br>
> How can I do it with Valentina's .NET Features?<br>
<br>
</div>Mit freundlichen Grüßen/Regards<br>
<br>
Trixi Willius<br>
<br>
<a href="http://www.mothsoftware.com" target="_blank">http://www.mothsoftware.com</a><br>
Mail Archiver X: archive, clean and search email<br>
<a href="http://www.beatrixwillius.de" target="_blank">http://www.beatrixwillius.de</a><br>
Fractals, 3d landscapes etc.<br>
<div><div></div><div><br>
_______________________________________________<br>
Valentina mailing list<br>
<a href="mailto:Valentina@lists.macserve.net" target="_blank">Valentina@lists.macserve.net</a><br>
<a href="http://lists.macserve.net/mailman/listinfo/valentina" target="_blank">http://lists.macserve.net/mailman/listinfo/valentina</a><br>
</div></div></blockquote></div></div></div><br><br clear="all"><div><div></div><div class="h5"><br>-- <br>With kind regards,<br>Dennis W<br>-------------------------------------------------<br>XL-Dennis about .NET & MS Excel<br>
<a href="http://xldennis.wordpress.com/" target="_blank">http://xldennis.wordpress.com/</a><br>
<br>XL-Dennis Consulting<br><a href="http://www.excelkb.com/index.htm" target="_blank">http://www.excelkb.com/index.htm</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>With kind regards,<br>Dennis W<br>-------------------------------------------------<br>XL-Dennis about .NET & MS Excel<br><a href="http://xldennis.wordpress.com/">http://xldennis.wordpress.com/</a><br>
<br>XL-Dennis Consulting<br><a href="http://www.excelkb.com/index.htm">http://www.excelkb.com/index.htm</a><br>