VS C# - designer tool delete manually inserted code, what I do wrong ???

  • Thread starter £ukasz Margielewski
  • Start date
£

£ukasz Margielewski

I have a dataset and a couple of tabels in it geberated automatically by
dataset designer tool.
I have to attend RowUpdate event by define and place standard lines of
code (from Microsoft sites) in appropriare places. I need to do this because
I want to receive an autonumber primary key column value ...
This standard procedure consists of 3 steps:
1) declare: public event oledbrowupdatedeventhandler rowupdated
2) define:
protected static void OnRowUpdated(object sender, OleDbRowUpdatedEventArgs
args)



and :

3) gRUPATableAdapter.RowUpdated += new
OleDbRowUpdatedEventHandler(OnRowUpdated);



And after that application works fine, everything looks good (program
properly adds rows and receives autonumbes). And ... when I continue my
HARD! work with application and rebuild project, the manually inserted code
disappears ( the event declaration is cleaned up) and ... compiler errors
apperar. What I'm doing wrong - where I have to insert code (by hand or by
designer).

Similarly problem occurs when I manually override addTABLERow function
generated by designer ... Why IDE has still deleting my code!
 
M

Miha Markic [MVP C#]

Hi,

If I understand correctly, you should never modify designer generated code,
as it is regenerated when you modify something.
That said, one option would be to copy the autogenerated code to another
file, so the designer won't bother you again.
Or just disengage the designer by clearing Custom Tool property of xsd file
and include underlying code file in the project.
 
£

£ukasz Margielewski

Thanks for answer ...
Indeed - I resolve the problem by creating new partial classes definition
for the classes, where mentioned functions appears. Next, I removed there
codes this functions and at this moment everything goes alright!
In fact - it was the designer tool falt, who doesn't permit to addind code
manually .. thanks ... regards!!!
 
M

Miha Markic [MVP C#]

Hi,

Well, it is not actually a bug - that's the way designer does its job.
You might consider inheritance to add features to a strongtyped dataset.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top