Dta List and Flexgrid

Embed Size (px)

Citation preview

  • 8/3/2019 Dta List and Flexgrid

    1/13

  • 8/3/2019 Dta List and Flexgrid

    2/13

    ` Start up VB with a standard Exe project.`

    Go to project menu and select components or Ctrl+T) (fig).

    ` W hen we select components a dialog box appear and add:-` Microsoft FlexGr id control 6.0`

    ` F rom that dialog box.

  • 8/3/2019 Dta List and Flexgrid

    3/13

    ` N ow we w ill see the new tool populated in the` toolbox can be shown in the toolbox (fig):-

    ` Now change the name of the main form to` frmflexgrid or any other name acording to our wish.

    ` SET UP DATA CONTROL` Add Data grid to the form using the toolbox [ ]` and draw it on the form.`

    ` Now add MS F lexGrid control into the form.(fig)

  • 8/3/2019 Dta List and Flexgrid

    4/13

    ` And add combo box [ ]in order to access the data.

    ` CONNECT TO DATA BASE` Now after all is done in the form let us begin the coding for accessing data from using combo box.`

    `

    Go to form and define the dimension as` D im DB As Da taba se` D im RS As Recor d set` for our own convince it is not necessary but short name for Da taba se.`

    ` Go to the com b o b ox co d e w in d ow and do coding as :-` Private Sub Combo1_CLICK()` F G1.Clear ` F G1.TextMatrix(0, 0) = "ROLLN0"` F G1.TextMatrix(0, 1) = "NAME"` F G1.TextMatrix(0, 2) = "CLASS"` F G1.TextMatrix(0, 3) = "DIVISION"` F G1.TextMatrix(0, 4) = "TOTAL"` F G1.TextMatrix(0, 5) = "PERCENT"` X = 1` Set RS = DB .OpenRecor d set("SELECT * FRO M B CA WHERE CLASS ='" + Tr im(Com b o1.Text) + "'")` Do Until RS.EO F` F G1.Rows = X + 1` F G1.TextMatrix(X, 0) = RS!ROLLNO` F G1.TextMatrix(X, 1) = RS!Name` F G1.TextMatrix(X, 2) = RS!Class` F G1.TextMatrix(X, 3) = RS!DIVISION` F G1.TextMatrix(X, 4) = RS!TOTAL` F G1.TextMatrix(X, 5) = RS!Percent` RS.MoveNext` X = X + 1` Loop` End Sub

  • 8/3/2019 Dta List and Flexgrid

    5/13

    ` 9 . W e have to sepecify the connection location to data Access for that purpose do coding uponthe form load event as

    `

    ` Private Sub F orm_Load()

    ` Set DB = OpenDatabase("D:\BCA.MDB")` Set RS = DB.OpenRecordset("SELECT DISTINCT CLASS F ROM BCA")` Do Until RS.EO F

    ` Combo1.AddItem RS!Class` RS.MoveNext` Loop` End Sub`

    ` 10.Save and run the project it will display in the following format and help us to show our datain a flexgrid with using data combo as it source.

  • 8/3/2019 Dta List and Flexgrid

    6/13

  • 8/3/2019 Dta List and Flexgrid

    7/13

    ` 1. Start up VB with a standard Exe project.` 2. Go to project menu and select

    components (Ctrl+t) (f igu re).

    ` 3. Now add control to our project that is:-` Microsoft Da ta list control 6.0 (OL D EB )

    Then click apply and ok.(figure)

  • 8/3/2019 Dta List and Flexgrid

    8/13

    3 . N ow we w ill see that toolbox is populatedwith two more icons as shown in the figure:-

    4. Now change the property of the main form as :-

    SET UP DATA CONTROL5. Add an ADO Data control to the form using the ADO DC tool [ ] and draw it on the form.Name it

    as ADODC and change its

    Visible property toF

    alse.

    6. Now right control and select ADODCProperties option from the shortcut menuthat appers.(figure)

    S.no Name Caption

    i. Name Frm_Datagrid

    ii. Font Times new Roman (14)

    iii. Window Status Maximize

  • 8/3/2019 Dta List and Flexgrid

    9/13

    7 . Now it will display property page ( F igure)for the AD OD C control that we addedIn our project .Select the source of the connection

    as u se connect ion str in g and click b ui ld B u tton.

    8. Now it will display another dialog

    DATA LINK PROPERTY pops up.Select Microsoft jet 3.51OLE DB Provider from the listand click next.(figure)

  • 8/3/2019 Dta List and Flexgrid

    10/13

    9 . W e have to sepecify the connection to data access.Select the data base name.and then click on test connection button.If the connection is properly connected to

    our ACCESS database then it will display thedialog box as text connection succeded.(fig)

    10. Once all we have done then click OK on Data Link dialogbox and again in property page dialog.

  • 8/3/2019 Dta List and Flexgrid

    11/13

    11. Now once again in the property p a g es select the record source tab, setcommand type the source string which contain access statement.i.e. 2 adcmdTable

    12. Table name this contain name of theaccess file. i.e.

    c ommand type 2 - ad c mdTable

    Table name Employee Detail

  • 8/3/2019 Dta List and Flexgrid

    12/13

    12 .Now draw the data list into the formand set all the property of it as

    13. After all is done save the form and create the start up object as our default form name click apply thenok.

    14. Run the form by clicking (f5) or b y cl ick in g start from the tool bar. It will display the form in this way.

    S .NO N AME PROPERTY

    01. D ATA SOURCE A DODC 1

    02. R OWSOURCE A DODC 1

    03. L IST F EILD (F IELD N AME )

    04. F ONT A RIAL (14)

  • 8/3/2019 Dta List and Flexgrid

    13/13