How do you completely clear a flex grid?

Posted on 2003-02-24
Medium Priority
Last Modified: 2012-05-04
Hi there! I have a simple, but confusing VB app here. It contains 1 combobox and a flex grid. When a selection is made within the combobox, the flex grid fills with data from the a database. The problem is when I select another choice, the flex grid does clear and inserts the new data, BUT there is so many empty rows.

Choice 1 has 5 items
Choice 2 has 10 items

when the first choice is made, its perfect. I see 5 items and no extra rows. Now, when I select choice 2, I do see the 10 items, but now there is 5 empty rows at the end. Can someone help me in this coding. This is what I have(I will not show database connection, thats ok).

Public combobox_click()

With MSFlexGrid1
      .Row = 0
      .Col = 0
      .Text = "STORE"
       i = 0
      Do Until myRec.EOF = True
         i = i + 1
         .AddItem ""
         .Col = 0
         .Row = i
         .Text = myRec!Store        
        .RemoveItem (.Rows)   <--this eliminates an empty row that just appears after the last item//
        If use = 1 Then    <--If the combo box has been used already, delete the extra empty cells the first choice left behind//
           For x = 1 To i Step 1
              .RemoveItem (.Rows)
           Next x
        End If      
     x = 0
   End With

I also tried flexgrid.clear, but like i said, it doesn't remove the rows, just clears the text. Help please!
Question by:Vortexo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8013286
Select the FlexGrid in the properties window and give it an index of 0 (zero)

Then in your code replace MSFlexGrid1 with MSFlexGrid1(0)
When you want to clear it type
    Unload MSFlexGrid1(0)
    Load MSFlexGrid1(0)
This should do it.

Expert Comment

ID: 8014500
dim i as integer

Do While Not objr.EOF
        If i <> 1 Then
            MSHFlexGrid1.Rows = MSHFlexGrid1.Rows + 1
        End If

'   load your datas here and put them in the grid.
        i = i + 1
it works perfectly for me

Expert Comment

ID: 8016086
It may be happening because your msflex.rows property not initialized again when you change item in combo and it add more 10 rows .
so make clear whenever you insert new record as per combo value each time reset Rows property ,may be
  msflex.rows=2 or 1 ,as you want

hope this may help you
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users


Accepted Solution

xThorx earned 160 total points
ID: 8016630
Just add MSHFlexGrid1.rows = 0 before adding entries.

Hope this help

Author Comment

ID: 8021494
Thank you xThorx, I knew it was a simple missing syntax. And for you other guys, thanx for the support. Your comments gave me errors which I could not work around.

Expert Comment

ID: 8031276
vortexo don't u think that my solution is more detailed as per your problem and i also posted it before then y i not  got the points???

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question