CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2012
    Posts
    3

    mshflexgrid doubt

    I am facing a strange issue regarding mshflexgrid. mshflexgrid1.rows is returning 5 while on the grid i can see only 1 row. please help me asap.

    For I = 1 To rs.recordcount
    frmresolveBase2File.MSHFlexGrid1.Row = l
    tranDatetime = Format(rs!tran_datetime, "yyyy-mm-dd")
    If tranDatetime >= startDate Then
    l = l + 1
    Else
    If frmresolveBase2File.MSHFlexGrid1.Rows > 2 Then
    frmresolveBase2File.MSHFlexGrid1.RemoveItem (l)
    Else
    frmresolveBase2File.MSHFlexGrid1.Clear
    End If
    End If

    rs.MoveNext
    Next
    rows = MSHFlexGrid1.Rows

    i am trying to filter the grid by date. here rows = 5 while on the display i can see only 1 row.

  2. #2
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,901

    Re: mshflexgrid doubt

    Nowhere in your code do you show how you actually put some data into the grid

    This statement changes the row number - thats all - no data is changed - displayed, removed or otherwise - You are just adding 1 to the row number and if you had 100 rows which didn't fit your date range you might be sitting on row 100

    Code:
    If tranDatetime >= startDate Then
    l = l + 1
    You clear the grid - you remove a line from the grid but nowhere do you put anything into the grid

    You can see one line - I see none

  3. #3
    Join Date
    Mar 2012
    Posts
    3

    Re: mshflexgrid doubt

    thanks..

    I am clearing it only only if number of rows is 1 + 1 header row. That is because i am unable to delete the last fixed row.

    i am inserting the data in the grid before the last added code as:
    Set MSHFlexGrid1.DataSource = rs

    if i check the MSHFlexGrid1.rows property then it returns 10 but i am just able to see 1 row on the display..

  4. #4
    Join Date
    Mar 2012
    Posts
    3

    Re: mshflexgrid doubt

    If the date is greater then the start date then it shouldnot remove the row..

  5. #5
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,901

    Re: mshflexgrid doubt

    Always a good idea to clear your grid before

    Code:
    Set MSHFlexGrid1.DataSource = rs
    
    ie,  MSHFlexGrid1.Clear
    Also, after populating with the rs, you may need to remove row 1 which often is left blank

    Check rs.recordcount to see how many records are in the recordset before populating

    Code:
    Msgbox rs.recordcount

  6. #6
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: mshflexgrid doubt

    The problem could be the databinding.
    If your flexgrid has rs (a recordset) as DataSource, then .RemoveItem wouldn't work.
    You'd have to remove the record from the recordset to make it actually disappear from the grid.

    It all depends how you entered the data to the grid...

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