Click here to Skip to main content
15,895,794 members
Home / Discussions / C#
   

C#

 
QuestionHow can I set Multi Folder Watcher?? Pin
Rakesh B Singh17-Sep-07 3:11
Rakesh B Singh17-Sep-07 3:11 
AnswerRe: How can I set Multi Folder Watcher?? Pin
Giorgi Dalakishvili17-Sep-07 3:23
mentorGiorgi Dalakishvili17-Sep-07 3:23 
QuestionRe: How can I set Multi Folder Watcher?? Pin
Rakesh B Singh17-Sep-07 23:28
Rakesh B Singh17-Sep-07 23:28 
AnswerRe: How can I set Multi Folder Watcher?? Pin
Giorgi Dalakishvili17-Sep-07 23:30
mentorGiorgi Dalakishvili17-Sep-07 23:30 
QuestionRe: How can I set Multi Folder Watcher?? Pin
Rakesh B Singh18-Sep-07 18:33
Rakesh B Singh18-Sep-07 18:33 
QuestionChange the location of the Shared add-in User.Config File Pin
Seenu_prabakar17-Sep-07 3:03
Seenu_prabakar17-Sep-07 3:03 
AnswerRe: Change the location of the Shared add-in User.Config File Pin
originSH17-Sep-07 3:12
originSH17-Sep-07 3:12 
QuestionPersisting collections - Serialization Problem??? Pin
Johnny J.17-Sep-07 3:00
professionalJohnny J.17-Sep-07 3:00 
I've made an inherited ListView control with a customized ColumnHeader Type.
I've overwritten the Columns property with a collection of my custom
ColumnHeader items. Now I would like to implement serialization so that
columns are persisted from designtime to runtime. But I cannot get it to
work.

I think it's because I don't know how to implement the type converter
correctly. Here's my suggestion for the type converter. Sample code for the
ListView, ColumnHeaderCollection and ColumnHeaderItem is supplied below. Can
anybody tell me what's wrong?

I've got a small test project (C# 2005) that I've stripped of everything but
the important part (the collection) - I cannot get the serialization to
work. I add columns at designtime, but no matter what, the columns are not
persisted to runtime. If anybody has got the time to help me, I can mail the
test project. I would REALLY appreciate any help I can get.

Cheers, Johnny J.



public class MyListViewColumnConverter : TypeConverter
{
public override bool CanConvertTo
(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor))
{
return true;
}
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo
culture, object value, Type destinationType)
{
if (destinationType == typeof(InstanceDescriptor) && value is
MyListViewColumn)
{
MyListViewColumnitem = (MyListViewColumn)value;
ConstructorInfo ci = typeof(MyListViewColumn).GetConstructor(new Type[]
{ });
if (ci != null)
{
return new InstanceDescriptor(ci, null, false);
}
}
return base.ConvertTo(context, culture, value, destinationType);
}
}

**********************************************************
Listview, ColumnheaderCollection, ColumnHeaderItem code:


namespace MyListView
{
public class MyListView : ListView
{
private MyColumnHeaderCollection myListViewColumnHeaders = null;
public MyListView()
{
myListViewColumnHeaders = new MyColumnHeaderCollection(this);
//Other Code
}
public MyListView(IContainer container)
{
myListViewColumnHeaders = new MyColumnHeaderCollection(this);
container.Add(this);
//Other Code
}
[Localizable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor("System.Windows.Forms.Design.ColumnHeaderCollectionEditor,
System.Design, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
[MergableProperty(false)]
public new MyColumnHeaderCollection Columns
{
get { return myListViewColumnHeaders; }
}
//Other Code
}
[DesignTimeVisible(false)]
public class MyColumnHeaderCollection : ListView.ColumnHeaderCollection
{
private SortedList columnList = new SortedList();
public new MyListViewColumn this[int index]
{
get
{ return (MyListViewColumn)columnList.GetByIndex(index); }
}
public override ColumnHeader Add(string str, int width, HorizontalAlignment
textAlign)
{
MyListViewColumn column = new MyListViewColumn(str, width, textAlign);
this.Add(column);
return column;
}
public override int Add(ColumnHeader column)
{
return this.Add(new MyListViewColumn(column));
}
public override void AddRange(ColumnHeader[] values)
{
for (int index = 0; index < values.Length; index++)
{
this.Add(new MyListViewColumn(values[index]));
}
}
public int Add(MyListViewColumn column)
{
int retValue = base.Add(column);
columnList.Add(column.ColumnID, column);
return retValue;
}
public new void Remove(ColumnHeader column)
{
base.Remove(column);
columnList.Remove(((MyListViewColumn)column).ColumnID);
}
public new void RemoveAt(int index)
{
ColumnHeader column = this[index];
this.Remove(column);
}
public new void Clear()
{
base.Clear();
columnList.Clear();
}
}
[DesignTimeVisible(false)]
[TypeConverter(typeof(MyListViewColumnConverter))]
public class MyListViewColumn : ColumnHeader
{
private int m_ColumnID = 0;
private static int autoColumnID = 0;
public MyListViewColumn()
{
Initialize("", 60, HorizontalAlignment.Left);
}
public MyListViewColumn(string str, int width, HorizontalAlignment
textAlign)
{
Initialize(str, width, textAlign);
}
public MyListViewColumn(ColumnHeader column)
{
Initialize(column.Text, column.Width, column.TextAlign);
}
private void Initialize(string str, int width, HorizontalAlignment
textAlign)
{
base.Text = str;
base.Width = width;
base.TextAlign = textAlign;
m_ColumnID = autoColumnID++;
}
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public int ColumnID
{
get { return m_ColumnID; }
}
}
}
Questionfile sharing for web applications Pin
gbabu1717-Sep-07 2:24
gbabu1717-Sep-07 2:24 
AnswerRe: file sharing for web applications Pin
Pete O'Hanlon17-Sep-07 2:56
mvePete O'Hanlon17-Sep-07 2:56 
GeneralRe: file sharing for web applications Pin
gbabu1717-Sep-07 3:45
gbabu1717-Sep-07 3:45 
GeneralRe: file sharing for web applications Pin
gbabu1717-Sep-07 3:48
gbabu1717-Sep-07 3:48 
GeneralRe: file sharing for web applications Pin
Pete O'Hanlon17-Sep-07 4:41
mvePete O'Hanlon17-Sep-07 4:41 
QuestionInserting a row into excel spreadsheet Pin
lourensG17-Sep-07 2:18
lourensG17-Sep-07 2:18 
Questionlooping Pin
Lucky Sheikh17-Sep-07 1:57
Lucky Sheikh17-Sep-07 1:57 
AnswerRe: looping Pin
Colin Angus Mackay17-Sep-07 2:06
Colin Angus Mackay17-Sep-07 2:06 
AnswerRe: looping Pin
Imran Khan Pathan17-Sep-07 2:09
Imran Khan Pathan17-Sep-07 2:09 
GeneralRe: looping Pin
Colin Angus Mackay17-Sep-07 2:29
Colin Angus Mackay17-Sep-07 2:29 
QuestionC# use for Resource Intesive Backend Components Vs C++ Pin
Supercross17-Sep-07 1:52
Supercross17-Sep-07 1:52 
AnswerRe: C# use for Resource Intesive Backend Components Vs C++ Pin
Pete O'Hanlon17-Sep-07 2:14
mvePete O'Hanlon17-Sep-07 2:14 
QuestionChecking for new data in a xml file Pin
anu8117-Sep-07 1:47
anu8117-Sep-07 1:47 
Questionhow to us typed dataset in vb.net 2005 Pin
himanshu p taunk17-Sep-07 1:38
himanshu p taunk17-Sep-07 1:38 
QuestionHow to stop a windows service in Visual Studio 2003 Pin
Diego F.17-Sep-07 1:07
Diego F.17-Sep-07 1:07 
AnswerRe: How to stop a windows service in Visual Studio 2003 Pin
TimFoxell17-Sep-07 1:25
TimFoxell17-Sep-07 1:25 
QuestionA listview-like control for displaying log messages? Pin
Domenic Denicola17-Sep-07 0:17
Domenic Denicola17-Sep-07 0: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.