473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem serializing property on custom UserControl

I have a series of simple controls that I created to make some aspects of
Tablet PC programming a little easier. The "Tablet PC" aspects of the
controls are irrelevant to the problem I'm having, but I feel compelled to
mention it because it can be hard for someone to imagine my challenge when I
talk in hypotheticals.

Anyway, these controls each have an Ink property. For non-Tablet
developers, Ink is a class defined in the Tablet PC SDK (1.0+). I've
created a custom UI Editor for my Ink property and it works well at design
time, but as soon as I run the program the changes are gone. I can't seem
to figure out how to make the IDE (Visual Studio EA 2003) recognize the
change to the property and serialize the data.

I'm attaching my project code to this post because I can't really slim it
down and still have it do what I'm trying to do. Those of you who might be
able to help should be able to get past the extra nonsense pretty easily.
This is my first UI Editor so I'm sure the solution is pretty simple.

Here's how I created the editor:

1. First, I have the control (scratchLabel). If that doesn't go without
saying, please stop reading now - you can't help me. ;-)

2. I have a class called InkEditor which inherits from
System.Drawing.Design.UITypeEditor.

3. In the InkEditor class I have overidden the EditValue method to
display a form which captures the ink. This form works on non-Tablet PC
machines as well. Here is the code for that method:

public override object
EditValue(System.ComponentModel.ITypeDescriptorCon text context,
IServiceProvider provider, object value)

{

InkEditorDialog inkedit = new InkEditorDialog();

if (value != null)

{

inkedit.Ink = (Ink)value;

}

else

{

inkedit.Ink = new Ink();

}

IWindowsFormsEditorService winFormEditorService =
(IWindowsFormsEditorService)provider.GetService(ty peof(IWindowsFormsEditorService));

if (DialogResult.OK == winFormEditorService.ShowDialog(inkedit))

{

value = inkedit.Ink;

}

return value;

}

4. In the scratchLabel class (my control), I've put the following
attribute on my Ink property.

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Visible),System.ComponentModel.Edito r
(typeof(InkEditor),typeof(System.Drawing.Design.UI TypeEditor))]

5. I probably should have mentioned it earlier, but my scratchLabel
class is tagged with the [Serializable()] attribute and implements the
ISerializable interface.

6. The following serialization code is included, but it doesn't seem to
ever get called.

public scratchLabel (SerializationInfo info, StreamingContext context)

{

InitializeComponent();

try

{

//deserialize class

this.Ink = (Ink)info.GetValue ("Ink",typeof(Microsoft.Ink.Ink));

}

catch (Exception ex)

{

throw ex;

}

}

//serializes class

void ISerializable.GetObjectData(SerializationInfo info, StreamingContext
context)

{

info.AddValue ("Ink",this.Ink);

}

So the million dollar question is, what am I missing? There must be
something really simple that I need to include to let the IDE know to save
the data.

Thanks for your help.

Rhy Mednick

P.S. The source code for the group of controls in development, for those
interested, is at http://chickenscratch.sourceforge.net and
http://inkmenu.sourceforge.net.


Nov 16 '05 #1
0 3289

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DraguVaso | last post by:
Hi, I'm having some weird behaviour, and I can't find any solution to this. I made a UserControl (uclCommands) which contains a Toolbar (ToolBar1) with Modifiers = Public. I put this...
1
by: Rhy Mednick | last post by:
I'm creating a custom control (inherited from UserControl) that is displayed by other controls on the form. I would like for the control to disappear when the user clicks outside my control the...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
5
by: amatuer | last post by:
hi i have a link from page1 to page2. this link uses a querystring to transfer data. usually i have no problems using querystring t transfer data. bt for the first time page2 does not display.an...
9
by: norvinl | last post by:
Hi, I'm serializing a class and using shared memory / deserialization to send it to other processes. I can serialize with one app and deserialize with another instance of the same app. But...
2
by: she_prog | last post by:
I have a class derived from UserControl. I need to serialize an object of this class, but only some properties of it, as not all properties are serializable (some of the properties coming from...
5
by: Nirdesh | last post by:
Hi, I am serializing a custom class holding some data for my project. This data internally contains a class which contains an event public delegate void MemberModifiedEventHandler(object...
4
by: Jeff | last post by:
hi asp.net 2.0 I have created a custom web control, here is it's header: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditUserBox.ascx.cs" Inherits="Controls_EditUserBox" %> ...
9
tlhintoq
by: tlhintoq | last post by:
Situation: A Windows Form with a single User Control containing 4 custom controls. This lets me drop the User Control on its own form to make it a dialog, or make it part of a larger configuration...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.