|
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
|
|
|
|
|
Declare a label control array in the Form class like this
public Label[] lblArray = null;
static int counter = 0;
Inside the form load method add your labels like this.....
this.lblArray = new Label[] { label4, label5, label6 };
Then the event should look like this...
private void ListView1_SelectedIndexChanged_1(object sender, EventArgs e)
{
ListView.SelectedListViewItemCollection sl = ListView1.SelectedItems;
for (int h = 0; h < sl.Count; h++)
{
if (counter < lblArray.Length)
{
lblArray[counter].Text = sl[h].Text;
counter++;
}
}
}
I have even checked this myself... Its working for me... without any problem...
Have a Happy Coding.....
|
|
|
|
|
Hi
Thanks its working now
|
|
|
|
|
unmaiyavae work aagutha... illa summa solringla...????
what did you do for decrementing the counter....?????
Have a Happy Coding.....
|
|
|
|
|
Hi
Its working the way i wanted.I dont understand why the counter should be decremented?
|
|
|
|
|
I dont know exactly about your application....
So no comments,....
Anyway!!
Cheers...
Have a Happy Coding.....
|
|
|
|
|
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;
p4 = Convert.ToInt32(rv3);
break;
}
}
a[0] = p1;
a[1] = p2;
a[2] = p3;
a[3] = p4;
listBox2.Items.Add("Connecting....");
ch[0] = cb;
ch[1] = cb1;
ch[2] = cb3;
ch[3] = cb4;
//int r=cb
for (int i = 0; i <= c; i++)
//int i = 0;
//while (i <= 1)
{
UdpClient client = new UdpClient("127.0.0.1", a[i]);
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"), a[i]);
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 Byte[512];
received = client.Receive(ref ipep);
String dataReceived = System.Text.Encoding.ASCII.GetString(received);
listBox2.Items.Add(dataReceived);
listBox2.Items.Add("======================================================================");
if (dataReceived == "Welcome to the Server")
{
if (cb.Checked == true && lb4.Text != "")
{
lb8.Text = "Active";
lb8.BackColor = System.Drawing.Color.Green;
}
if (cb1.Checked == true && lb5.Text != "")
{
lb9.Text = "Active";
lb9.BackColor = System.Drawing.Color.Green;
}
if (cb3.Checked == true && lb6.Text != "")
{
lb10.Text = "Active";
lb10.BackColor = System.Drawing.Color.Green;
}
if (cb4.Checked == true && lb7.Text != "")
{
lb11.Text = "Active";
lb11.BackColor = System.Drawing.Color.Green;
}
}
else
{
lb8.Text = "Inactive";
lb8.BackColor = System.Drawing.Color.Red;
lb9.Text = "InActive";
lb9.BackColor = System.Drawing.Color.Red;
lb10.Text = "InActive";
lb10.BackColor = System.Drawing.Color.Red;
lb11.Text = "InActive";
lb11.BackColor = System.Drawing.Color.Red;
}
client.Close();
}
}
catch (Exception e)
{
listBox2.Items.Add("An Exception Occurred!");
listBox2.Items.Add(e.ToString());
}
}
|
|
|
|
|
you can use the same slvi to get that.
slvi[index].checked will give you the corresponding checkbox of an item is checked or not.....
Have a Happy Coding.....
|
|
|
|
|
Hi ,,
plz reply ;;;;;...........
how I can add css(cascading style sheet ) at run time in html..?????
thanks
|
|
|
|
|
This is not the place for you Kid! Try a different forum
|
|
|
|
|
Hi,
I developed windows application and now want to install that project only on one pc through CD.
So Is there any property want to set while creating the setup.
I want to use it only in one pc. Other people will not use it.
How can I do?
Thanks
|
|
|
|
|
If you want to protect your application from multiple installation use the licensing system.
you can create setup projects to start the installation only when a valid license data is entered. If not the setup will not continue.
Have a Happy Coding.....
|
|
|
|
|
Can you please rectify what exactly you want to do with your Form? Why do u need to install your project only one one computer? Is it too bad?
|
|
|
|
|
Actually I want to prevent the copy of the project. client cant distribute it to other also. So thats why I want to do it.
|
|
|
|
|
Olrite, then I think you have to copyright your project and its contents. Go to Google or MSDN and search 'Copyright Windows Form'. Hope you get your answer.
Happy Programming,
Rajdeep.NET
And hey,
Julien has given you the correct answer. You also can go for that. You can create a Product Key for the set up of your app.
|
|
|
|
|
Hi
my problem is..,
In my c#.net 3.5 windows application,
To my application setup i want to add a word document(here i will give some text)
i want to read that text in one of my form.
how can i read that text.
Please help me itz urgent
modified on Friday, April 3, 2009 7:24 AM
|
|
|
|
|
REPOST[^]
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
to which forum i have to move this?
i thought i am in c#.net forum
---
|
|
|
|
|
you are in the right forum but you need to stick to your original post and not create a new one unless its a different subject.
like i said, look at the guidelines[^]
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
You need to:
1. Read the forum guidlines.
2. Have a go at doing your scholl work.
3. DO NOT REPOST YOUR OWN QUESTION! YOU WILL BE SHOUTED AT!
That was the polite answer.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
You mean an embedded resource in your application which is a word document????
Have a Happy Coding.....
|
|
|
|
|
It Is A C#.net windows application
|
|
|
|
|
Babu!!! I think you really need to find a c# book which can guide you better....
Try to explain your requirement properly so that you will get some valid suggestions....
Have a Happy Coding.....
|
|
|
|
|
i kept my requirement in my question Babu..!
but no suitable answer i found.
|
|
|
|
|
YOur question is not clear....
Do you want to read a word document in runtime???
Do you want to get configuration data from a file while you setup your application??
Do you want add a document to your project, so that you can open and read the document???
What else you want....?????
Have a Happy Coding.....
|
|
|
|