473,809 Members | 2,951 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing Form Elements - From Static Event Messages

2 New Member
I'm building a simple C# Win App to monitor some directories and then
kick of some processes - when files hit the system.

Right now everything works except that i have a listView control on a form
and when i click the button to tell the app to start monitoring.

I cannot get the "addItems() " method to update the Forms listView - it won't even compile.

Any Ideas

I have only been using C# for about 2 months on and off.


Expand|Select|Wrap|Line Numbers
  1.     private static void OnChanged(object source, FileSystemEventArgs e)
  2.         {
  3.             addItems(e.FullPath, "changed");
  4.         }
  5.  
  6.         private static void OnCreated(object source, FileSystemEventArgs e)
  7.         {
  8.             addItems(e.FullPath, "created");
  9.         }
  10.  
  11.         private static void OnRenamed(object source, RenamedEventArgs e)
  12.         {
  13.             addItems(e.FullPath, "renamed");
  14.         }
  15.  
  16.         private static void OnDeleted(object source, FileSystemEventArgs e)
  17.         {
  18.             addItems(e.FullPath, "deleted");
  19.         }
  20.  
  21.         private static void addItems(string fp, string info) {
  22.             System.Windows.Forms.ListViewItem lvi = new System.Windows.Forms.ListViewItem(fp);
  23.             System.Windows.Forms.ListViewItem.ListViewSubItem lvsi = new System.Windows.Forms.ListViewItem.ListViewSubItem(lvi ,info );
  24.             Console.WriteLine("File name triggering event {0}, action - {1}", fp, info);
  25.            //lsvFiles.Items.add(lvi);
  26.         }
Mar 6 '07 #1
2 1080
kenobewan
4,871 Recognized Expert Specialist
Have you tried referencing the item that you are adding the items to? For example, listitem1.addIt em(e.FullPath, "changed"); I thought that it was additem not additems.
Mar 7 '07 #2
seanjones
2 New Member
Have you tried referencing the item that you are adding the items to? For example, listitem1.addIt em(e.FullPath, "changed"); I thought that it was additem not additems.
In C# its listView1.Items .add(listViewIt em) i.e. - //lsvFiles.Items. add(lvi);

when i uncomment that line - i get compile exception
Mar 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
3627
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
4
9308
by: Stuart Perryman | last post by:
Hi, I have the following code which works just fine in IE6 but not in Firefox. It is an extract of several table rows each with an individual form. It is generated by php. <form action="MaintNotification.php?ReqID=5" method="post" name="frm5"> <tr align="left" bgcolor="#dddddd" class="text" onClick="submit()"
6
2749
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is called "form1", and I have selects called "PORTA", "PORTB" ... etc...
2
22653
by: David N | last post by:
Hi All, The OnLoad() event is invoked automatically when a form is being loaded. Do we have another event that is invoked automatically after a form has completed loading? Thanks.
3
1439
by: Greg Merideth | last post by:
An app I'm working on has a "message" box docked to the bottom of the window to display messages. I've added a series of child windows to the main form and wanted to keep passing messages into the docked window. The main app has a method to take the string, format it and then add it to the rich text box. I created a delegate to be able to call the main methods RichTextAddLine but in order to get it to work I had to set the richtextBox...
4
7270
by: jedimasta | last post by:
Good evening all, I'm a relatively new to javascript, but I've been working with ColdFusion and PHP for years so I'm not necessarily ignorant, just stuck and frustrated. Using ColdFusion I'm using an include to pull in form elements (text fields, checkboxes, etc...) multiple times on a single page. The included page does not have a form tag of it's own, but the root page has uniquely named forms for validation. Imagine it like this:
6
10428
by: Chuck Anderson | last post by:
My knowledge of JavaScript is limited. I learn from example and then adapt those examples to suit my needs. I have stumped myself on this one. I have a form with checkboxes that I want to group by using a two dimensional array. <form name=msgs>
11
3004
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether certain fields match certain criteria, and inform the user in different ways when the data is wrong (offcourse, this will be checked on posting the data again, but that's something I've got a lot of experience with). Now, offcourse it's...
5
2883
by: Paul Brettschneider | last post by:
Hello, I have a global static array of structs and want to access a given element using an identifier. I don't want to use the element subscript, because it will change if I insert elements before the element I want to access. In assembler I would simply add a label in front of the element, but this doesn't work in C++. The following programm snippet might explain what I want to do:
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10633
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.