Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

mrithula8

@mrithula8
About
Posts
103
Topics
47
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Application failed to initialize
    M mrithula8

    Hi When i try to debug a Windows Application it says "Application failed to initialize properly". It also gives "hpqwmiex Module has encountered a problem and needs to close. We are sorry for the inconvenience". What is that i should be doing for this error

    C# help debugging question

  • Closing the curent process
    M mrithula8

    Hi I used the following code to close the running processes.When i click on the stop button i want to stop all those files that are opened.<pre> currpro = Process.GetCurrentProcess(); foreach (Process proce in currpro) { proce.CloseMainWindow(); }It says, Error 1 foreach statement cannot operate on variables of type 'System.Diagnostics.Process' because 'System.Diagnostics.Process' does not contain a public definition for 'GetEnumerator'

    C# help

  • Client Server
    M mrithula8

    Hi I have used the following code for the client server communication.The start() starts the server and calls the SenMessage() to send the message to the server.This method takes as input the port number of the server that has started. It works fine.Suppose i start 2 servers, then both servers are calling the SendMessage().In this case one server communicates properly.For the 2nd one it says that the existing connection is closed. I think that when the 2nd server starts it should call the sendMessage() with some time delay.I hope that it work then.But im not sure how to do it.Please help me with this.<pre>private void Start_Click(object sender, EventArgs e) { //int n; //label1.Text = "Enter the value of n:"; String n2, n1, n3, n4; n1 = lb4.Text; n2 = lb5.Text; n3 = lb6.Text; n4 = lb7.Text; ProcessStartInfo si1,si2,si3,si4; if (cb.Checked && lb4.Text!="") { si1 = new ProcessStartInfo(n1); proc = Process.Start(si1); proclist.Add(proc); String portno1 = n1.Substring(18, 5); listBox1.Items.Add(portno1); pno1=Convert.ToInt32(portno1); SendMessage(pno1); } if (cb1.Checked && lb5.Text!="") { n2 = lb5.Text; si2 = new ProcessStartInfo(n2); proc = Process.Start(si2); proclist.Add(proc); String portno2 = n2.Substring(18, 5); int pno2 = Convert.ToInt32(portno2); SendMessage(pno2); } } public void SendMessage(int portnumber) { try { UdpClient client = new UdpClient("127.0.0.1", portnumber); listBox2.Items.Add("Connected"); Byte[] data = new Byte[256]; String snd = "hello"; data = Encoding.ASCII.GetBytes(snd); IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), portnumber); int n = client.Send(data, data.Length); listBox2.Items.Add("Sent..."); listBox2.Items.Add("Message received from {0}:"); listBox2.Items.Add(ipep.ToString()); Byte[] received = new

    C#

  • Retrieving multiple items from listview
    M mrithula8

    hi I have another doubt.If i want to find the selected index of a listbox or a listview control i can use listbox.SelectedIndex; Similarly if i have 5 checkboxes and if i want to find the index of the checkbox that is checked how do i do this?There is no Selected Index property for checkbox. I have the exe files listed and each one is assigned a checkbox.I want to start only those exe files that i select.I am able to do this.After starting the exe files i want the client to send message to only those exe files that have been started. I used the following code to send message to different ports <pre>public void SendMessage() { try { label1.Text = "Enter the number of times to send the message:"; String ns = textBox1.Text; int c = Convert.ToInt32(ns); int[] a = new int[4]; XmlTextReader xtr1 = new XmlTextReader("p1.xml"); XmlTextReader xtr2 = new XmlTextReader("p2.xml"); XmlTextReader xtr3 = new XmlTextReader("p3.xml"); XmlTextReader xtr4 = new XmlTextReader("p4.xml"); int p1 = 0, p2 = 0, p3 = 0, p4 = 0; while (xtr1.Read()) { switch (xtr1.NodeType) { case XmlNodeType.Text: String rv = xtr1.Value; p1 = Convert.ToInt32(rv); break; } } while (xtr2.Read()) { switch (xtr2.NodeType) { case XmlNodeType.Text: String rv1 = xtr2.Value; p2 = Convert.ToInt32(rv1); break; } } while (xtr3.Read()) { switch (xtr3.NodeType) { case XmlNodeType.Text: String rv2 = xtr3.Value; p3 = Convert.ToInt32(rv2); break; } } while (xtr4.Read()) { switch (xtr4.NodeType) { case XmlNodeType.Text: String rv3 = xtr4.Value;

    C#

  • Retrieving multiple items from listview
    M mrithula8

    Hi Its working the way i wanted.I dont understand why the counter should be decremented?

    C#

  • Retrieving multiple items from listview
    M mrithula8

    Hi Thanks its working now

    C#

  • Retrieving multiple items from listview
    M mrithula8

    Hi, I used this code in the selectedIndexchanged().Is this right?I declared the conuter variable inside the class.When i execute the code the form does not respond. <pre>private void listView1_SelectedIndexChanged(object sender, EventArgs e) { ListView.SelectedListViewItemCollection sl = this.listView1.SelectedItems; Label[] lb = new Label[4]; lb[0] = lb4; lb[1] = lb5; lb[2] = lb6; lb[3] = lb7; for (int h = 0; h < sl.Count;){ if(counter<lb.Length) { lb[counter].Text=sl[h].Text; counter++; } } }

    modified on Wednesday, April 8, 2009 5:18 AM

    C#

  • Retrieving multiple items from listview
    M mrithula8

    Hi When i used this, it says invalid static modifier for this item.So i used <pre>static int counter=0</pre> outside the method but im not able to select any item from listview.

    C#

  • Retrieving multiple items from listview
    M mrithula8

    Hi Thanks for reply.I do not want to display the 1st item in the 1st label.Suppose for the 1st time i select the 10th item that should appear in the 1st label.The 2nd time if i select the 5th item it should be displayed in the 2nd the label......Actually i uesd the code in the selected indexchanged event <pre> private void listView1_SelectedIndexChanged(object sender, EventArgs e) { ListView.SelectedListViewItemCollection sl = this.listView1.SelectedItems; Label[] lb = new Label[4]; lb[0] = lb4; lb[1] = lb5; lb[2] = lb6; lb[3] = lb7; for (int h = 0; h <= sl.Count; h++) { lb[h].Text = sl[h].Text; } }

    modified on Wednesday, April 8, 2009 2:18 AM

    C#

  • Retrieving multiple items from listview
    M mrithula8

    Hi I used the following code.Whichever item i select from the listview appears on the 1st label.The item that is selected 2nd does not appear in the 2nd label.Im not clear what sl[1] will contain?Can you tell me the mistake?

    Label[] lb = new Label[4];
    lb[0] = lb4;
    lb[1] = lb5;
    lb[2] = lb6;
    lb[3] = lb7;
    for (int h = 0; h < sl.Count; h++)
    {
    lb[h].Text = sl[h].Text;
    }

    C#

  • CheckedListBox
    M mrithula8

    I tried to list drives available in a system in checkedlistbox.When i click on the C:\ i want to list its files in a listview.I tried with the following but it does not work.Can you give me an alternative.<pre> int p=checkedListBox1.SelectedIndex; if(p==1) { try { reader = new XmlTextReader("path.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Text: //Display the text in each element. // Console.WriteLine(reader.Value); String s1; s1 = reader.Value; String ss; ss = checkedListBox1.CheckedItems.ToString(); String sss = ss + s1; object o3 = (object)sss; DirectoryInfo dire = new DirectoryInfo(sss); //DirectoryInfo[] dirs = dire.GetDirectories(); 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*"); //FileInfo[] fi = dire.GetFiles(); foreach (String filename in files) { lvi = new ListViewItem(); lvi.Text = filename; listView1.Items.Add(lvi); } this.Controls.Add(listView1); } } } break; }

    C#

  • Accessing control from multiple forms
    M mrithula8

    Hi I have a listview control in Form1 which displays the file information.I have another listview control in Form2.Whatever gets displayed in listview of Form1 should also be displayed in ;listview of Form2.I tried using the object of Form2 but it dint work.Can you give your suggestions? In form1<pre> for2=new Form2(); for.listView1.Items.Add();

    C#

  • Retrieving multiple items from listview
    M mrithula8

    Hi I have a TableLayoutPanel and i have added label controls to the each cell of its 1st column.Also i have used a listview control to display the list of all files from a directory.For a design purpose, i want the name of the file to be displayed in the 1st label in the 1st cell of the table when i select any file name from the listview control.Similarly when the 2nd item from listview is selected it should appear in the 2nd label. Currently i have a design which has a mapping like when i select on the 1st filename it appears in the 1st label,2nd file name in the 2nd label...the drawback that i face here is that suppose if by random i select 5th filename from listview it appears on the 5th label. I hope im making myself clear.Please help me with this

    C#

  • Retrieving multiple items from listview
    M mrithula8

    ya im sorry

    C#

  • Help required in comparing an image file with a text file
    M mrithula8

    Hi I dont mean text in an image. I have a TableLayoutPanel and i have added label controls to the each cell of its 1st column.Also i have used a listview control to display the list of all files from a directory.For a design purpose, i want the name of the file to be displayed in the 1st label in the 1st cell of the table when i select any file name from the listview control.Similarly when the 2nd item from listview is selected it should appear in the 2nd label. Currently i have a design which has a mapping like when i select on the 1st filename it appears in the 1st label,2nd file name in the 2nd label...the drawback that i face here is that suppose if by random i select 5th filename from listview it appears on the 5th label. I hope im making myself clear.Please help me with this

    C#

  • Retrieving multiple items from listview
    M mrithula8

    Hi I used the following code

    foreach (ListViewItem ltv in listView1.SelectedItems)
    {
    lb4.Text = ltv.Text;

    listView1.SelectedItems gets all the selected items from the listview.The first item that i select from the listview gets displayed in the lb4.I want the next selected item from the listview to get displayed in lb5.I believe that ltv contains the list of all selected items but i do not know how to add it to label.Can you tell me how to do this?

    C#

  • Retrieving multiple items from listview
    M mrithula8

    Hi Can you please tel me how to retrieve multiple items from Listview? If i use

    ListView.SelectedListViewItemCollection sl = this.listView1.SelectedItems;
    lb4.Text = sl[0].Text;

    The item that is selected first from the listview should be displayed in the 1st label added to the TableLayoutPanel.The next selected item from listview should be displayed in the 2nd label added to the Table.Can you please help me with this?

    C#

  • Adding items to TableLayoutPanel
    M mrithula8

    Hi I have added 10 items to ListView control.When i click on the items of listview control it should be added to the column of the TableLayoutPanel.How can i do this?

    C#

  • listing files in C#
    M mrithula8

    Hi I used the following code for listing files

    int h=listBox1.SelectedIndex;
    if(h==0)
    {
    try
    {
    reader = new XmlTextReader("path.xml");

                    while (reader.Read())
                    {
                        switch (reader.NodeType)
                        {
                            case XmlNodeType.Text: //Display the text in each element.
                                //   Console.WriteLine(reader.Value);
                                String s1;
                                s1 = reader.Value;
                                String ss;
    
                                ss = listBox1.SelectedItem.ToString();
                                sss = ss + s1;
                                object o3 = (object)sss;
    
                                DirectoryInfo dire = new DirectoryInfo(sss);
    
                                //DirectoryInfo\[\] dirs = dire.GetDirectories();
    
                                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\*");
    
                                            //FileInfo\[\] fi = dire.GetFiles();
    
                                            foreach (String filename in files)
                                            {
                                                lvi = new ListViewItem();
                                                lvi.Text = filename;
                                                listView1.Items.Add(lvi);
    
                                 lvsi = new ListViewItem.ListViewSubItem();
                                 lvsi.Text = filename.Length.ToString();
                                                lvi.SubItems.Add(lvsi);
                                             }
                                             this.Controls.Add(listView1);
                                        }
                                    }
                                }
                                break;
    
    C# csharp xml

  • Unable to copy error in C#
    M mrithula8

    Hi Thanks it works now

    C# csharp debugging help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups