开发者

can we access form controls from an external assembly (dll assembly not within the project)?

开发者 https://www.devze.com 2023-02-09 05:29 出处:网络
I have to access label control of running form from referenceed assembly to change label text dynamically.My application scans all the files of selected folder.I have to show name of the file which is

I have to access label control of running form from referenceed assembly to change label text dynamically.My application scans all the files of selected folder.I have to show name of the file which is currently in开发者_Python百科 progress.

Can we access form controls from an external assembly (dll assembly not within the project)?


Your DLL could trigger an event e.g. FileProcessing whch has some information passed with it (current filename etc) which your c# application could then subscribe to and that way your DLL doesn't have to know anything about the application that is using it, and your application can just update the label each time the event is raised...Here's an overview of events for c# on MSDN

Edit
Try this code Project article "The Simplest C# Events Example imaginable". It says it's designed to just be copy/pasted into a new project so you should be able to get a quick working example to see the concept. In regards to your situation, the Metronome would be your File System Scanner and instead of "Tick Events", you've have FileProcess/FileScan events. The Listener from the example would be your C# UI application. That way your c# app is basically waiting for your File Scanner to raise events at which point it can then use the information passed (an example also in the link) to update the Label

0

精彩评论

暂无评论...
验证码 换一张
取 消