|
You can do this using databinding, or use events to monitor changes. For example:
class Form1
{
public Form1(ComboBox theComboBoxFromForm2)
{
theComboBoxFromForm2.SelectedValueChanged += MySelectionChangedFunction;
}
void MySelectionChangedFunction(object sender, EventArgs e)
{
this.comboBoxOnThisForm.SelectedItem = ((ComboBox)sender).SelectedValue;
}
}
As I mentioned, you could also do this with databinding. You also do not have to pass the combobox into the constructor; you could setup a public get/set property and do it there. Or you could have some governing code that sets it all up for you. There are many different ways to do this with object oriented programming; you just need an instance of each combo box accessible to some piece of code, and you're good to go.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
There are several ways to do this. You can monitor the combobox events on form2 from form 1 as Judah Himango posted or you can create your own custom events on form2 and montior those from form1.
Those are close to the same so the code example is for this last one: if you are showing form2 using ShowDialog you could always check the properties of form2 after it has closed on your form1.
<br />
class Form1<br />
{<br />
public void Button1_Click(sender object, System.EventArgs e)<br />
{<br />
Form2 frm2 = new Form2();<br />
<br />
frm2.ShowDialog();<br />
<br />
this.DropDownList1.SelectedIndex = frm2.DropDownList1.SelectedIndex;<br />
<br />
frm2.Dispose();<br />
}<br />
}<br />
<br />
Like we said there are many ways to do this and which you choose depends on what you are trying to accomplish.<br />
-Richard
|
|
|
|
|
Hi there
I have a problem where the designer does not support manipulating my third party controls. They can be manipulated programatically with ease. However i would like to exploit the designer for at least previewing the changes.
What i initially wanted to do was insert a method call into InitializeComponent() so that my changes would be picked up in the designer for previewing. But i guess this isn't the way to go?
Anyone any thoughts? or suggestions on how i could achieve this?
Cheers
Richard J
|
|
|
|
|
Hi. I built a client/server system that communicates with sockets. I used System.Net.Sockets.TcpClient and NetworkStream. I wonder if there is a simple way to encrypt the data so that it can not be viewed from outside. Would be greatful for any help
/Robert
|
|
|
|
|
There are plenty of built-in classes to aide you. See the System.Security.Cryptography namespace and its members.
|
|
|
|
|
|
Hello,
I'm developing a windows form client application. It has to work with our server application.
Our server application is a scanning application which needs .tiff files.
What I want to do is to "scan" digital documents such as .doc, .rtf, .pdf, .txt and convert them to .tiff files so the server can handle them. One problem I don't know how to do, and where to start.
So does anyone know a solution for this problem, or at least a direction to look?
Thanks....
Fedor Brouwer
X-Solutions
The Netherlands
|
|
|
|
|
For text, you could just create an in-memory bitmap, draw the text on it, and save to tiff.
For rtf, you should be able to do the same using the RichTextBox control and the DrawToBitmap method of the Control class (.NET v2).
For proprietary, closed types such as doc and pdf, you might need some library to parse them out for custom rendering. I can't help you there; I know there are several PDF reader and writer SDKs out there...I'm not sure if any of them support rendering them to bitmap.
|
|
|
|
|
Following up on Judah's suggestion, you may want to check out this[^] PDF to image converter.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
I need to call a win32 api into c#
can any 1 suggest any example program to help me understand the idea.
Please any1 out there reply coz i realy need help...
|
|
|
|
|
|
Have you not already asked this question in a round about way?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Hi,
I am creating a setup project in Visual Studio. Apart form installation, I also want to run a batch file during setup. How do I do that?
Thanks in advance.
|
|
|
|
|
|
Is it possible to get a readily available directory and file browser control of like windows explorer so that i can have it populated in a treeview from which i can choose whichever file i want to open.
|
|
|
|
|
System.Windows.Forms.OpenFileDialog, System.Windows.Forms.FolderBrowserDialog
|
|
|
|
|
I have a TabControl 'tabcontrol1', which i am populating with 5 tabpages at runtime. Now i also have another TabControl 'tabcontrol2' which has 2 tabpages of its own already. I want to add 'tabcontrol2' on every one of the 5 tabpages of 'tabcontrol1' when they get created during runtime.
Any suggestions !
|
|
|
|
|
You cannot add a control to multiple parents, AFAIK. Since only one tab can be viewed at a time, just add the tabcontrol2 to whichever page happens to be visible at the time.
|
|
|
|
|
Hi,
I want to perform some action by event handling when
the app window go top and not go top when the user choose
another application on the desktop.
I have try Form.Activated, Form.Deactivate, Form.LostFocus,
Form.GotFocus, Form.Enter, Form.Leave, but none of them work !
Could any one help me pls ?
Thanks
|
|
|
|
|
When the form becomes the active form, you should get an Activated event. We would need to see your code if something is not working right.
|
|
|
|
|
I am working on a project which communiactes with a Radio Device (WR G303e Radio Receiver)connected to PC via USB.
I comes with an API WRG3API.DLL implemented as a 32-bit driver.
In the SDK it has examples for Delphi and C/C++.
My Question is.....
How can i import/communicate (with) this dll to work in C#.
I am looking for some1 2 reply... please help me if any1 out there has any info about this issue...
Kind Regards
t4urean
|
|
|
|
|
I would wrap up the appropriate C++ functions in Managed C++ and then access the managed code from C#
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Antony M Kancidrowski wrote: would wrap up the appropriate C++ functions in Managed C++ and then access the managed code from C#
Ant.
do You mean that i have 2 implement all the functions in a c++ class and then import it in c#?
I am a newbie so i didn't actually understand what do u mean. Can u give me example to make me understand more quickly....
Kind Regards
t4urean
|
|
|
|
|
See Nish's article on C++/CLI[^]. Basically, it allows you to compile C++ and expose certain functions to pure managed languages, such as C#.
In C++/CLI, define a C++ class like this:
public ref class MyClass
{
void DoSomething()
{
}
};
Build this C++/CLI class a .dll.
In C#, add a reference to the C++/CLI dll you just built. You can then call the DoSomething method as if it were written in C#. It's really great. Go read Nish's article linked above. There's another article[^] over at MSDN as well.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: How 'bout a little guitar now?
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I understand your idea...
I have 2 define/call all the functions which I need, from the API in c++ class and then include that class in a c# project.
Can you tell me that wouldn't it be better to directly call the functions from the API in c# (I think there is "dllimport" which I am not totally familiar with).
The reason is that my project deals with real time data and I need high speed response. Using indirect function calls may slow up the process???
... What is your opinion ....
Please comment ASAP
t4urean
|
|
|
|