|
no this will not work. because you are creating a new lvi.
Have a Happy Coding.....
|
|
|
|
|
Hi
Can you please tell why it adds "started.." as a sub item for last item?Why does it not display it as the sub item for the 1st item?
|
|
|
|
|
Not sure what's the problem....
but instead of this
foreach(Process pr in proclist)
{
String proname = pr.ProcessName;
lvsi=new ListViewItem.ListViewSubItem();
lvsi.Text="Started...";
lvi.SubItems.Add(lvsi);
}
try this
foreach(Process pr in proclist)
{
String proname = pr.ProcessName;
//listBox4.Items.Add(proname);
lvi.SubItems[1].Text = "started";
}
Make it sure that you are executing this code after adding the item to the list view... otherwise you may get an exception in the blocked line.
Have a Happy Coding.....
|
|
|
|
|
Hi
It tells that 1 is not valid argument index.
|
|
|
|
|
how many column headers you have???
because the subitems index always starts from 0.
can you post the entire code block of the listcontrol??? if possible...
Have a Happy Coding.....
|
|
|
|
|
Hi
I have created 3 column headers
private void CreateHeadersAndFillListView()
{
colHead = new ColumnHeader();
colHead.Text = "Servers";
colHead.Width = 250;
listView1.Columns.Add(colHead);
colHead = new ColumnHeader();
colHead.Text = "Status";
colHead.Width = 100;
listView1.Columns.Add(colHead);
colHead = new ColumnHeader();
colHead.Text = "Last accessed";
colHead.Width = 100;
listView1.Columns.Add(colHead);
}
private void PaintList(String sss)
{
try
{
reader = new XmlTextReader("path.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Text:
String s1;
s1 = reader.Value;
String ss;
ss = listBox4.SelectedItem.ToString();
sss = ss + s1;
object o3 = (object)sss;
DirectoryInfo dire = new DirectoryInfo(sss);
if (dire.Exists)
{
String[] folder;
folder = Directory.GetDirectories(sss);
foreach (string foldername in folder)
{
DirectoryInfo di = new DirectoryInfo(foldername);
if (di.Exists)
{
String[] files;
files = Directory.GetFiles(foldername,"*.exe*");
foreach (String filename in files)
{
lvi = new ListViewItem();
lvi.Text = filename;
listView1.Items.Add(lvi);
}
this.Controls.Add(listView1);
}
}
}
break;
}
}
}
catch (System.Exception err)
{
MessageBox.Show("Error: " + err.Message);
}
}
private void Start_Click(object sender, EventArgs e)
{
String n2, n1, n3, n4;
n1 = lb4.Text;
n2 = lb5.Text;
n3 = lb6.Text;
n4 = lb7.Text;
ProcessStartInfo si1;
if (cb.Checked)
{
n1 = lb4.Text;
si1 = new ProcessStartInfo(n1);
proc = Process.Start(si1);
proclist.Add(proc);
}
if (cb1.Checked)
{
n2 = lb5.Text;
ProcessStartInfo si2 = new ProcessStartInfo(n2);
proc = Process.Start(si2);
proclist.Add(proc);
} foreach(Process pr in proclist)
{
ListViewItem.ListViewSubItem lvsi = new ListViewItem.ListViewSubItem();
lvsi.
lvsi.Text = "Started..";
lvi.SubItems.Add(lvsi);
}
|
|
|
|
|
Hi,
If i add subitem like the following it just gives the subitem "Started" corresponding to every item in listview.But what i require is that when the server starts it must display the subitem "Started.." to the corresponding item (server) that has started.
DirectoryInfo di = new DirectoryInfo(foldername);
if (di.Exists)
{
String[] files;
files = Directory.GetFiles(foldername,"*.exe*");
foreach (String filename in files)
{
lvi = new ListViewItem();
lvi.Text = filename;
listView1.Items.Add(lvi);
lvi = new ListViewItem();
lvi.SubItems.Add("Started..");
listView1.Items.Add(lvi);
}
this.Controls.Add(listView1);
|
|
|
|
|
So you finally got that....!!! Hail Hurray!!!
If you want to show the status dynamically, then you need to go for threading.....
Dedicate a thread specifically for updates and things will work...
Have a Happy Coding.....
|
|
|
|
|
Hi
I tried with the following code. It displays "Started" as a subitem for the 2nd item in listview control
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = "Started..";
listView1.Items[1].SubItems.Insert(1, lvsi);
If i use
listView1.Items[0].SubItems.Insert(0, lvsi);
it displys "started " as an item and not a subitem like
Server status Last accessed
started
Server1.exe
...
....
Can you give me some suggestions
|
|
|
|
|
I use this code to get all files from a folder or drive
public static string[] GetFilesPaths(string directory)
{
List<string> filesPaths = new List<string>();
GetDirectories(directory, filesPaths);
return filesPaths.ToArray();
}
static void GetDirectories(string dir, List<string> filesPaths)
{
filesPaths.AddRange(Directory.GetFiles(dir));
string[] subdirectoryEntries = Directory.GetDirectories(dir);
foreach (string subdirectory in subdirectoryEntries)
GetDirectories(subdirectory, filesPaths);
}</string></string></string>
you can get string[] and then you can add 'em in ListView...ListView is slow BTW, use DataGridView instead.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
modified on Wednesday, March 25, 2009 3:13 AM
|
|
|
|
|
Just a point of curiosity. Why do you pass the List by reference? I thought that a collection can be added to without passing by reference
|
|
|
|
|
Computafreak wrote: I thought that a collection can be added to without passing by reference
yes, you're right...thanks
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi every body
I'm Malkan
How are you?
I have small problem.
This is my code:
1- int? g;
2- g = vamTableAdapter1.SelectShomvam(textBox1.Text, textBox2.Text);
3- decimal? h = vamTableAdapter1.SelectMablkol(System.Convert.ToInt32(g));
The input of third line is Int and the output of it is Decimal?
this line(third)worked well already.But after change my database......
They are my errors
"Specified cast is not valid"
"when casting from number the value must be a number less than infinity"
But I know taht my code are true.
Plese help me
Thanks alot
|
|
|
|
|
Convert.ToInt32 is going to return a value that equates to infinity if g is not a number.
Your code is really crappy, please tell me you're a first year student ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi
Thanks
G is a number(Int?)
I don't a first year student,but I like C#
I want to learn Programing with C#.please help me.I like codeproject.I studied computer.
Thanks alot
modified on Wednesday, March 25, 2009 5:36 AM
|
|
|
|
|
Christian Graus wrote: Convert.ToInt32 is going to return a value that equates to infinity if g is not a number
MSDN:
Convert.ToInt32
Returns ... zero if value is null.
FormatException value does not consist of an optional sign followed by a sequence of digits (zero through nine).
OverflowException: value represents a number less than MinValue or greater than MaxValue
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi All,
The problem that we are facing is that we are unable to connect the windows service through the socket running on computer A from the windows application running on computer B. The following are the steps that we have followed.
At Window Service Side running on Computer A:-
· We have created a window service and under OnStart event we have initialize the object of TCP listener through port 8001.
· Start the TCP listener.
· Made a thread for WaitingForClient and start this thread so that it always lies in listen mode for accept the socket from Computer B.
· In the method WaitingForClient we have accepted the socket and start another thread for read this socket.
At Window Application running on Computer B:-
Made a socket that has AddressFamily InterNetwork, SocketType is stream and ProtocolType is TCP.
Made the object of IPEndPoint by initialize it through IP address of Computer A and Port 8001.
When we connecting this socket to the Computer A through IPEndPoint, it does not connect and throws the exception of connection timeout.
Plese Help............
Thanks and Regards,
Lalit Narayan
|
|
|
|
|
Does it work if you run the client and service on the same machine? If so, it's probably a firewall blocking your port.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Hi Nick,
Thank u very much,u have solved my problem in one line,i have just turn off my firewall and my program started working.
Regards,
Lalit Narayan
|
|
|
|
|
hi all
i have been trying to use nhunspell but a error always comes ;
error is given below:
Could not load file or assembly 'NHunspell, Version=0.5.2.42123, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)
I was trying to implement the nhunspell for nepali language but since the error i have not been able to work ahead.
I would be very happy if anyone could help me out.
Thanking you in advance.
With regards
Sagun shrestha
|
|
|
|
|
Your best bet is to contact the vendor to determine what configuration is needed.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
I want to do a topic on the management staff! Include add, delete employee, the employee by the employee by day with the number of each person, all information is entered in the file!
programming language C + + or C #? please help me! many thanks
|
|
|
|
|
What's your requirement???
"topic on the management staff!"
what do you think that it could mean?????
Please post a question which is more meaningful.....
Have a Happy Coding.....
|
|
|
|
|
hoale2008 wrote: programming language C + + or C #?
Well, that depends. Does that mean you know both languages equally well, and yet felt the need to ask this, or does it mean you're clueless and whichever answer I give, that's the forum you'll fill with inane questions that would be easily answered by google, or common knowledge to anyone who has ever used the language in question ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Use a database. If you want ease of use, then stick with C# - you haven't known true pain until you've grappled with pointer arithmetic in C++
|
|
|
|