*?*FILL STRUCTURE ON FORM LOAD EVENT*?*
Posted on 2006-05-03
A general question on how to "FILL A STRUCTURE with DATA ON WIN FORM LOAD EVENT", with some detail code included. I am new to VB2005.NET. I have created a FORM and figured out how to LOAD a DATAGRID CONTROL from an MS ACCESS Table. Most of the code to do this was auto-generated and all I did was tweak control/object properties or Event Handlers. I got what I wanted, a DATABOUND GRID CONTROL to AUTOFILL on a WIN FORM.
What I really want to do now is to cycle thru the MS ACCESS TABLE DATA and read each ROW ELEMENT in to a RECORD STRUCTURE and create an STRUCTURE ARRAY. This would occur when the FORM IS LOADED.
Here is the current RECORD STRUCTURE CDX from WINDOWS MAIN_FORM OBJECT
Public Structure DONOR
Public strDSTATUS As String
Public lngDNISADDRBKnum As Long
Public strDENAME As String
Public sngDFTE As Single
Public sngDVBAL As Single
Public sngDSBAL As Single
Public datDDate As Date
This is the current FORM LOAD EVENT CDX:
Private Sub frmDONORS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'PSCLVACCTm0DataSet.STAFF' table. You can move, or remove it, as needed.
Specifically, my primary question is how the following line of VB2005.NET Code
can be modified to read each ROW/ELEMENT(FIELD/COLUMN) sequentially in the TABLE and ASSIGN IT to the corresponding ROW STRUCTURE ELEMENT.
Basically, A FOR EACH STATEMENT to READ the MS_ACCESS TABLE would be the easiest way to loop thru the TABLE, but I'm not sure that'll work, being a VB2005.NET Newbie. My experience tells me, I may have to write code(DO UNTIL) to check for a EOF Condition.
My secondary question then and I'm only looking for general direction and concept development here, is I then want to selectively use STRUCTURE ARRAY ELEMENTS to load /populate a GRID CONTROL and DISLAY the DATA on the FORM when it is LOADED? So, can I create/populate the DATAGRID CONTROL with the STRUCTURE ARRAY DATA on the FORM, when it is LOADED and after I have created the STRUCTURE ARRAY?
Any guidance and assistance would be greatly appreciated.