|
I created WinMainForm that setted IsMdiContainer=True and added toolBar to WinMainForm in MainProject (that compile to exe).
And I created WinParentForm in ParentProject (that compile to dll).
For example
public class WinMainForm : System.Windows.Forms.Form
{
...
private void openParent_Click(object sender, System.EventArgs e)
{
ParentProject.WinParentForm FormA = new ParentProject.WinParentForm();
FormA.MdiParent = this;
FormA.Show();
}
...
}
About that How can I control the toolBar (in MainProject.WinMainForm) from FormA (in ParentProject.WinParentForm) ?
|
|
|
|
|
If you're looking for an OLE-like way where the toolbar and/or menu updates depending on the current window (or other object), then you should use an interface that objects should implement with a method to pass either the main form's ToolBar or some other similar mechanism. This is more of a provider-based approach, which is far more common in commercial grade applications and is essentially what you see in applications like Microsoft Office and other ActiveX containers like Internet Explorer (which gains the Office buttons when an Active Document like Word Documents are opened inside it).
This also gives you an abstract designer so you don't have to use circular dependencies. Just define that interface in a common DLL that both projects reference (or even in the DLL project you already mentioned - just not in the EXE project since VS.NET can't reference an EXE assembly, even though the command-line compiler can).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can you give me simple or demo project ?
|
|
|
|
|
It's not hard. This is what development is about - researching problems and solutions, designing the solution, and then writing the solution.
Simply define an interface, like IToolBarProvider which has a property or method that takes a ToolBar as a param. Your WinParentForm would implement this interface. WinMainForm - in an override to OnMdiChildActive for example - would reset the toolbar back to the default, determine if the child window class implements the interface, then passes the toolbar to the implementation for it to modify, something like this:
protected override void OnMdiChildActivate(EventArgs e)
{
base.OnMdiChildActivate(e);
IToolBarProvider tbProvider = ActiveMdiChild as IToolBarProvider;
if (tbProvider != null) tbProvider.ModifyToolBar(ToolBar tb);
} In a separate DLL project (or the one that already defines the MdiParentForm , define the interface like so:
public interface IToolBarProvider
{
void ModifyToolBar(ToolBar tb);
} It's a very simplistic example, but you should get the idea and explore it further.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is there any kind of tutorial/source code/anything for C# similar to softwer on this link => http://fma.sourceforge.net
It's mobile phone controlling over your PC and other way around...
Any response is highly appreciated
|
|
|
|
|
If you want to know how what their source code looks like, browse their CVS repository[^] and write your own code. But why do what's already been done? It's GPL'd, so it's free software (as everything on SourceForge seems to be, though some licenses may be more restrictive).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
where do you get an add-in for Visual Studio Pro 2000?
I looked on MS website but didn't find a download... maybe I missed it..
Thanks
Will
|
|
|
|
|
An add-in for what?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
well I was trying to look at a project for Pocket PC and could not fined an emulator or add-in for VS Studio..
sorry for the blurry subject matter
will
|
|
|
|
|
VS.NET 2003 comes with the Compact Framework and I recommend that. If you can find it, the Compact Framework for .NET 1.0 beta (it was released for .NET 1.1) will work.
If you just want an emulator, though, you can download these from http://msdn.microsoft.com[^]. They also come as part of the Pocket PC 2002 and 2003 SDKs, IIRC.
You could always install the .NET Compact Framework into the ROM image (keep in mind this is a hardware emulator - not a software emulator - so it's better) and transfer files using the emulator support software. This allows you to use VS.NET 2002 (without the beta .NET CF) or the command-line tools (comes with the Framework, though the Framework SDK includes additional tools) to write an test mobile apps without having a physical PocketPC device.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thank you very much for the info
Will
|
|
|
|
|
OK, maybe I was bit lazy and looking for easier way to get whole picture ^_^. Thanks anyway Heath you're always coming to my aid it seems
c-ya
|
|
|
|
|
pekica wrote:
maybe I was bit lazy and looking for easier way to get whole picture
Sounds more like looking for the work done for you. It you really want to understand, studying it from another language you can't so easily translate or whatever will teach you far more since you'll actually have to research it instead of just copying and pasting. Would you agree?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yeah... but it will take me a lot more time to research. Nevermind I downloaded SDK and will look into it ^_^ if nothing else it'll remind me of good old Pascal times because of synatax .
c-ya
|
|
|
|
|
Nothing worth understanding every come easy. Do you think the regulars here learned anything by someone just giving us the answer - especially for an entire project? Even if a managed application did exist like you're looking for, it's wrong to just rip-off someone else's work.
Besides, legally, the project you look at is GPL'd. If you create any derivative work (work based on that project or including some of the source code - even modified) you have to GPL your application as well. If you don't, you break the law. If you do GPL your application you break your licensing agreement with Microsoft that you agreed to when you installed Visual Studio .NET (if you did).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This question has 2 parts...either answer would fix a problem for me
My problem is that I need to query a database, and one of my parameters is the text from a combo box. If the user puts an apostrophe, then this messes up my query. So here are my questions:
How would I go about pre-processing a keypress event in a combo box so I can disable specific characters from ever being typed, such as the apostrophe?
~or~
How can I prevent an apostrophe (or probably quotes too) from screwing up transferring rows?
(I'm getting the error when I use this data in a Crystal Report, and when I build a select command for a data adapter, and include the text which contains the apostrophe.)
Thanks for any help, I apprecaite it
|
|
|
|
|
You can prevent apostrophe by placing 2 single apostrophe instead of one...
i.e.
string strName = "baby's day out";
..."where name='"+strName+"'";
change "strName" like this :
string strName = "baby''s day out"
thus after the text has been entered in the combo parse the string for single apostrophe. If present replace that with double like above example and then use the string in ur query.
hope this works...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
Thank you, that worked very well!
|
|
|
|
|
This is what happens when you don't use parameterized commands! I know that I've given you code samples before for this. Creating a SQL command by concatenating your params together is arcane and should not be used in .NET. If you use a SqlCommand , for example, then you should add SqlParameter s to its SqlCommand.Parameters collection property and use @paramname in your query without quotes. The command will do what's necessary. See the documentation for the SqlParameter (or OleDbParameter , or any of the others) in the .NET Framework SDK.
There are also a lot of other benefits to using parameterized commands, such as easy batch processing when you save the parameters as variables and simply update their Value property, then re-execute the command.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I'm trying to populate a TreeView with info I'm gathering via a PeekCompleted callback for a MessageQueue. My PeekCompleted method, which is "void static", does not have any trouble populating a ListBox but the compiler complains that I must use Control.Invoke() from the callback to use TreeNode.Add().
Here are my questions:
1) Why?
2) Should I use Control.Invoke() or do this another way?
All I'm trying to do is build a TreeView using data I collected from a callback method. What are my other options?
TIA,
Matt
|
|
|
|
|
Yes you should use Control.Invoke . This invokes the call on the thread on which the control was created, which is important. You should do this for your ListView as well. Modifying the control from a different thread causes problems in the message queue. The technical details get down into what is encapsulated by the .NET Framework (much of it, anyway): Win32 APIs.
To use Invoke , take a look at this sample code to safely add a TreeNode in the property thread:
internal void SafeAdd(TreeNodeCollection nodes, TreeNode node)
{
if (nodes == null || node == null)
throw new ArgumentNullException(nodes == null ? "nodes" : "node");
if (treeView1.InvokeRequired)
{
Delegate d = new AddTreeNodeHandler(nodes.Add);
treeView1.Invoke(d, new object[] {node});
}
else nodes.Add(node);
}
private delegate int AddTreeNodeHandler(TreeNode node);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi guys,
I am trying to write an application which when installed will keep an watch over the network and generate report about it.
Can any one tell me how can I detect a SOAP call. I want specifically to detect and ensure that a SOAP call has been made and also extract out info like : by which applicaiton(the application and machine name) ,to which server, etc.
Thanks in advance...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
If you're talking about a network filter, you treat it like any other HTTP request or response. Extract the body and check if it uses the SOAP namespace. If so, you can extract additional information from the HTTP headers or from the WS-Routing or WS-Addressing elements, if available in the SOAP header.
If you just want to log information about SOAP calls, you can add a client or server sink to the chain that uses information from the IMessage that's passed to it to log information about the call.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I made 2 events on System.Windows.Form named as Click and DoubleClick.The sample code for them is
private void Form1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Click");
}
private void Form1_DoubleClick(object sender, System.EventArgs e)
{
MessageBox.Show("DClick");
}
but when i clicks(whether single or double) only the Form1_Click event occur.I want that on single click Form1_Click occur and on double click Form1_DoubleClick
occur.In other words i want to perform 2 different actions on single and double-click,please give any sort of help for this problem.
mughalali
|
|
|
|
|
I guess you can go about with it in the following manner...
private int clickCount = 0;
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
clickCount ++;
}
private void Form1_DoubleClick(object sender, System.EventArgs e)
{
if(clickCount>=2)
{
clickCount=0;
MessageBox.Show("double click");
}
}
Cheers !! and have a Funky day !!
|
|
|
|