|
Hi;
I have 2 forms (FormA and FormB) and a text box on each (TextBoxA and TextBoxB).
I want to be able to capture my typing in one text box and in one form on the other form text box. ie, I type in TextBox A and same characters show up in TextBoxB
I realize that when I press a key while I am in FormA and TextBoxA, the keypress event is raised. However, I can't figure out how to trigger the same event in FormB and TextBoxB while I am still typing in FormA.
I really want to raise the same event in form B and not just call TextBoxB_KeyPress method in FormB
Any idea
Thanks
|
|
|
|
|
Hello,
The most appropriate way of accomplishing this would be to have FormB subscribe to the event from TextBoxA. Then, within the event handler, do whatever is needed to add the text into TextBoxB.
laptop_01 wrote:
I really want to raise the same event in form B and not just call TextBoxB_KeyPress method in FormB
May I ask why? I don't see a benefit to raising the event vs. using the information you already have. Assuming you do proceed with this goal, it will likely involve sending windows messages to TextBoxB. Once you start doing that, you will need to be careful that focus issues don't crop up. (You don't want to type a character in TextBoxA, only to find that the next typed character only shows up in TextBoxB. This can be worked around if it does happen, though.)
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hi,
I am getting problem in the navigation of windows forms.
I have 2 buttons in a form clicking on which it will open two different forms Form1 and Form2 but it is not closing the previous windows. I got some success using the following code:
private void Btn1_Click(object sender, System.EventArgs e)
{
ParentForm.Hide();
Form fm1 = new Form1();
fm1.ShowDialog();
}
private void Btn2_Click(object sender, System.EventArgs e)
{
ParentForm.Hide();
Form fm2 = new Form2();
fm2.ShowDialog();
}
but again ParentForm.Hide() only hides the other form and eating out valuable resources.
Is there any better method so that I can close the previous Form when I call another Form.Actually I am a novice so please help me.
Thanks in advance
Libpcap2001
|
|
|
|
|
No, you can't close it because that form has the Main function on it. When that function ends, you app ends with it. You can only HIDE it, not close it.
RageInTheMachine9532
|
|
|
|
|
Without understanding what problem (business) you are trying to solve, it is not easy to answer this question.
As you have found, hiding the parent form really starts to eat resources. And if this application evolves into a more complex process, you could find yourself n-deep into multiple forms and then find a need to get back to the parent.
One approach if it solves your problem is to establish the first (parent) form as an MDI parent. This parent becomes a container that all other forms live within. You could use menu selections to decide which child to open, and in creating and opening them you make them MDI children. You are still left with the flexibility at the child and parent level that if you need to pop up a dialog box, you can still create your dialog form and do a ShowDialog() from either level (parent or child) If you need to know of certain events occuring within the children you can establish delegates that raise events in the parent to act upon it. For example:
private void menuChoice_Click(object sender, EventArgs e)
{
Form[] children = this.MdiChildren;
foreach (Form item in children)
{
if (item is MyForm)
{
item.Focus();
return;
}
}
string[] args;
PopulateArguments(args);
MyForm frm1 = new MyForm(args);
frm1.MdiParent = this;
frm1.SomeDelegate += new EventHandler(HandleThisEvent);
frm1.Show();
}
public void HandleThisEvent(object sender, MyEventArgs e)
{
}
This will minimize resources of the 'unhidden' form while putting specific functionality into the children that are opened. You could implement a menu in this scenario....but then you go off into deploying a docking manager and third party controls.....too much to cover here.
Hope this gives you some ideas.
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
Hi i want to access exchane server services through .NET ,
Does it have some object model sort
please guide
P.S. PATWAL
|
|
|
|
|
You can use CDO 1.21 (the COM wrappers for MAPI), but you'll need a lot of workarounds if you have to access task items.
|
|
|
|
|
Hi.
My quest is how to sort fields hierarchical in a Crystal Report from within my c#-application.
I know the way how to sort one field (by DatabaseFieldDefintion and SortField ), but what is about multiple sorting fields in a hierarchy? How to tell the ReportDocument, that there are more sorting fields than only one and how to define more than one fields? How to get them to the DatabaseFieldDefinitons-collection? I havent't found an adequate answer yet.
Here's the code for one sorting field:
DatabaseFieldDefinition _dbFieldDef = repDoc.Database.Tables["EXAMPLE"].Fields["EXAMPLE_NO"];<br />
SortField _sortField = repDoc.DataDefinition.SortFields[0];<br />
_sortField.Field = _dbFieldDef;
Additional Info: I'm developing with VS 2003, C# and Crystal Reports 9 (not CR for .Net).
T. Labenche
|
|
|
|
|
You can set up hierarchical sorting when you define the report definition using their wizard. If your report definition is already created, you can customize the groupings and select multiple sort fields, ordered by precendence ascending. You can also accomplish this using nested groups each with their own sorting.
If you're trying to do this through code, see the documentation for the DataDefinition.SortFields collection/array property. I'm betting you could probably add addition SortField s to it.
Other than that, see the Crystal Reports web site for CR-specific documentation, which should also be included with the product.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi all
Does anyone know how I can play .ra files and other multimedia files using C#
Thanks for help!
Medhat Ramses
|
|
|
|
|
I haven't search CP to see anything exist but in addition to that you can import Windows Media Player ActiveX in your project and use it.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
.ra is RealCrap...er, RealPlayer. Windows Media Player can't play RealAudio streams.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
RealPlayer.
Does realplayer have has any activex or library?
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Yes. It's often embedded into web pages just like Windows Media Player. You can use this in Windows Forms applications as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
RealAudio streams use a proprietary format and require that you have an ActiveX control to play them. RealPlayer has an ActiveX control that you typically find in web pages. If you right-click on the Toolbox in VS.NET and customize, you should see the RealPlayer ActiveX control (or something like that) if you have it installed. When you deploy your application, you must make sure that the clients have RealPlayer installed and that you also ship the interop assemblies that are created when you create the RCW (runtime callable wrapper) for RealPlayer.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
For my application i am generating reports in excel. I am writing the records to a text file and applying the formatting to that and then saving it has excel file. I want to create a new worksheet once the maximum no. of rows reached in an excel worksheet. How to go abt that? pls suggest me a way
|
|
|
|
|
Hi..
As of now most of the examples ,I have encountered on distributed apps,
The server side sends asyncronous notifications to all the clients that have hooked up to the server.
for example in a tyical publish-subscribe example ,say 5 clients
have registered thier callbacks with server and whenever the server gets a magzine detail ,it sends out the info and all the clients get it..That's perfect..
I wanted to build an application wherin the server sends asyncronous messages only to a specific client by identifying the client's credentials when it had first connected to the server .
is it possible...?[Like in a conventional chat application.]
God Is Great
|
|
|
|
|
For every connected client a new Socket object is created. You can store the Sockets in a Hashtable, with some client information as the key. Then you can pick specific Sockets from the Hashtable and send messages only to these clients.
I don't have an example in C#, but if you know Java, try this one (Version 3.1 or lower):
http://cocoswelt.online.de/beginners/english/JavaChat/indexChat.html[^]
|
|
|
|
|
Let me just remind everyone that this guy is a scumbag and his site links to others where people keep illegal copies of current books. Before you rush off to get some books for free, ask yourself if you think it's Ok to steal a car. Is it OK for someone to steal your computer ? What's the difference ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
anybody know how to do tic tac toe games using look ahead function?
|
|
|
|
|
To discuss the look-ahead functions in any game would require quite an indepth discussion on queue theory. This is the fundamental basis for all look-ahead processes since the management of queue depth (how far ahead I look), the evaluation of each queue value (how heavily weighted should a given queue be given to determine best move), and finally queue tie-breaker resolution (two best moves are equal).
I would begin by searching for articles and/or books on either queue theory or architectural implementations of chess. You are more likely to get queue theory searching for chess instead of tic-tac-toe --- but then apply that to your example.
Your approach, however, is a fine way to approach it. Start with something very simple that can do the basics listed above....then try to ramp it up to something far more complex.
BTW--I don't know how widely known this is...but the basics of queue theory that were deployed in BigBlue (the chess game) was the prototype research for improving queue process within MVS.
_____________________________________________
Of all the senses I could possibly lose, It is most often the one called 'common' that gets lost.
|
|
|
|
|
Hi, all!
I want to allow users to change current UI language dynamically (with no application restart). How can I do that when I have already creted MainForm in my C# application? Do I need to recreate it completely?
Thanks.
Regards,
alexx.
|
|
|
|
|
I think it does not matter. All applications use technic with restart after change UI language... So I'll do the same
|
|
|
|
|
Call InitializeComponent() again but it could be dirty way.
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
You have to change the current UI culture by assigning a new CultureInfo to Thread.CurrentUICulture and then re-initialize your controls. You should not, however, call InitializeComponents again because that instantiates and re-adds the controls (so you'll get duplicates) to your container. This means that you'll have to break the designer and move all the property assignments out of that method (or better yet, just pull that method apartment into separate calls to instantiate and add, and to assign properties). This is not very common in applications, however. Most applications - especially larger, more complex applications - require a restart.
Microsoft MVP, Visual C#
My Articles
|
|
|
|