Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: barney guna
  Where is barney guna?
 BANALORE
 India
 barney guna
 Tags
Subject: RE: how to clear a form or combox texbox
Thread ID: 394346 Message ID: 395717 # Views: 31 # Ratings: 3
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Friday, January 17, 2014 2:03:13 PM         
   


> > .Items.Clear();
> Sir...pls give an example of how and where this can be used...in a commandbox?

You got me wrong:) We were talking about how to clear items in a .Net combobox or listbox, not VFP.

I didn't reply to your question before as our friends already gave you the replies. If you ask me how I do that, then I simply set:

listIndex = 0

Which would basically remove the selection if any. That wouldn't clear the contents, why should I? It depends on application. In my applications, I almost always use RowSourceType = 3-SQL. So clearing out the contents doesn't make sense. Instead, if my parameters are changing, then in gotfocus or in anywhere that parameters change and I need to 'replace' contents of my list/combobox I do like this:

with thisform.myListbox
  .Requery() && fill the content based on new parameter
  .listIndex = 0
endwith



Here is sample code showing dependent combos:

Public oForm
oForm = Createobject('myForm')
oForm.Show

Define Class myForm As Form
  Add Object combo1 As ComboBox With ;
    Height = 24, Left = 17, Top = 27, Width = 131
  Add Object combo2 As ComboBox With ;
    Height = 24, Left = 161, Top = 27, Width = 131
  Add Object label1 As Label With ;
    Caption = "Type", Height = 17, Left = 17, Top = 10, Width = 40
  Add Object label2 As Label With ;
    Caption = "SubType", Height = 17, Left = 163, Top = 10, Width = 51

  Procedure Load
TEXT to m.MyText noshow
Trouser             Slimleg
Trouser             Kickflare
Trouser             Bootleg
Jacket              Double Breasted
Jacket              Single Breasted
ENDTEXT
    lcTemp = Sys(2015)+'.txt'
    Strtofile(m.MyText,m.lcTemp)

    lnTypeLen = Len('Trouser             ')
    Create Cursor Products (Type c(m.lnTypeLen),SubType c(30))
    Append From (m.lcTemp) Type Sdf
    Erase (m.lcTemp)
  Endproc

  Procedure Init
    With This.combo1
      .RowSourceType = 3
      .RowSource = 'Select distinct type from products into cursor crsproduct'
      .ColumnCount = 1
      .DisplayValue='Select Product Group'
    Endwith

    With This.combo2
      .RowSourceType = 3
      .RowSource = 'Select subtype from products where type=crsproduct.type into cursor crssubtype'
      .ColumnCount = 1
      .DisplayValue='Select Product Type'
    Endwith
  Endproc

  Procedure combo1.InteractiveChange
    With This.Parent.combo2
      .Requery()
      .ListIndex=0
      .DisplayValue = 'Select Product Type'
    Endwith
  Endproc
Enddefine





Cetin Basoz

Give some sample data in code for your question - here is the tool you need to generate the code

My Blog


MongoDb Certified Developer
MongoDb Certified DBA


Support Wikipedia

ENTIRE THREAD

how to clear a form or combox texbox Posted by barney guna @ 1/2/2014 9:45:49 AM
RE: how to clear a form or combox texbox Posted by David Mustakim @ 1/2/2014 9:48:57 AM
RE: how to clear a form or combox texbox Posted by barney guna @ 1/2/2014 12:06:23 PM
RE: how to clear a form or combox texbox Posted by David Mustakim @ 1/2/2014 12:15:45 PM
RE: how to clear a form or combox texbox Posted by Vilhelm-Ion Praisach @ 1/2/2014 2:49:15 PM
RE: how to clear a form or combox texbox Posted by barney guna @ 1/17/2014 5:27:15 AM
RE: how to clear a form or combox texbox Posted by Jun Tangunan @ 1/3/2014 12:13:40 AM
RE: how to clear a form or combox texbox Posted by David Mustakim @ 1/3/2014 12:28:20 AM
RE: how to clear a form or combox texbox Posted by Tony Vignone @ 1/4/2014 5:53:56 PM
RE: how to clear a form or combox texbox Posted by barney guna @ 1/17/2014 5:28:36 AM
RE: how to clear a form or combox texbox Posted by jacob lefore @ 1/2/2014 4:15:30 PM
RE: how to clear a form or combox texbox Posted by Cetin Basoz @ 1/2/2014 4:51:25 PM
RE: how to clear a form or combox texbox Posted by Koen Piller @ 1/2/2014 5:03:44 PM
RE: how to clear a form or combox texbox Posted by Cetin Basoz @ 1/2/2014 6:31:46 PM
RE: how to clear a form or combox texbox Posted by Tony Vignone @ 1/4/2014 6:06:20 PM
RE: how to clear a form or combox texbox Posted by barney guna @ 1/17/2014 5:31:50 AM
RE: how to clear a form or combox texbox Posted by Cetin Basoz @ 1/17/2014 2:03:13 PM