Click here to Skip to main content
15,867,704 members
Home / Discussions / C#
   

C#

 
GeneralRe: Call Webservice from windows client problem Pin
Mazdak29-Jan-04 4:54
Mazdak29-Jan-04 4:54 
GeneralRe: Call Webservice from windows client problem Pin
Heath Stewart29-Jan-04 6:52
protectorHeath Stewart29-Jan-04 6:52 
GeneralRe: Call Webservice from windows client problem Pin
Mazdak29-Jan-04 7:04
Mazdak29-Jan-04 7:04 
GeneralRe: Call Webservice from windows client problem Pin
Heath Stewart29-Jan-04 7:32
protectorHeath Stewart29-Jan-04 7:32 
Generalmultiple search engine querying tool! Pin
mali28-Jan-04 23:15
mali28-Jan-04 23:15 
GeneralRe: multiple search engine querying tool! Pin
Heath Stewart29-Jan-04 3:12
protectorHeath Stewart29-Jan-04 3:12 
GeneralCancel Button on collection Editor Pin
arti_ab28-Jan-04 22:50
arti_ab28-Jan-04 22:50 
GeneralRe: Cancel Button on collection Editor Pin
Heath Stewart29-Jan-04 3:07
protectorHeath Stewart29-Jan-04 3:07 
Write your own custom collection editor and make a deep copy of the object which you're trying to edit before displaying it in the collectio editor form you'd create. The reason this is happening is because the collection editor is responsible for editing the collection. The objects in that collection are references to objects elsewhere, something the collection editor does not care about. By making a deep copy of the collection you are creating new objects to which the collection of objects reference. Depending on your implementation, though, this might now work.

Say that the collection references a bunch of controls in your form. If you make a deep copy, edit it, and replace the original copy you have to remove all the old controls from the Controls collection of the control or form and add the new ones. If all the collection contains is a bunch of strings, ListViewItems, etc., then this is probably okay to do.

You could make it easy and extend the CollectionEditor, override EditValue, and re-use the CollectionEditor.CollectionForm. Just remember to change the EditorAttribute on the property that is of the collection Type (or on the collection class itself).

One final option uses the DesignerTransaction, though I don't know if it'll work in this case. Since an IServiceProvider is passed to the UITypeEditor.EditValue, you could try getting the IDesignerHost service and call CreateTransaction on it to create an associated DesignerTransaction. You can then commit or undo a batch of operations. You could do something like this:
protected override object EditValue(ITypeDescriptorContext context,
  IServiceProvider provider, object value)
{
  DesignerTransaction trans = null;
  IDesignerHost host = provider.GetService(typeof(IDesignerHost));
  if (host != null)
    trans = host.CreateTransaction();
 
  IWindowsFormsEditorService forms = provider.GetService(typeof(
    IWindowsFormsEditorService));
  try
  {
    CollectionForm form = new CollectionForm(this);
    form.EditValue = value;
    DialogResult result = form.ShowEditorDialog(forms);
    if (result == DialogResult.OK)
    {
      value = form.EditValue;
      if (trans != null) trans.Commit();
    }
    else if (trans != null) trans.Cancel();
  }
  catch
  {
    if (trans != null) trans.Cancel();
  }
  return value;
}
This is a very simple example and untested, but the concept is sound so long as you can use the DesignerTransaction from this context (and I don't see why you couldn't). Read the documentation for the DesignerTransaction in the .NET Framework SDK for more information and an example.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralAssertion in C# app Pin
ip_tgz28-Jan-04 20:23
ip_tgz28-Jan-04 20:23 
GeneralRe: Assertion in C# app Pin
Mazdak28-Jan-04 20:55
Mazdak28-Jan-04 20:55 
GeneralRe: Assertion in C# app Pin
ip_tgz28-Jan-04 22:58
ip_tgz28-Jan-04 22:58 
GeneralRe: Assertion in C# app Pin
Mazdak29-Jan-04 0:02
Mazdak29-Jan-04 0:02 
GeneralRe: Assertion in C# app Pin
Heath Stewart29-Jan-04 2:47
protectorHeath Stewart29-Jan-04 2:47 
Generalcontrolling devices in c# Pin
mahmoud12328-Jan-04 20:11
mahmoud12328-Jan-04 20:11 
GeneralRe: controlling devices in c# Pin
Heath Stewart29-Jan-04 2:42
protectorHeath Stewart29-Jan-04 2:42 
GeneralSecond Time Slow Code Pin
obelisk2928-Jan-04 16:59
obelisk2928-Jan-04 16:59 
GeneralRe: Second Time Slow Code Pin
Le centriste28-Jan-04 18:19
Le centriste28-Jan-04 18:19 
GeneralRe: Second Time Slow Code Pin
obelisk2929-Jan-04 4:44
obelisk2929-Jan-04 4:44 
GeneralRe: Second Time Slow Code Pin
Colin Angus Mackay29-Jan-04 14:48
Colin Angus Mackay29-Jan-04 14:48 
GeneralDataAdapters Pin
MrJJKoolJ28-Jan-04 13:54
MrJJKoolJ28-Jan-04 13:54 
GeneralRe: DataAdapters Pin
Christian Graus28-Jan-04 15:47
protectorChristian Graus28-Jan-04 15:47 
GeneralRe: DataAdapters Pin
MrJJKoolJ28-Jan-04 16:22
MrJJKoolJ28-Jan-04 16:22 
GeneralRe: DataAdapters Pin
Christian Graus28-Jan-04 16:27
protectorChristian Graus28-Jan-04 16:27 
GeneralControls using the form designer Pin
James Simpson28-Jan-04 12:12
James Simpson28-Jan-04 12:12 
GeneralRe: Controls using the form designer Pin
James Simpson28-Jan-04 12:28
James Simpson28-Jan-04 12:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.