HighTechTalks DotNet Forums  

vs2005 - 'The event Click is read-only and cannot be changed' - What?

Dotnet FAQs microsoft.public.dotnet.faqs


Discuss vs2005 - 'The event Click is read-only and cannot be changed' - What? in the Dotnet FAQs forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
dbuchanan
 
Posts: n/a

Default vs2005 - 'The event Click is read-only and cannot be changed' - What? - 12-08-2005 , 07:47 PM






Hello,

What does this error mean?
"The event click is read-only and cannot be changed"

This is a design-time error. It is displayed instead of the form.

Here is the full text
\\
"One or more errors encountered while loading the designer. The errors
are listed below. Some errors can be fixed by rebuilding your project,
while others may require code changes.

The event click is read-only and cannot be changed

at
System.ComponentModel.Design.EventBindingService.E ventPropertyDescriptor.SetValue(Object
component, Object value)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeAttachEventStatement(IDe signerSerializationManager
manager, CodeAttachEventStatement statement)
at
System.ComponentModel.Design.Serialization.CodeDom SerializerBase.DeserializeStatement(IDesignerSeria lizationManager
manager, CodeStatement statement)
//

I have made it go away by commenting out the following code. Then I
rebuild, close and reopen the solution.

(This is used within an inherited form thus the Overrides.)
\\
Protected Overrides Sub btnOK_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnOK.Click

'Save to Quote table
InsertIntoQuote()
'UpdateDatasourceTable(_dataSet1.tbl010Quote)

'Save to Version table
insertIntoVersion()
'UpdateDatasourceTable(_dataSet1.tbl020Version)

Me.Close()
End Sub
//

What is the problem?

dbuchanan


Reply With Quote
  #2  
Old   
Cor Ligthert [MVP]
 
Posts: n/a

Default Re: vs2005 - 'The event Click is read-only and cannot be changed' - What? - 12-09-2005 , 02:28 AM






dbuchanan,
Quote:
What does this error mean?
"The event click is read-only and cannot be changed"

One or more errors encountered while loading the designer. The errors
are listed below. Some errors can be fixed by rebuilding your project,
while others may require code changes.

Have a look at the code in the designerpart, most probably did you change or
delete something in that.
(This can even be because you deleted a class by instance a strongly typed
dataset from your solution explorere).

I hope this helps,

Cor




Reply With Quote
  #3  
Old   
dbuchanan
 
Posts: n/a

Default Re: vs2005 - 'The event Click is read-only and cannot be changed' - What? - 12-09-2005 , 06:30 AM



Cor,

There you go guessing

Please read my posts carefully before responding

I said
Quote:
I have made it go away by commenting out the following code. Then I
rebuild, close and reopen the solution.
How coud that work if I had changed or deleted code or deleted a class?

The problem does come back, but not on the first time I run it after
the steps above. It will seem to work okay on the first or second
running, but then it will fail again. The same steps will temporarly
recover the problem, but the problem *will* return.

Anybody have any suggestions regarding why commenting the following
code would temporarly remedy the problem

\\
Protected Overrides Sub btnOK_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnOK.Click

'Save to Quote table
InsertIntoQuote()
'UpdateDatasourceTable(_dataSet1.tbl010Quote)

'Save to Version table
insertIntoVersion()
'UpdateDatasourceTable(_dataSet1.tbl020Version)

Me.Close()
End Sub
//

Thank you,
dbuchanan



Reply With Quote
  #4  
Old   
Cor Ligthert [MVP]
 
Posts: n/a

Default Re: vs2005 - 'The event Click is read-only and cannot be changed' - What? - 12-09-2005 , 07:00 AM



Copied text until the next line
--------------------------------------------------------------
This is used within an inherited form thus the Overrides.)
\\
Protected Overrides Sub btnOK_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnOK.Click

'Save to Quote table
InsertIntoQuote()
'UpdateDatasourceTable(_dataSet1.tbl010Quote)

'Save to Version table
insertIntoVersion()
'UpdateDatasourceTable(_dataSet1.tbl020Version)

Me.Close()
End Sub
//

What is the problem?
------------------------------------------
Problem is probably your "thus". What are you overriding.

This is overriding a btnOK which is probably nowhere created in this class,
not even in your designer part. However AFAIK you are not even able to do
that, what is the reference you had that this is "thus".

Cor.




Reply With Quote
  #5  
Old   
Bart Mermuys
 
Posts: n/a

Default Re: vs2005 - 'The event Click is read-only and cannot be changed' - What? - 12-09-2005 , 08:35 AM



Hi,

"dbuchanan" <dbuchanan52 (AT) hotmail (DOT) com> wrote

Quote:
Cor,

There you go guessing

Please read my posts carefully before responding

I said
I have made it go away by commenting out the following code. Then I
rebuild, close and reopen the solution.

How coud that work if I had changed or deleted code or deleted a class?

The problem does come back, but not on the first time I run it after
the steps above. It will seem to work okay on the first or second
running, but then it will fail again. The same steps will temporarly
recover the problem, but the problem *will* return.

Anybody have any suggestions regarding why commenting the following
code would temporarly remedy the problem

\\
Protected Overrides Sub btnOK_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnOK.Click
----------------------
This looks suspicious.

If the base clase already handles the btnOK.Click event, eg:

Partial Public Class BaseForm
Protected Overridable Sub btnOK_Click(
ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnOK.Click
----------------------
' .... code ...
End Sub
End Class

Then the derived class does not need to handle the event ("Handles"), only
override it, eg:

Partial Public Class DerivedForm
Protected Overridable Sub btnOK_Click(
ByVal sender As System.Object,
ByVal e As System.EventArgs)

' ... code that runs before base.btnOK_Click here ...

MyBase.btn_OK_Click(sender, e)

' ... code that runs after base.btnOK_Click here ...
End Sub
End Sub

In this example the base class handles the event while the derived class
only overrides it (doesn't handle it again).

If you do handle the event in both the base form and derived form and
override it then this would not cause an Exception but would cause the
eventhandler to fire twice.

The Exception is most likely caused because the btnOK (in the base class)
has no 'protected' Modifier(see btnOK properties) and therefore you can't
add events in the derived class (in VB.Net terms doesn't allow you to use
"Handles"). BUT as explained earlier you probely don't need this event
handling in the derived class because you are already overriden it.


HTH,
Greetings


Quote:
'Save to Quote table
InsertIntoQuote()
'UpdateDatasourceTable(_dataSet1.tbl010Quote)

'Save to Version table
insertIntoVersion()
'UpdateDatasourceTable(_dataSet1.tbl020Version)

Me.Close()
End Sub
//

Thank you,
dbuchanan




Reply With Quote
  #6  
Old   
dbuchanan
 
Posts: n/a

Default Re: vs2005 - 'The event Click is read-only and cannot be changed' - What? - 12-09-2005 , 11:47 AM



Bart,

The exception is not caused because of the modifier because the base
class is modified as "Protected", however I need to remove the "Handles
btnOK.Click" from the derived class code.

I'll try that and see if I get any errors.

Thank you,
dbuchanan


Reply With Quote
  #7  
Old   
Bart Mermuys
 
Posts: n/a

Default Re: vs2005 - 'The event Click is read-only and cannot be changed' - What? - 12-09-2005 , 02:19 PM



Hi,

"dbuchanan" <dbuchanan52 (AT) hotmail (DOT) com> wrote

Quote:
Bart,

The exception is not caused because of the modifier because the base
class is modified as "Protected",
Strange, i hope you double checked, anyways at least the oposite is true, if
you Handle an event in a derived form of a base form's Control whose
Modifiers is set to friend, the designer will show the exact same exception.

Quote:
however I need to remove the "Handles btnOK.Click" from the derived class
code.
Yes, if you use Overridable-Overrides then you only have to Handle the event
once, eg. in the base Form.

Greetings

Quote:
I'll try that and see if I get any errors.

Thank you,
dbuchanan




Reply With Quote
  #8  
Old   
dbuchanan
 
Posts: n/a

Default Re: vs2005 - 'The event Click is read-only and cannot be changed' - What? - 12-09-2005 , 05:01 PM



Hello Bart,

when I said...
Quote:
The exception is not caused because of the modifier because the base
class is modified as "Protected",
I had misunderstood you. I thought you meant the code as in "Protected
Overridable Sub".
Now I know you meant the modifier in the properties of the button. Yes
it was "Friend". (!)

And now I think I know why the error was "Click is read-only" though it
certainly isn't very clear.

Thanks again,
dbuchanan



Reply With Quote
  #9  
Old   
Bart Mermuys
 
Posts: n/a

Default Re: vs2005 - 'The event Click is read-only and cannot be changed' - What? - 12-09-2005 , 05:59 PM



Hi,

"dbuchanan" <dbuchanan52 (AT) hotmail (DOT) com> wrote

Quote:
Hello Bart,

when I said...
The exception is not caused because of the modifier because the base
class is modified as "Protected",

I had misunderstood you. I thought you meant the code as in "Protected
Overridable Sub".
no no :-)

Quote:
Now I know you meant the modifier in the properties of the button. Yes
it was "Friend". (!)
So that was causing the problem then (together with handling the button
event in the derived form).

Quote:
And now I think I know why the error was "Click is read-only" though it
certainly isn't very clear.
You should also notice that when a base form control modifiers is set to
'Friend' that all properties and events for that control on the derived form
inside the properties window are shown grayed-out, meaning you can't use
them.

But, you can add "Handles" in code, next time you compile and open the
designer, the designer throws because it's trying to change the text of a
grayed-out (readonly) event (in properties window).

Quote:
Thanks again,
You're welcome.
Greetings


Quote:
dbuchanan




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.