Click here to Skip to main content
15,886,026 members
Home / Discussions / C#
   

C#

 
AnswerRe: array to array copy Pin
PIEBALDconsult11-Aug-10 3:08
mvePIEBALDconsult11-Aug-10 3:08 
QuestionMoving the multiple files from one to another location Pin
annie_bel10-Aug-10 23:33
annie_bel10-Aug-10 23:33 
AnswerRe: Moving the multiple files from one to another location Pin
Nuri Ismail10-Aug-10 23:48
Nuri Ismail10-Aug-10 23:48 
AnswerRe: Moving the multiple files from one to another location Pin
Islorvat11-Aug-10 0:51
Islorvat11-Aug-10 0:51 
GeneralRe: Moving the multiple files from one to another location [modified] Pin
annie_bel11-Aug-10 1:26
annie_bel11-Aug-10 1:26 
GeneralRe: Moving the multiple files from one to another location Pin
annie_bel11-Aug-10 1:56
annie_bel11-Aug-10 1:56 
AnswerRe: Moving the multiple files from one to another location Pin
Luc Pattyn11-Aug-10 1:39
sitebuilderLuc Pattyn11-Aug-10 1:39 
QuestionDesign-Time editor for Custom object stores value into *.resx with $ variable prefix Pin
Bouditch10-Aug-10 23:01
Bouditch10-Aug-10 23:01 
Hi,
I made my custom editor for my object using listdictionary type where I store the collection of objects.

I have an ancestor form where I am trying to create the property with binded designer. That will be used for specification
of datagridview columns in inherited form. But main methods must be in an ancestor.

[Browsable(true)]
[Category("BrowserForm")]
[EditorAttribute(typeof(DisplayColumnsEditor), typeof(UITypeEditor))]
public ListDictionary DisplayColumns
{
    get { return displaycolumns; }
    set { displaycolumns = value; }
}


There is the code for the editor:

using System;
using System.Drawing.Design;
using System.ComponentModel;
using System.Windows.Forms.Design;
using System.Collections.Specialized;
using System.Windows.Forms;
using System.Collections;

namespace mynamespace
{
    [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
    class DisplayColumnsEditor : UITypeEditor
    {
        public DisplayColumnsEditor()
        {
        }

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc == null)
            {
                return null;
            }

            ListDictionary editval;
            
            
            if (value == null)
            {
                editval = new ListDictionary();
            } else 
            {
                editval = (ListDictionary)value;
            }
            
            
            using (DisplayColumnsEditorDialog form = new DisplayColumnsEditorDialog(editval))
            {
                if (edSvc.ShowDialog(form) == DialogResult.OK)
                {
                    context.OnComponentChanged();
                    return (object)form.Current;
                }
            }

            return value;
        }
    }
}


there is the class for the listdictionary objects:

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;

namespace mynamespace
{
    [Serializable()]
    public class DisplayColumn : ISerializable
    {
        private string _name;
        private string _headertext;
        private string _datapropertyname;
        private int _width;

        public DisplayColumn()
        {
            this._name = "";
            this._datapropertyname = "";
            this._headertext = "";
            this._width = 100;
        }

        public DisplayColumn(string colname)
        {
            this._name = colname;
            this._datapropertyname = colname;
            this._headertext = colname;
            this._width = 100;
        }

        public string Name
        {
            get
            {
                return this._name;
            }
            set
            {
                this._name = value;
            }
        }

        public string HeaderText
        {
            get
            {
                return this._headertext;
            }
            set
            {
                this._headertext = value;
            }
        }

        public string DataPropertyName
        {
            get
            {
                return this._datapropertyname;
            }
            set
            {
                this._datapropertyname = value;
            }
        }

        public int Width
        {
            get
            {
                return this._width;
            }
            set
            {
                this._width = value;
            }
        }

        public DisplayColumn(SerializationInfo info, StreamingContext ctxt)
        {
            Name = (String)info.GetValue("Name", typeof(string));
            DataPropertyName = (String)info.GetValue("DataPropertyName", typeof(string));
            HeaderText = (String)info.GetValue("HeaderText", typeof(string));
            Width = (int)info.GetValue("Width", typeof(int));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("Name", Name);
            info.AddValue("DataPropertyName", DataPropertyName);
            info.AddValue("HeaderText", HeaderText);
            info.AddValue("Width", Width);
        }

    }
}


The editor uses classical windows forms(IWindowsFormsEditorService) and returns a listdictionary collection. If it will be needed I can include the code for it. But I can ensure it returns really listdictinary collection.

Tha main trouble consist of storing value into resource file of inherited form. When I use the designer
and open the resource file there is a key named: $this.DisplayColumns and not just DisplayColumns.
This name of key is problematic, because value is available only for the designer, but not present in run-time.

in inerited form's resource file it creates following node:

  <data name="DisplayColumns" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>
        AAEAAAD/////AQAAAAAAAAAMAgAAAElTeXN0ZW0sIFZlcnNpb249Mi4wLjAuMCwgQ3VsdHVyZT1uZXV0
        cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAtU3lzdGVtLkNvbGxlY3Rpb25z
        LlNwZWNpYWxpemVkLkxpc3REaWN0aW9uYXJ5BAAAAARoZWFkB3ZlcnNpb24FY291bnQIY29tcGFyZXIE
        AAADPFN5c3RlbS5Db2xsZWN0aW9ucy5TcGVjaWFsaXplZC5MaXN0RGljdGlvbmFyeStEaWN0aW9uYXJ5
        Tm9kZQIAAAAICBxTeXN0ZW0uQ29sbGVjdGlvbnMuSUNvbXBhcmVyAgAAAAkDAAAABgAAAAMAAAAKDAQA
        AABHU09QUlZDb3JlLCBWZXJzaW9uPTEuMC4zODcyLjI1NTAwLCBDdWx0dXJlPW5ldXRyYWwsIFB1Ymxp
        Y0tleVRva2VuPW51bGwFAwAAADxTeXN0ZW0uQ29sbGVjdGlvbnMuU3BlY2lhbGl6ZWQuTGlzdERpY3Rp
        b25hcnkrRGljdGlvbmFyeU5vZGUDAAAAA2tleQV2YWx1ZQRuZXh0AgQEIlNsaW0uU09QUlYuU09QUlZD
        b3JlLkRpc3BsYXlDb2x1bW4EAAAAPFN5c3RlbS5Db2xsZWN0aW9ucy5TcGVjaWFsaXplZC5MaXN0RGlj
        dGlvbmFyeStEaWN0aW9uYXJ5Tm9kZQIAAAACAAAABgUAAAAFR2NfSUQJBgAAAAkHAAAABQYAAAAiU2xp
        bS5TT1BSVi5TT1BSVkNvcmUuRGlzcGxheUNvbHVtbgQAAAAETmFtZRBEYXRhUHJvcGVydHlOYW1lCkhl
        YWRlclRleHQFV2lkdGgBAQEACAQAAAAJBQAAAAYJAAAAC2RhdGExMDBrX2lkBgoAAAACSURkAAAAAQcA
        AAADAAAABgsAAAAHR2NfVEVYVAkMAAAACQ0AAAABDAAAAAYAAAAJCwAAAAYPAAAABXRleHQxBhAAAAAE
        VEVYVGQAAAABDQAAAAMAAAAGEQAAAAhHY19DSVNMTwkSAAAACgESAAAABgAAAAkRAAAABhQAAAAFY2lz
        bG8GFQAAAAfEjMOtc2xvZAAAAAs=
</value>
  </data>


in inherited form's designer.cs it creates a row, where it loads its value:

this.DisplayColumns = ((System.Collections.Specialized.ListDictionary)(resources.GetObject("$this.DisplayColumns")));


but I would need just:

this.DisplayColumns = ((System.Collections.Specialized.ListDictionary)(resources.GetObject("DisplayColumns")));


Is there anyone, who has an idea what does this cause? Is this caused by using serialization? Or am I doing anything else wrong, beacuse I did not implement any TypeConverters? Is this normal "store key" with $ prefix of collections for resource files? D'Oh! | :doh:
JvR

QuestionECG wave extraction Pin
biaali10-Aug-10 22:56
biaali10-Aug-10 22:56 
AnswerRe: ECG wave extraction Pin
riced11-Aug-10 1:01
riced11-Aug-10 1:01 
Question.net remoting Pin
Member 59031010-Aug-10 20:01
Member 59031010-Aug-10 20:01 
Questioninstall sql server 2005 Pin
ram_kesari10-Aug-10 17:26
ram_kesari10-Aug-10 17:26 
AnswerRe: install sql server 2005 Pin
Luc Pattyn10-Aug-10 17:52
sitebuilderLuc Pattyn10-Aug-10 17:52 
AnswerRe: install sql server 2005 Pin
Abhinav S10-Aug-10 18:07
Abhinav S10-Aug-10 18:07 
QuestionHelp: Can't format string using String.Format Pin
roman_s10-Aug-10 9:17
roman_s10-Aug-10 9:17 
AnswerRe: Help: Can't format string using String.Format Pin
Ennis Ray Lynch, Jr.10-Aug-10 9:29
Ennis Ray Lynch, Jr.10-Aug-10 9:29 
AnswerRe: Help: Can't format string using String.Format Pin
OriginalGriff10-Aug-10 9:32
mveOriginalGriff10-Aug-10 9:32 
AnswerRe: Help: Can't format string using String.Format Pin
Luc Pattyn10-Aug-10 9:34
sitebuilderLuc Pattyn10-Aug-10 9:34 
AnswerRe: Help: Can't format string using String.Format Pin
ignrod10-Aug-10 9:42
ignrod10-Aug-10 9:42 
AnswerRe: Help: Can't format string using String.Format Pin
Martin shooster10-Aug-10 10:17
Martin shooster10-Aug-10 10:17 
AnswerRe: Help: Can't format string using String.Format Pin
PIEBALDconsult10-Aug-10 17:24
mvePIEBALDconsult10-Aug-10 17:24 
AnswerRe: Help: Can't format string using String.Format Pin
Luc Pattyn10-Aug-10 17:51
sitebuilderLuc Pattyn10-Aug-10 17:51 
GeneralRe: Help: Can't format string using String.Format Pin
PIEBALDconsult11-Aug-10 3:09
mvePIEBALDconsult11-Aug-10 3:09 
GeneralRe: Help: Can't format string using String.Format Pin
Luc Pattyn11-Aug-10 3:25
sitebuilderLuc Pattyn11-Aug-10 3:25 
GeneralRe: Help: Can't format string using String.Format Pin
PIEBALDconsult11-Aug-10 16:17
mvePIEBALDconsult11-Aug-10 16:17 

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.