|
|
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; }
}
}
}
|
|
|
|
|
i have a .net(C# + asp.net) web application that needs to show a set of log files on the browser once the user is logged in. The user should be able to download the files by clicking or right click->save as.
any ideas or samples will be thankful.
|
|
|
|
|
Here's[^] a sample that shows you how to do this.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
thanks for the reply.
I think the sample you mentioned will directly downlaod all the files without any selection.
i want the user to click a file and then download.
|
|
|
|
|
thanks for the reply.
I think the sample you mentioned will directly downlaod all the files without any selection.
i want the user to click a file and then download.
i mean i want the files names as a kind of links on the web page.
|
|
|
|
|
To do this, you need to build the list of links yourself, and dynamically attach an event handler which handles it in the same way that the button click does in the article.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I want to insert 2 rows into my spreadsheet but I have a dataset that is inserting values into the spreadsheet and I want to insert the rows after that values from my dataset.please help thanks.
|
|
|
|
|
how to loop the label or textid in C#.net
as per vb
textboxname.text=cmd.executescalar()
but it,s not working in c#.net
anyone tell me the suggestion now
lucky
|
|
|
|
|
Lucky Sheikh wrote: how to loop the label or textid in C#.net
as per vb
textboxname.text=cmd.executescalar()
but it,s not working in c#.net
anyone tell me the suggestion now
What do you mean "loop the label or textid"?
The code you have written puts the value of the first column of the first row in the Text property of the text box. It won't loop over anything.
|
|
|
|
|
textboxname.text=cmd.executescalar()
ExecuteScalar returns object.
You assigned this object to var string so that u r getting error here
try this code
textboxname.text=cmd.executescalar().ToString();
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
Imran Khan Pathan wrote: textboxname.text=cmd.executescalar().ToString();
And if the result set contains zero rows this will fail also.
|
|
|
|
|
Hi All...
I work for a software development company which writes Telephony solutions.. All of our backend components are written in C++ but the problem I am finding is it is taking us to long to get products to market and am looking for a quicker means of writting these applications.. I have been researching and toying with the idea of moving some of our newer products to C# to try and improve stability and simplicity in our applications. The only thing I am unsure about is the performance aspect and if C# can do just as much as C++ can. We use Threads, Handles and pointer list's extensivly. These applications are real-time applications and need to perform task's quickly and efficiently without delay. Maybe I am asking to much of having the best of both worlds but any advice would be appreciated..
|
|
|
|
|
A common misconception is that C# cannot work with pointers. This is not true. While it is not recommended to work directly with pointers, you can do it by marking regions of code as unsafe, so you could move highly intensive pointer based code into these areas. I would question though, whether or not this is a route you would want to go down when you can mix C++ and C# projects in the same solution.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hi all,
I have a xml file of the following format.
<xml version="1.0" encoding="UTF-8">
<MainCategory>
<category1>
<title>First Title</title>
<Description>Some description</Description>
</category1>
<category2>
<title>Second Title</title>
<Description>Some description about the second category</Description>
</category2>
</<MainCategory>
</xml>
the data from the xml file is stored in a datatable and set as a datasource to datagridview.
now when a new entry is added to the top of the xml file, say like this,
<xml version="1.0" encoding="UTF-8">
<MainCategory>
<NewCategory>
<title>New Title</title>
<Description>description about new category</Description>
</NewCategory>
<category1>
<title>First Title</title>
<Description>Some description</Description>
</category1>
<category2>
<title>Second Title</title>
<Description>Some description about the second category</Description>
</category2>
</<MainCategory>
</xml>
how can i check the xml file for new changes and display the values for the new categories alone?
this xml file is not stored in the local machine. how can i accomplish the same without storing the xml file locally?
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
how to insert,update and delete records in a SQL Express 2005 database using typed dataset in c#.net 2005
himanshu p.taunk
|
|
|
|
|
Hello. In Visual Studio 2005, there is a Stop method that you can call from any method to stop the service. That is useful in case something went wrong.
I see that in Visual Studio 2003, that method doesn't exist. How can I then stop the service from code?
Regards,
Diego F.
|
|
|
|
|
Hi Diego,
Although I'm not 100% sure of how to do it, hopefully this puts you in the right direction. A service can only be started or stoped by the OS (for what I understand anyways...). So to stop it you either have to use the Services management snap-in in Win2k / XP etc or the NET command from the command prompt. Stopping it from your code is probably going to be easier from the latter...
NET Stop <servicename>
Hope this helps!
Having said all the above... have a look see here... http://support.microsoft.com/kb/245230[^]
TimmyFox
|
|
|
|
|
Hi there,
I'd like a control to display my log messages for my application, apart from the simple RichTextBox idea. I was thinking something that would have a separate row for each item, something like a ListView, in that sense. The best thing I've seen is in this screenshot:
http://www.feedghost.com/Promo/ShowScreen.aspx?id=5
But, I'd like to not have all those columns---just the titles and excerpt text .
Can anyone point me toward such a control, or perhaps tell me how to bend ListView to my will?
-Domenic Denicola- [CPUA 0x1337]
“I was born human. But this was an accident of fate—a condition merely of time and place. I believe it's something we have the power to change…”
|
|
|
|
|
I find this[^] control to be very flexible/powerful when it comes to working with lists of data.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Dear all,
I'm working with a Microsoft outlook add-in. There are 2 kinds of email item. One is normal email from the internet, called SMTP email. The other is from Exchange Server, called EX email.
I want to get the sender email address when user click on a email item.With the smtp email, I can get the sender email easily. I have a big problem when user click on EX email type, an email is from Exchange Server. The SenderEmailAddress is not as usual. It is like: mail.SenderEmailAddress = "/O=ABC ORGANIZATION/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=MYTESTING"
I found one way on internet for this problem, but it is not success when i applied.
<br />
public static string GetFromAddress(MailItem mail)<br />
{<br />
MailItem objItem;<br />
MAPI.Session objSession;<br />
MAPI.Message objMsg;<br />
MAPI.AddressEntry objSender;<br />
String strAddress;<br />
String strName;<br />
String strEntryID;<br />
objOutlook = GetApplication();<br />
strName = mail.SenderName;<br />
strEntryID = mail.EntryID;<br />
objSession = new MAPI.Session();<br />
object pobjMissing = System.Reflection.Missing.Value;<br />
objSession.Logon("", "", pobjMissing, pobjMissing, pobjMissing, pobjMissing, mail.SenderEmailAddress);<br />
objMsg = (MAPI.Message)objSession.GetMessage(strEntryID, false);<br />
objSender = (MAPI.AddressEntry)objMsg.Sender;<br />
strAddress = objSender.Address.ToString();<br />
objSession.Logoff();<br />
return strAddress;<br />
<br />
<br />
}<br />
Although I have tried for 2 days, I have no any good solutions.
Please give me a hand to solve this issue.
Thanks
-- modified at 6:10 Monday 17th September, 2007
Banana
|
|
|
|
|
First thing to try:
mySenderAddress = (message.SenderName == null) ? String.Empty : message.SenderName;
Second thing to try:
mySenderAddress = ((MAPI.AddressEntry)message.Sender).Address.ToString();
____________________________________
There is no proof for this sentence.
|
|
|
|
|
Thanks for your answer, Corinna John
Could you please tell me more detail about message variable. Is it a objMsg variable in my example?
<br />
objSession.Logon("", "", pobjMissing, pobjMissing, pobjMissing, pobjMissing, mail.SenderEmailAddress);<br />
objMsg = (MAPI.Message)objSession.GetMessage(strEntryID, false);<br />
If yes, I still got the wrong email address. Its format is like "/O=ABC ORGANIZATION/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=MYTESTING"
If no, please tell me how to get that message variable.
Are there any other ways to get email address sender of email from Exchange Server without log on.
Thanks for your advance.
-- modified at 23:02 Monday 17th September, 2007
-- modified at 3:25 Wednesday 19th September, 2007
Banana
|
|
|
|
|
Your logon fails because the last parameter is wrong. You don't specify username/password, which menas to use the acount of the currently active user. The profile info parameter tell Exhange to use the sender's profile. That doesn't make much sense, does ist?
The correct call to logon as the current Outlook user is:
<br />
objSession.Logon("", "", false, false, pobjMissing, pobjMissing, pobjMissing);<br />
The rest should work after you got a session. For further information please see MSDN:
http://msdn2.microsoft.com/en-us/library/ms526377.aspx
http://support.microsoft.com/?scid=kb%3Ben-us%3B171422&x=10&y=13
And the samples at CDO Live:
http://www.cdolive.com/code.htm
____________________________________
There is no proof for this sentence.
|
|
|
|
|
Hi, i have one button1 hwo starts the timer:
Timer oT = new Timer();
oT.Tick+= new System.EventHandler(TimerFunction);
oT.Interval = 15000;
oT.Start();
private void TimerFunction(object o, EventArgs e)
{
//////////my code
}
My question is how do i stop the timer with a button2 click???
And do u know any good sleep or wait function???
Thanks!!!;);P
|
|
|
|
|