By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,642 Members | 2,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,642 IT Pros & Developers. It's quick & easy.

how to include checkbox in MsFlexgrid

chandru8
100+
P: 145
hi everybody
can anyone help me in this how to add a check box in flexgrid with sample code

thanks in advance
Nov 29 '07 #1
Share this Question
Share on Google+
1 Reply


Dököll
Expert 100+
P: 2,364
hi everybody
can anyone help me in this how to add a check box in flexgrid with sample code

thanks in advance
Have a look here:
http://www.planet-source-code.com/UR...!1/anyname.htm

Just tried it, it works!

Here, just is case link becomes obsolete

Expand|Select|Wrap|Line Numbers
  1.  
  2. Const strChecked = "ş"
  3. Const strUnChecked = "q"
  4.  
  5. Private Sub Form_Load()
  6.         With MSFlexGrid1
  7.             .Rows = 10
  8.             .Cols = 3
  9.  
  10.             .AllowUserResizing = flexResizeBoth
  11.  
  12.             'name the cols
  13.             For i = 1 To .Cols - 1
  14.                 .Row = 0
  15.                 .Col = i
  16.                 .Text = "Column " & i
  17.             Next i
  18.  
  19.             'name the rows
  20.             For i = 1 To .Rows - 1
  21.                 .Col = 0
  22.                 .Row = i
  23.                 .Text = "Row " & i
  24.             Next i
  25.  
  26.             'define fields as checkbox
  27.             For y = 1 To .Rows - 1
  28.                 For x = 1 To .Cols - 1
  29.                     .Row = y
  30.                     .Col = x
  31.                     .CellFontName = "Wingdings"
  32.                     .CellFontSize = 14
  33.                     .CellAlignment = flexAlignCenterCenter
  34.                     .Text = strUnChecked
  35.                 Next x
  36.             Next y
  37.         End With
  38.  
  39. End Sub
  40.  
  41. Private Sub Form_Resize()
  42.     MSFlexGrid1.Width = Me.ScaleWidth
  43.     MSFlexGrid1.Height = Me.ScaleHeight
  44. End Sub
  45.  
  46. Private Sub TriggerCheckbox(iRow As Integer, iCol As Integer)
  47.         With MSFlexGrid1
  48.             If .TextMatrix(iRow, iCol) = strUnChecked Then
  49.                 .TextMatrix(iRow, iCol) = strChecked
  50.             Else
  51.                 .TextMatrix(iRow, iCol) = strUnChecked
  52.             End If
  53.         End With
  54. End Sub
  55.  
  56. Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
  57.     If KeyAscii = 13 Or KeyAscii = 32 Then 'Enter/Space
  58.         With MSFlexGrid1
  59.             Call TriggerCheckbox(.Row, .Col)
  60.         End With
  61.     End If
  62. End Sub
  63.  
  64. Private Sub MSFlexGrid1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  65.     If Button = 1 Then
  66.         With MSFlexGrid1
  67.             If .MouseRow <> 0 And .MouseCol <> 0 Then
  68.                 Call TriggerCheckbox(.MouseRow, .MouseCol)
  69.             End If
  70.         End With
  71.     End If
  72. End Sub
  73.  
Dököll
Nov 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.