|
Stephane's idea is probably the best way to embed a Word document in your application. There is another way, though, if you really want to go to all the work, but you should be very familiar with ActiveX programming interfaces.
The WebBrowser control (actually, MSHTML) can host the doc because it is a container. Making your application a valid ActiveX container is very difficult and requires that you implement many interfaces (most of which are not defined in the .NET base class library, so you either have to create an interop assembly or manually define the interfaces with all the right attributes and parameter marshaling). Just to name a view interface, you'll need to read about IOleContainer , IOleDocumentView , IOleWindow , and many more. You can use oleview.exe to examine the interfaces implemented by the Microsoft HTML Document COM object (mshtml.dll) for a list. Not all the interfaces have to be implemented, though.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I found an activex control built by microsoft people that holds an Office document, and you can use it in your forms. I don't have the url, but have the file. I'll put it on my server and you can download it from there.
http://www.juriscomp.com/emp/guille[^]
Free your mind...
|
|
|
|
|
|
Thnx so much Guillermo i've downloaded this activex and i'll test it and citact u back
thnk in advance u was so helpful
|
|
|
|
|
i tryed the activex and it's exactly what iam looking for.
but i have found a web sample writen in vbscript(client side script)
and i wanna know if i can deal with this activex by dynamic serverside script,
or by another words can play with this control by asp.net coz i do not know much about vb syntax.
|
|
|
|
|
What exactly do you want to do ??
I used the ActiveX on a windows form application, but I've never used it on a web page, just saw the example that came with the package.
If you give me a little description about what you want to do, may be I can give you a hand.
Free your mind...
|
|
|
|
|
never mind Guillermo i desided to use it with windows form
but plz allow me to contact u after this. coz i have some problems in this project coz most of my experience in the web field with java(jsp) & asp.net(c#)
thnx so much
|
|
|
|
|
Hi to all and compliments about the site
Is possible in VC#, no with the alias, to make so that the compiler uses in automatic the short name of namespace.
Es instead of:
using System.Window.Forms
public class MainForm: System.Window.Forms.Form
{}
Directly:
using System.Window.Forms
public class MainForm: Form
{}
In this way the code is simpler to read
Thanks Pino
|
|
|
|
|
You definitely should read the C# language specification in the .NET Framework SDK documentation, and should at the very least take a look at some examples. It's important to understand what is in the .NET class library, but it's even more important to know the language you'll be programming in! By far!
What you're looking for is:
using System.Windows.Forms;
public class MainForm : Form
{
} Like most languages, C# statements most often end with a semi-colon (;) and use curly brackets for blocks.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
In old days In FoxPro could generate a page for a given table with edit boxes for every field, some navigation buttons, add, delete, find - all this without too much typing
Is there something like that for C# ?
Datagrid is not an option here because of validations, auto-calculated fields and user preferences
I have a lot of tables with a lot of columns and to create all forms is just overkill.
Any hints please?
Thanks
|
|
|
|
|
C# is a programming languages that targets the Common Languages Runtime. FoxPro is a complete database application environment so it has a lot of bells and whistles like that.
The DataGrid can do all those things you want by overriding key functionality. I suggest you thoroughly examine the methods and properties of the DataGrid . As far as user preferences are concerned, this is not even an issue. As with all preferences, you change the the object in question when either initializing or update it when preferences change.
Windows Forms uses data-bound controls. You can drag-and-drop a table to your form which will create the necessary connection and command objects (although it'd be better to create a new DataSet class (Add New->Class->DataSet) in your project and drag the tables to the designer's surface, then drag the DataSet component from the Component toolbox and select your strongly-typed DataSet . Then you add the appropriate controls to your form, go to the DataBindings category and click the "..." button. The UI is pretty intuitive.
You can find more information by reading some of the articles in the .NET Framework SDK.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hallo
i posted a similarly message a few days before in the vb-forum but unsuccessfully.
is it possible to create a virtual display device?
is it possible to open a form in this virtual device?
i need to do this, because i like to make a screenshot of this form but the form should not be visible for the user. i tryed to make a screenshot, when the form is out of the screen or when it is invisible but of course this doesn't work.
any idea...
regards
bernd
|
|
|
|
|
I want to do something like below(in ASP.NET & C#):
string strupdate = "UPDATE table SET field = field + intvariable WHERE otherfield = yes";
but i don't know how i can do (add a variable value to a numerical field in a ACCESS database).
Please tell me the right string that i can use.
|
|
|
|
|
I don't understand your question. Are you asking how to add (or concatenate) two values, or how to execute the UPDATE statement?
As far as adding or concatenating values, what you typed works fine so long as the field and intvariable are of the same type or are convertable to the same type.
To execute the statement for an Access database, look at the System.Data.OleDb namespace, specifically OleDbConnection , OleDbCommand , and OleDbParameter . Using parameters in your statement makes it easy to execute a statement multiple times by only changing the values of parameters and executing the statement, and saves you from having to do string concatenation (very inefficient if you just use + ) and proper quoting and escaping.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Nazila I thought I might give you a different twist on your question. I write classes that overloaded the toString()'s (if I am being lazy I make them methods) so that I can always get my variables back with the correctly. Example
public class AccessDb
{ //in my data object
public int pInt(int intIn) // This is the lazy way
{// this is only an example I would use inherited base classes and
// overloading the toString it is so much cleaner.
return "'" + intIn.toString() + "'"
}
}
// then later in your Business object code
AccessDB db = new AccessDb();
db.Update("update table set field=" + db.pInt(intvariable)+ "where otherfield=yes");
I started doing this so I don't get caught recoding everytime the database gets switched from Access to MySql or something else happens. I really like insulating the data objects from the business objects and this is a big help in making generic interfaces. My applications can switch database backends by setting preferences which makes my life much better. It is very important to read up on your database access in .Net and get your design down solid first you will need this when you are setting up the data classes. There are a couple of really cool articles on how to implement this.
Let me know what you think of the idea.
Kevin
|
|
|
|
|
Hi,
I'm working with Arrays of strings for which I don't know the Length beforehand. Because I have a boatload of code that needs to index these arrays, I don't want to embed every single line in a try{} block or have an if() statement on every line without looking at other approaches that would save me some syntax. Basically, I want my program to return zero instead of throwing IndexOutOfRangeException. Can anybody point me in the right direction for this?
Thanks,
John
|
|
|
|
|
The only way to do this AFAIK is to create a wrapper class for the array that gives you the behaviour you want. If it's an array of strings, why/how can you return 0, or do you mean an empty string ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Yes, I meant to write empty string. Which leads to my next question, is there some way I can use the Convert.ToInt32, Convert.ToDouble, etc, and have them return 0 if the string is unrecognized?
I spent a minute writing a class that derives from Array but got an error "cannot inheret from special class System.Array." But I'll research that route more thoroughly now.
|
|
|
|
|
Same answer - you can't inherit, you need to contain, your class HAS an array, you can't write a class that IS A array.
So you need a class with static methods that call Convert.ToWhatever, and handle failure the way you want them to.
I'm not suggesting this is a good idea.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Okay, that makes sense. I'll try that. Thanks.
|
|
|
|
|
Perl has made me very soft.
c# is sharpening me up again.
Rgds,
Ian
|
|
|
|
|
Hi everybody
I an all the examples that I have studied so far with regards to remoting there is a server and many clients that communicate with it using either TCP/IP or HTTP. What kind of communication protocol can we use for the case of windows forms that communicate with other windows forms and need to pass data to them. So instead of having a pool of sockets to connect, we have the server (window form father) to create and then send data to the new window form (window form child) and then wait until the child window returns some results. If we use TCP/IP and config files all child processes will use the same port. From my small exeprience I believe that this is at least incorrect. So my question is: does anyone know am effective way to perform that type of communication?
Thank you very much for your time.
Spiros Prantalos
Miami the place to be!!
|
|
|
|
|
The whole application runs on Window Terminal Server
Spiros Prantalos
Miami the place to be!!
|
|
|
|
|
Using a TcpChannel is typical for remoting between app domains on the same machine. There is far less overhead than with HTTP (a protocol over TCP/IP). Using a .config file for remoting configuration (by calling RemotingConfiguration.Configure ) does offer benefits over manual configuration, but you can still specify ports. Each application will have it's own configuration file (named yourappname.exe.config) so you can configure clients to use the same or different ports. Of course, applications that need to communicate with each other via remoting must use the same port. Also note that with remoting, you don't have to use the typical client-server setup. Clients can talk to each other as well as can servers; in essence, each application acts as a client and server (sending requests and getting responses back for both applications).
You should pick up the book ".NET Remoting" from MSPress. It's a good introduction to remoting and covers lots of intermediate and some advanced techniques and topics.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thank you for your help.
After some research I found the following:
--
Let's assume you have two Windows Forms applications, running on a single machine and you want the two applications to be able to communicate with each other. Or suppose you have a Windows service which should exchange data with your GUI application. Which protocol can you use? Remoting!
This is one of the cases where the TCPChannel is extremely helpful as it allows you to specify rejectRemoteRequests="true" upon its construction which limits all incoming connections to the ones originating from your own machine. No need to take too many precautions about security in this case.
However: If you use fixed port numbers for WinForms to WinForms communication, you might run into troubles when running on Windows Terminal Services with two or more users trying to use your application at the same time
--
Unfortunately this is my case.
Spiros Prantalos
Miami the place to be!!
|
|
|
|