|
This[^] MSDN page lists all the custom numeric formatting strings. For your requirement, all you need to do is
int x = 2;
string formattedValue = x.ToString("00");
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Lets suppose that your int is i. Then you can use following code:
String intI=i.ToString();
if(intI[0]!='0')
intI="0"+intI;
Console.WriteLine(intI);
Regards,
Wasif Ehsan.
|
|
|
|
|
I am adding reference for microsoft outlook. i have selecting microsoft outlook 11.0 object library.
but in my code it gives error in c#.net 2005. but its working in visual studio 2003. Please help me.
Error:
The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.Office' (are you missing an assembly reference?)
using System;
using System.Collections.Generic;
using System.Text;
//using System;
using System.Reflection; // to use Missing.Value
//TO DO: If you use the Microsoft Outlook 11.0 Object Library, uncomment the following line.
using Outlook = Microsoft.Office.Interop.Outlook;
namespace CheckOutlook
{
class Program
{
static void Main(string[] args)
{
try
{
// Create the Outlook application.
// in-line initialization
Outlook.Application oApp = new Outlook.Application();
// Get the MAPI namespace.
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
// Log on by using the default profile or existing session (no dialog box).
oNS.Logon(Missing.Value, Missing.Value, false, true);
// Alternate logon method that uses a specific profile name.
// TODO: If you use this logon method, specify the correct profile name
// and comment the previous Logon line.
//oNS.Logon("profilename",Missing.Value,false,true);
//Get the Inbox folder.
Outlook.MAPIFolder oInbox = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
//Get the Items collection in the Inbox folder.
Outlook.Items oItems = oInbox.Items;
// Get the first message.
// Because the Items folder may contain different item types,
// use explicit typecasting with the assignment.
Outlook.MailItem oMsg = (Outlook.MailItem)oItems.GetFirst();
//Output some common properties.
Console.WriteLine(oMsg.Subject);
Console.WriteLine(oMsg.SenderName);
Console.WriteLine(oMsg.ReceivedTime);
Console.WriteLine(oMsg.Body);
//Check for attachments.
int AttachCnt = oMsg.Attachments.Count;
Console.WriteLine("Attachments: " + AttachCnt.ToString());
//TO DO: If you use the Microsoft Outlook 10.0 Object Library, uncomment the following lines.
/*if (AttachCnt > 0)
{
for (int i = 1; i <= AttachCnt; i++)
Console.WriteLine(i.ToString() + "-" + oMsg.Attachments.Item(i).DisplayName);
}*/
//TO DO: If you use the Microsoft Outlook 11.0 Object Library, uncomment the following lines.
/*if (AttachCnt > 0)
{
for (int i = 1; i <= AttachCnt; i++)
Console.WriteLine(i.ToString() + "-" + oMsg.Attachments[i].DisplayName);
}*/
//Display the message.
oMsg.Display(true); //modal
//Log off.
oNS.Logoff();
//Explicitly release objects.
oMsg = null;
oItems = null;
oInbox = null;
oNS = null;
oApp = null;
}
//Error handler.
catch (Exception e)
{
Console.WriteLine("{0} Exception caught: ", e);
}
// Return value.
//return 0;
}
}
}
Prya
|
|
|
|
|
Hello
I believe your problem is not in the above code. It should be in your reference.
Revise it.
PS.
Please use the <pre> headers next time you post a code.
Regards
|
|
|
|
|
I am able to create a balloon tooltip from the systray of my application.
The problem is that the message displayed by the tooltip is a maximum of 256 characters.
I need the maximum to either be unlimited, or much bigger than 256 characters. Can anyone help me on how to do this?
I know there are a lot of examples on this site about it, I have tried them all except one that is copyrighted.. I don't want to use anyones code that is copyrighted..
Also: I am using a method that is before the supposed .NET 2.0 SDK tooltip handling because for some reason, even though I have .NET 2.0 SDK installed, I can't seem to access any of the balloon tooltip controls that it is supposed to have.. I really don't know why.. I also don't know if the .NET 2.0 balloon tooltip is limited to 256 characters also..
Any help anyone can give on this issue would be .. helpful
Thanks!
|
|
|
|
|
Hello
I tried to show a tooltip of more than 300 chars, using my .Net 2.0 framework & it worked fine.
I don't know about older versions!! Yet MSDN didn't mention any notices about 1.0 & 1.1 frameworks!! Personally I think the problem may be in your code.
Regards
|
|
|
|
|
That's interesting..
I am currently using balloon tooltip handling from before .NET 2.0 which is limited to 256 characters.. but if I could get .NET 2.0 SDK working that would be great..
Might you know why I can't use the 2.0 balloon functions/structures? I installed .NET 2.0 SDK and am using Microsoft Visual Studio .NET 2003 but I can't see any of the .NET 2.0 code for handling the balloons.
Perhaps I need to update the MSDN documentation? I really don't know.
|
|
|
|
|
Hello
Just in case that .Net 1.1 tooltip class doesn't support more than 256 chars - I must tell you I strongly doubt it!!-, you should change the reference of "system.windows.forms.dll" of your project to the dll file in your .Net 2.0 SDK's folder. Remember, don't add it. Change it.
Regards
|
|
|
|
|
omgwoot wrote: I installed .NET 2.0 SDK and am using Microsoft Visual Studio .NET 2003 but I can't see any of the .NET 2.0 code
You can't use VS 2003 with .Net 2.0. Either purchase an 2005 version of VS or just use one of the freely available Express editions. They can be installed side by side and not interfere with each other.
Don't try to mix them. You will fail.
|
|
|
|
|
i want to show in a tree XML file, the problem is that i want the tree to have only the element name inner text, how can i do it, i always have a problem with the function:
<folders>
<folder>
<name>80
<folder>
<name>Madona
<media>
<file>C:\songs\80\Madona\Like a vergin.mp3
<file>C:\songs\80\Madona\papa.mp3
<folder>
<name>Madona
<media>
<file>C:\songs\80\Madona\Like a vergin.mp3
<file>C:\songs\80\Madona\papa.mp3
<folder>
<name>90
<folder>
<name>Metallica
<media>
<file>C:\songs\90\metallica\blackend.mp3
<file>C:\songs\90\metallica\unforgiven.mp3
what do you say
The tree should look like this:
80
madona
madona
90
metallica
Thanks
|
|
|
|
|
Your XML isn't displayed properly. Replace the < and > tags with [ ] and repost. People here understand that [ and ] map to < and > respectively. You might then get a quicker answer.
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
|
Is there a way to run an app as a system-user on the compact framework?
I need to do some stuff with the certificate store, and I keep getting no-permission errors..
Help would be much appreciated !
|
|
|
|
|
I'm quite certain that the Windows Mobile supports RunAs.
|
|
|
|
|
Allright, that's good to know!
Then I'll just have to find out, how to actually do it.
|
|
|
|
|
I have a datagrid with a dataset table as it's datasource and a tree with a copy of the original dataset table as it's datasource. The datagrid dataset can be changed, but the tree needs to stay constant.
This is for a biology app. After I add nodes for each Family\Genus\Species to the tree I want to go back through it and add a (number) after each node to designate how many collections are under each node.
This works fine on faster processors but not on slower as the processors hit 100% and take up to 8 minutes to run. It takes 8 seconds when it doesn't hit 100%.
Here is the code that adds the (number) after each node:
public void AddCollectionsToNodes()
{
this.collectionTree.SuspendLayout();
this.CollectionsDataGrid.SuspendLayout();
string oldFilter = "";
if(dsCollections.Tables[0].DefaultView.RowFilter != null)
{
oldFilter = dsCollections.Tables[0].DefaultView.RowFilter;
}
try
{
foreach(TreeNode all in this.collectionTree.Nodes)
{
foreach(TreeNode family in all.Nodes)
{
string filter = "";
if(oldFilter.Trim().Length > 0)
{
filter = oldFilter + " AND Family_Name='" + family.Text + "'";
}
else
{
filter = "Family_Name='" + family.Text + "'";
}
dsCollections.Tables[0].DefaultView.RowFilter = filter;
int rowCount = dsCollections.Tables[0].DefaultView.Count;
family.Text += " (" + rowCount + ")";
if(rowCount > 0)
{
foreach(TreeNode genus in family.Nodes)
{
int count = 0;
for(int i = 0; i < rowCount; i++)
if(dsCollections.Tables[0].DefaultView[i]["Genus_Name"].ToString().Trim() == genus.Text.Trim())
count++;
genus.Text += " (" + count + ")";
if(count > 0)
{
foreach(TreeNode species in genus.Nodes)
{
count = 0;
for(int i = 0; i < rowCount; i++)
if(dsCollections.Tables[0].DefaultView[i]["Specific_Epithet"].ToString().Trim() == species.Text.Trim())
count++;
species.Text += " (" + count + ")";
if(count > 0)
{
foreach(TreeNode infra in species.Nodes)
{
count = 0;
for(int i = 0; i < rowCount; i++)
if(dsCollections.Tables[0].DefaultView[i]["Infra_Epithet"].ToString().Trim() == infra.Text.Trim())
count++;
infra.Text += " (" + count + ")";
}
}
}
}
}
}
}
}
}
catch ( System.Exception e)
{
MessageBox.Show (String.Format ("Error: {0}", e.Message), "Add Number of Collections to Family Nodes");
}
dsCollections.Tables[0].DefaultView.RowFilter = oldFilter;
this.collectionTree.ResumeLayout();
this.CollectionsDataGrid.ResumeLayout();
this.collectionTree.Nodes[0].Expand();
}
Thanks for any ideas!
RABB17
|
|
|
|
|
Look at the number of nested for loops you have and its no wonder it pegs the processor.
If you need to get the number of child nodes use node.Nodes.Count.
|
|
|
|
|
Problem is, (number) is not the number of child nodes, it's the number of collections that will be seen in the datagrid for that particular parent/child/child node.
|
|
|
|
|
Can you return the number of these collections from the database? Get a second resultset from your query and use it to populate the treeview.
|
|
|
|
|
Populate the treenode by issuing a select that returns COUNT and put that number in the node.
|
|
|
|
|
What is the best way to return more than one value back from a method?
I have a method that I'm calling that I want to return back some data, a primary key, and the datetime stamp. I was thinking of returning a struct back, but was wondering if there was a better way?
Tom
|
|
|
|
|
A struct or some out variables on the signature, depending on if the struct makes any sort of sense beyond being a way to return the values.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You can also use "out" paramaters, which let you pass information back as a write only variable.
private string ReturnStuff(out var1, out var2)
{
var1=something;
var2=something;
return primaryKey;
}
Note these are Write-Only variables.
Aaron
|
|
|
|
|
Hi,
i need to display the selected folder name from a browse folder dialog on clicking "ok" button in another dialog in a text box,the user should not be able to edit this, i have disabled the text box on creation itself.Please help me with the code since i have to deliver my application by tomorrow evening.
Awaiting ur replies
Thanks
Shruthi
|
|
|
|
|
To pass info between forms, use a delagate.
x2pca wrote: Please help me with the code since i have to deliver my application by tomorrow evening.
That's very troubling.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|