Wednesday, September 28, 2016

MSFlexGrid in VB2010 Express Edition

MSFlexGrid control by default in VB6.0 so there is no need to worry about if the environment is vb6.0.  Incase, those working  in VB 2010 express edition  have to follow the below process to incorporate MSFlexgrid
 i) Have to add reference
Add Reference ->   COM - >  Microsoft Felxgrid Control 6.0
 .






 ii) ToolBox - > Right Click on the pointer - > Choose Items -> COM  - >MS Flexgrid Control 6.0

-------------------------------------------------------------------------------------------------------------
Public Class Form1


    Public rowcnt, colcnt, i, j As Integer
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' Entering no. of rows and cols for flexgrid

   rowcnt = InputBox("enter no. of rows")
        colcnt = InputBox("enter no. of cols")


        AxMSFlexGrid1.Rows = rowcnt
        AxMSFlexGrid1.Cols = colcnt
    End Sub













    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Giving values
        For i = 0 To rowcnt - 1
            For j = 0 To colcnt - 1

                'by matrix m X n format  entering values to the cells
                AxMSFlexGrid1.set_TextMatrix(i, j, InputBox("enter the value"))
            Next
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim tot, colindex As Integer


        ' Calculating values based on the given column


        colindex = InputBox("enter which column should be totaled")

        For i = 1 To rowcnt - 1

            tot = tot + AxMSFlexGrid1.get_TextMatrix(i, colindex)

        Next


        'Incrementing rows by one (to add total value in the next row)
        rowcnt = rowcnt + 1
        AxMSFlexGrid1.Rows = rowcnt


        ' column based total is assigned in the specified cell
        ' Specifying index of row and coloumn to feed "Total" String

        AxMSFlexGrid1.Row = rowcnt - 1
        AxMSFlexGrid1.Col = 0

        AxMSFlexGrid1.Text = "Total"


       
        ' Specifying index of row and coloumn to feed total value
        AxMSFlexGrid1.Row = rowcnt - 1
        AxMSFlexGrid1.Col = colindex
        AxMSFlexGrid1.Text = tot

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'display the index of selected row and column

        MessageBox.Show("Rowselected " & AxMSFlexGrid1.RowSel.ToString)
        MessageBox.Show("Colselected " & AxMSFlexGrid1.ColSel.ToString)

    End Sub
End Class



----------------------------------------------------------------------------------------------------------



3 comments:

Unknown said...

Nice blog its very informative and useful blog thanks for sharing.
Web Development Courses

Unknown said...

Great article, it will help me in future.
Web Development Company in Pune

Hasini said...

Thank you... sure will update hereafter.... thanks for boosting up to write more...