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
'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:
Nice blog its very informative and useful blog thanks for sharing.
Web Development Courses
Great article, it will help me in future.
Web Development Company in Pune
Thank you... sure will update hereafter.... thanks for boosting up to write more...
Post a Comment