CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    May 2007
    Posts
    37

    [RESOLVED] Fill MSHFlexGrid using textbox

    i able to fill one row of MSHFlexGrid form 6 textbox which i
    assinged one by one. The problem is how to fill the next row coz
    i want to fill about 100 row into my MSHFlexGrid form the same 6
    textbox. Every time i add it will change the first row. I want
    it to fill the next row. below is my coding:
    Code:
    Private Sub cmdAdd_Click() 
    Dim Iloop3 As Long 
    Dim R 
    Dim i As Integer 
    
    With MSHF2 
    
    .AddItem "" 
    
    .TextMatrix(.Row, 1) = txtMembership.Text 
    .TextMatrix(.Row, 2) = txtNamemem.Text 
    .TextMatrix(.Row, 3) = txtSandp.Text 
    .TextMatrix(.Row, 4) = txtNetprice.Text 
    .TextMatrix(.Row, 5) = txtStatus.Text 
    .TextMatrix(.Row, 6) = txtPremium.Text 
    
    End With 
    
    For Iloop3 = 0 To MSHF2.Rows - 1 
    MSHF2.TextMatrix(R, 0) = R 
    R = R + 1 
    Next 
    
    End Sub

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Fill MSHFlexGrid using textbox

    You need to use a STATIC variable.

    EDIT: you might want .MouseRow and .MouseCol for your grid.
    Code:
    Option Explicit
    
    Private Sub Form_Load()
      Static I As Integer ' doesn't get set back to 0 each time!
      
    End Sub
    Last edited by dglienna; July 16th, 2007 at 11:13 PM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2007
    Posts
    37

    Re: Fill MSHFlexGrid using textbox

    means, i replace the .textmatrix with .MouseCol and .MouseRow? Hows that, i never use these properties before.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Fill MSHFlexGrid using textbox

    They show you where the user clicked. You don't need both. You don't even need them to reload. Just use R (for ROW) like I said.

    Don't use a loop. Just update each of R's col's ONCE

    Code:
    .TextMatrix(R, 1) = txtMembership.Text
    Last edited by dglienna; July 16th, 2007 at 11:36 PM.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    May 2007
    Posts
    37

    Re: Fill MSHFlexGrid using textbox

    I don't get it Mr.David.

    The loop i put there is for the column 0 numbering. Do you mean i need to take out the With ?

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Fill MSHFlexGrid using textbox

    This is what I mean:

    Code:
    Private Sub cmdAdd_Click()
      Dim Iloop3 As Long
      Static R
      Dim i As Integer
      With MSHF2
    	.AddItem ""
    	.TextMatrix(R, 0) = R ' might want to use R + 1
    	.TextMatrix(R, 1) = txtMembership.Text
    	.TextMatrix(R, 2) = txtNamemem.Text
    	.TextMatrix(R, 3) = txtSandp.Text
    	.TextMatrix(R, 4) = txtNetprice.Text
    	.TextMatrix(R, 5) = txtStatus.Text
    	.TextMatrix(R, 6) = txtPremium.Text
      End With
      R = R + 1
    End Sub
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jul 2009
    Posts
    2

    Re: [RESOLVED] Fill MSHFlexGrid using textbox

    David is Gr88888888888888

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: [RESOLVED] Fill MSHFlexGrid using textbox

    Yes David is great!
    Just remember this thread is 2 years old

    Keep posting at this wonderful site Registered2009, if you have questions, don't hesitate in posting a New Thread about your topic, and you'll find out how many more great members post here

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured