|
snehanp wrote: immediate help will be appreciated.......
It may be appreciated, but it's not going to be forthcoming in the way you want.
snehanp wrote: i need the code in c#......
Well, that's the name of this forum so at least you got that right. Unfortunately for you though, you aren't my boss so I'm proceeding to urgently not writing the code for you.
Yes - you can set timers on every selected item, and you'd then handle the timer events for each one. It sounds like you want to create a list of timers and deal with them like that.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
thanks Pete if possible can u kindly help with the code whenever possible at ur pace.......i hav posted the code i hav done.....what i am doin is that i am first manually adding numbers to the listview and then on select index change i hav set the timer....
|
|
|
|
|
I knocked this quick sample together, and it should do what you want:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SimpleWinApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
_list.Add("Hello");
_list.Add("There");
_list.Add("What do you think");
_list.Add("Hello");
_list.Add("There");
_list.Add("What do you think");
_list.Add("Hello");
_list.Add("There");
_list.Add("What do you think");
_list.Add("Hello");
_list.Add("There");
_list.Add("What do you think");
_list.Add("Hello");
_list.Add("There");
_list.Add("What do you think");
_list.Add("Hello");
_list.Add("There");
_list.Add("What do you think");
int i = 0;
foreach(string item in _list)
{
listView1.Items.Add(new ListViewItem(string.Format("{0}. {1}", i++, item)));
}
}
private List<string> _list = new List<string>();
private List<Timer> _timers = new List<Timer>();
private void listView1_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
Timer timer = new Timer();
timer.Interval = 1000;
timer.Tag = e.Item;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
_timers.Add(timer);
}
void timer_Tick(object sender, EventArgs e)
{
Timer timer = sender as Timer;
if (timer != null)
{
timer.Stop();
timer.Tick -= new EventHandler(timer_Tick);
ListViewItem item = timer.Tag as ListViewItem;
item.Remove();
_timers.Remove(timer);
}
}
}
}
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hey pete thanks a ton.......it solved my problem......
modified on Friday, June 5, 2009 2:22 AM
|
|
|
|
|
You're welcome.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi friends
for example here Main form(this is not maximized form) in which if i click button it will open new maximized form, after i doing the job i will close it.
problem is that after closing child form the parent MDI form is becoming maximized automatically.
can any one help to fix this problem
thanks
|
|
|
|
|
Thats by default. Do one thing, dont maximize the child form so as to prevent the parent MDI from maximizing.
|
|
|
|
|
child form has to be maximized, is there any other tech to handle ?
|
|
|
|
|
Uhm forgive me if I'm wrong, I have not worked with MDI for 15 years, but isn't an MDI main form a container for child forms and as such has to "contain" the child. Is it possible to drag a child form outside an MDI container these days. If this is the case then your question is a really dumb one.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I want build a BHO which controls internet Explorer(IE6 or IE7) on client side. Intially, How can I get the .Net control of an HTML page?
|
|
|
|
|
Read the Microsoft documentation.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi, In my database table i have column with data like
00987
78960
89760
08123
009876
when i read the value(00987) into the integer variable, then it contiana value as 987.
I need the value in integer variable as same(00987). How can i do this?
int k = Convert.ToInt16(dt.rows[i]["colname]);
G. Satish
|
|
|
|
|
00987 is the same as 987. If you read it into an integer variable, then it will remove leading zeros. If you want to display it as it is in the database, then convert it to a string instead of an integer
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Do you know how to count ?
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
This data is stored as a string in your database. 00987 is exactly the same as 987 - I assume you want it displaying as 00987; in which case you need to use a string to display it.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Satish - Developer wrote: when i read the value(00987) into the integer variable, then it contiana value as 987.
I need the value in integer variable as same(00987)
You have to do nothing (or just review your basic math course material), since 000987 = 987 holds for a integer.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I suppose that what you really wanted to ask is: how to read a data with leading zeros and don't loose these zeros.
You have two possibilities:
- Store the number asa string in your application and parse it each time you need it for calculations.
- Create a structure which would store a number of zeros (I would do it this way).
internal struct IntWithZeros
{
private int zerosCount, value;
public static implicit operator int(IntWithZeros x)
{
return x.value;
}
public static IntWithZeros Parse(string data)
{
IntWithZeros ret;
ret.zerosCount = 0;
while (data.Length > ret.zerosCount && data[ret.zerosCount] == '0') {
ret.zerosCount++;
}
ret.value = int.Parse(data);
return ret;
}
public override string ToString()
{
string s = value.ToString();
return s.PadLeft(s.Length + zerosCount, '0');
}
}
Greetings - Jacek Gajek
|
|
|
|
|
private void btnUseLeadingZero_Click(object sender, EventArgs e)
{
int MyNumber = 987;
string MyNumberWithLeadingZero = MyNumber.ToString("00000");
MessageBox.Show(MyNumberWithLeadingZero);
}
|
|
|
|
|
Simplier and better. 5 from me.
Greetings - Jacek Gajek
|
|
|
|
|
Hi guys,
I had just posted a question about getting the path of the current executable. Thanks to all those who responded. However, I found this peice of code while googling just now, and this really seems to work:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
System.Reflection.Assembly a = System.Reflection.Assembly.GetEntryAssembly();
string baseDir = System.IO.Path.GetDirectoryName(a.Location);
Console.WriteLine(baseDir);
Console.ReadLine();
}
}
}
Here, Console.WriteLine(baseDir); prints the path of the .exe.
However, I want that the current executable be copied and moved using the System.IO; .NET class library namespace.
Some thing like this:
Instead of printing the path address with Console.WriteLine(baseDir); , I want to replace it with: System.IO.File.Copy("basedir", "C:\\desiredlocation");
But this code:
System.IO.File.Copy("basedir", "C:\\desiredlocation"); doesn't seem to work.
Can anyone help me out?
|
|
|
|
|
ShreeR.Bhattacharjee wrote: System.IO.File.Copy("basedir", "C:\\desiredlocation");
'basedir' shouldn't be in quotes. And that code snippet will copy the entire directory. Useful if you have references you want preserving, but if you just want to copy the executable, you should be specifying a.Location as the first parameter of File.Copy, not basedir
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Hi Computa,
The case remains same though I apply a.Location as the first parameter of File.Copy method.
Throws exception.
Exception type:
IOException
Exception details:
The target file "C:\\DesiredLocation" is a directory not a file.
Anyway, let me explain the problem more clearly. All I want to do is to copy only the .exe file to C:\\DesiredLocation.
Lemme know, if I need to be more comprehensive.
|
|
|
|
|
Try (new System.Uri(a.CodeBase)).AbsolutePath according to MSDN. This is because the CodeBase property is the fully escaped URL, including the file:// part. File.Copy won't accept this, so you need to create a new Uri, which parses it properly, and use the AbsolutePath property (which gets the proper name)
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
I assume that you want to move the file you have referenced in the baseDir variable to the new location - this means you shouldn't put quotes around baseDir in File.Copy, because that's a string literal, not a variable. Change it to
File.Copy(baseDir, @"c:\desiredlocation");
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi Pete,
The code:
File.Copy(baseDir, @"c:\desiredlocation"); throws exception!
Exception type:
IOException
Exception Details:
The target file "C:\desiredlocation" is a diretory, not a file.
PS: I want to copy the exe file namely 'ConsoleApplication1.exe' to C:\desiredlocation and not he entire project.
Any ideas?
|
|
|
|