473,769 Members | 6,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

References in C#

I've got a form code from which I call ExcelObject class to perform writing
to Excel and saving the sheet. The process is too slow and I'd like to
update my form's status bar's panel with number of records processed.
My question is since the form and ExcelObject are functionally separate
(encapsulation) , how can I update status bar panel from Excel object?

C# supposedly has references but only for passing variables to methods. I
can create a string and pass it to the method by reference and if I change
the value of it inside the method, but how to tie that string to status
bar's panel's text property?

Any ideas?
Nov 16 '05 #1
2 1903
Sauli,

You have to implement events of Excel object. Excel.Applicati on class has
many events based on its functionality.

Set the status bar inside the event.

For example,

When you create a save a workbook, "WorkbookBefore Save" event is fired. You
can have statusbar message there.

Shak
(Houston)
"Sauli V" <spamasNO_SPAM@ TO_MEapplicatio ndesign.net> wrote in message
news:40******** @news.nnrp.ca.. .
I've got a form code from which I call ExcelObject class to perform writing to Excel and saving the sheet. The process is too slow and I'd like to
update my form's status bar's panel with number of records processed.
My question is since the form and ExcelObject are functionally separate
(encapsulation) , how can I update status bar panel from Excel object?

C# supposedly has references but only for passing variables to methods. I
can create a string and pass it to the method by reference and if I change
the value of it inside the method, but how to tie that string to status
bar's panel's text property?

Any ideas?

Nov 16 '05 #2
Sauli V <spamasNO_SPAM@ TO_MEapplicatio ndesign.net> wrote:
I've got a form code from which I call ExcelObject class to perform writing
to Excel and saving the sheet. The process is too slow and I'd like to
update my form's status bar's panel with number of records processed.
My question is since the form and ExcelObject are functionally separate
(encapsulation) , how can I update status bar panel from Excel object?

C# supposedly has references but only for passing variables to methods. I
can create a string and pass it to the method by reference and if I change
the value of it inside the method, but how to tie that string to status
bar's panel's text property?

Any ideas?


Firstly, you need to get the idea of *a* reference and *by* reference
being two different things. See
http://www.pobox.com/~skeet/csharp/parameters.html

Then, what you should do is put the long-running part into a different
thread, and periodically update the status, making sure you use
Control.Invoke to "get back" to the UI thread. I would suggest creating
a public property of the form which your saving code can update, and
which calls Control.Invoke internally. You then pass a reference to
your form to the saving code, and within it you can do

form.Progress = "Starting save";

etc

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3080
by: Tom | last post by:
The motivation for references seems clear: stop people from using nasty pointers when all they really want is a reference to an object. But C++ references are so inadequate that I'm still using pointers for my references to objects. There are 3 reasons why I find them inadequate: 1 - Can't be null. 2 - Can't be reseated. Now I'm sure there are good reasons for these first 2, but it's #3 that I
22
2241
by: xmp333 | last post by:
Hi All, I am trying to hide my JavaScript source. The method I chose was to keep all the important source in a password protected folder, and then use a SRC="folder/script.js" to include it in my code. This way, the script will run, but the user will be unable to view the included code. Or so I think :). I have tried this method, and it seems to work. However, I would like
33
2398
by: JKop | last post by:
I understand variables/objects and pointer variables perfectly: int X = 5; int* pX = &X; *pX = 4; int** ppX = &pX:
2
22291
by: S. van Beek | last post by:
Dear reader, For removing a reference in the VBA reference form I receive from Doug Steele the following code: ........... References.Remove refCurr
11
1991
by: codebloatation | last post by:
I know how to use references but i DO not get WHY they exist other than to add to the language. Are they actually needed for anything?
14
2961
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will utilise the disco file to update the Corresponding proxy file and reflect the changes made to the web service. However, the results of doing this with out params is that the results seem
30
2485
by: jeremygetsmail | last post by:
I've got an adp (Metrix.adp) with a reference to another adp (InteractSQL.adp). InteractSQL sits on a server, and is refered to by all of the clients (Metrix), which sit on the client machines (There's also a SQL Server that sits on the server, but that's besides the point here.). Both adp files have references to ADOX. I've got to check Metrix has an older version of ADOX, and react appropriately. I've written code to do this, and it...
3
2115
by: DonJefe | last post by:
Does anyone have experience using project->project references in large solutions? What are the plus/minuses that you have found? Currently, we are using the binary assembly references for our code, but this becomes problematic when you want to build from multiple branches/working directories. Any thoughts on this would be appreciated. Thanks
9
2472
by: igor.kulkin | last post by:
References is a relatively basic feature of C++ language. It might be a good thing to think of references as aliases to the variables. However it's good to think of references this way when you deal with references which are local variables. But references can also be function arguments (in fact they are more useful this way) in which case it has to have the in-memory representation.
3
3864
by: CenturionX | last post by:
Hello everybody: I'd like to know what references in my vba code are used or not. I work in a code made by another person previously, i founded to many references and i believe that someones are not used. I'd like to optimize the application ereasing the useless references. Thanks a lot.
0
9423
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
10211
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...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
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
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6673
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
5299
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...
1
3959
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

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.