Object stays disabled after change of controlsource 
Author Message
 Object stays disabled after change of controlsource

I have a form with a number of controls which are linked
to database fields. If there are no records in the table,
the control is disabled by foxpro, which is normal.
However if I change the controlSource property to a memory
variable in the init() of the control, it doesn't get
enabled. This happens only with some controls like Spinner
or ComboBox, others like the TextBox are ok. Logically,
when there is at least 1 record in the table, there is no
problem also.
Does anybody have an idea how to solve this problem ? I
can't do the change of the controlSource anywhere else
since these are controls which are subclassed and this
behavior is part of the way our framework works.

thanks in advance
Xavier



Mon, 05 Sep 2005 20:24:17 GMT  
 Object stays disabled after change of controlsource
Xavier,

Are you changing them in the control's Init() or in the Forms.Init()? Have
you tried calling the control .Refresh() after changing the ControlSource?

--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro


Quote:
> I have a form with a number of controls which are linked
> to database fields. If there are no records in the table,
> the control is disabled by foxpro, which is normal.
> However if I change the controlSource property to a memory
> variable in the init() of the control, it doesn't get
> enabled. This happens only with some controls like Spinner
> or ComboBox, others like the TextBox are ok. Logically,
> when there is at least 1 record in the table, there is no
> problem also.
> Does anybody have an idea how to solve this problem ? I
> can't do the change of the controlSource anywhere else
> since these are controls which are subclassed and this
> behavior is part of the way our framework works.



Tue, 06 Sep 2005 10:43:18 GMT  
 Object stays disabled after change of controlsource
I'm changing them in the control's Init(), since this is
the only place I can do it (as I said this behaviour is
necessay for the way our subclass components work).
Calling the refresh() doesn't help, Foxpro keeps the
control disabled until a record is available.

Quote:
>-----Original Message-----
>Xavier,

>Are you changing them in the control's Init() or in the
Forms.Init()? Have
>you tried calling the control .Refresh() after changing
the ControlSource?

>--
>df - Microsoft MVP FoxPro

http://www.geocities.com/df_foxpro
Quote:



>> I have a form with a number of controls which are linked
>> to database fields. If there are no records in the
table,
>> the control is disabled by foxpro, which is normal.
>> However if I change the controlSource property to a
memory
>> variable in the init() of the control, it doesn't get
>> enabled. This happens only with some controls like
Spinner
>> or ComboBox, others like the TextBox are ok. Logically,
>> when there is at least 1 record in the table, there is
no
>> problem also.
>> Does anybody have an idea how to solve this problem ? I
>> can't do the change of the controlSource anywhere else
>> since these are controls which are subclassed and this
>> behavior is part of the way our framework works.

>.



Tue, 06 Sep 2005 15:27:07 GMT  
 Object stays disabled after change of controlsource
Xavier,

I think you have something else in your framework that is interfering.

I created a form in the load I did a create cursor, but did not insert any
rows, all controls bound to the columns of the cursor disable, as expected
when the form runs.

Then I put code like this into the cbo.Init:

this.ControlSource = thisform.iProp

reran the form and the cbo is enabled correctly.

--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro


Quote:
> I'm changing them in the control's Init(), since this is
> the only place I can do it (as I said this behaviour is
> necessay for the way our subclass components work).
> Calling the refresh() doesn't help, Foxpro keeps the
> control disabled until a record is available.



Thu, 08 Sep 2005 08:46:47 GMT  
 Object stays disabled after change of controlsource
Quote:
>Xavier,

>I think you have something else in your framework that is
interfering.

>I created a form in the load I did a create cursor, but
did not insert any
>rows, all controls bound to the columns of the cursor

disable, as expected

Quote:
>when the form runs.

>Then I put code like this into the cbo.Init:

>this.ControlSource = thisform.iProp

>reran the form and the cbo is enabled correctly.

Ok, thank you for your help, I will check this out.


Fri, 09 Sep 2005 20:14:12 GMT  
 Object stays disabled after change of controlsource

Quote:
>Then I put code like this into the cbo.Init:

>this.ControlSource = thisform.iProp

>reran the form and the cbo is enabled correctly.

the mistake that you make here is that you set the
controlSource to the value of the property, which is
probably empty. If you change it to :

this.ControlSource = 'thisform.iProp'

You will be able to simulate the behavior I was referring
to. It did however give me a hint about how to solve the
issue. If I use code like this :

this.ControlSource = ''
this.ControlSource = thisform.iProp

Everything seems to work ok ! Sometimes you have to be
very creative being a Fox Programmer :) Anyway, thank you
for your help, at least that's one more problem solved !



Fri, 09 Sep 2005 20:45:59 GMT  
 Object stays disabled after change of controlsource
Xavier,

I forgot the quotes when I did the test, frankly I suprised that didn't
throw a runtime error. That property must have a character string as it's
value, not the .f. or 0 that the two properties were initialized to.

What effectively happened as that the ControlSource was in fact set to ''
which unbinds the control. Which is also in effect what you found , you must
unbind the control before you bind it to something else in this eof()
situation.

--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro


Quote:
> >Then I put code like this into the cbo.Init:

> >this.ControlSource = thisform.iProp

> >reran the form and the cbo is enabled correctly.

> the mistake that you make here is that you set the
> controlSource to the value of the property, which is
> probably empty. If you change it to :

> this.ControlSource = 'thisform.iProp'

> You will be able to simulate the behavior I was referring
> to. It did however give me a hint about how to solve the
> issue. If I use code like this :

> this.ControlSource = ''
> this.ControlSource = thisform.iProp

> Everything seems to work ok ! Sometimes you have to be
> very creative being a Fox Programmer :) Anyway, thank you
> for your help, at least that's one more problem solved !



Fri, 09 Sep 2005 22:41:22 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Grid.Column.ControlSource change disables editing

2. FPW2.5: Changing colors in disabled objects

3. Use controlsource to find an object

4. Problem with Setting a ControlSource to the Property of an Object

5. Problem with Setting a ControlSource to the Property of an Object

6. Can't change ControlSource in a Text box

7. Changing a RichText ControlSource

8. FPD26 disabled objects

9. Click on disabled objects?

10. Disabled objects

11. change text color for disabled get fields?

12. FPMac: Change text color in disabled popup?

 

 
Powered by phpBB® Forum Software