|
Please - feel free to browse Google[^]
|
|
|
|
|
hi,
I have developed an application.i have to provide audio help of a software.
when the user put the focus on any textbox.i have to provide adiou help for that particular text box.i have written following code:
private void audiobtn_Click(object sender, EventArgs e)
{
if (txtbox1.Focus())
{
System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
myPlayer.SoundLocation = "C:\\WINNT\\Media\\recycle.wav";
myPlayer.Play();
}
if(txtbox2.Focus())
{
myPlayer.SoundLocation = "C:\\WINNT\\Media\\rcle.wav";
myPlayer.Play();
}
if(txtbox3.Focus())
{
myPlayer.SoundLocation = "C:\\WINNT\\Media\\re.wav";
myPlayer.Play();
}
}
problem is that when i click button,automaticaly focus set on first textbox an it plays its given sound.
plzzzzz help me out y this is so?
|
|
|
|
|
Try doing this.
Give the text box a higher tab order. (greater than 0).
if you have a label or something like that give that a tab order 0.
I hope this solves the issue.
rAm
i Think, i Wait, i Fast -- Siddartha
|
|
|
|
|
Hello,
YEP!
Because you are calling the method Focus which setts the focus to the control.
You have to use the "Focused" property which returns a bool!
if(txtbox1.Focused)
{
...
Nicer would be to implement the "GotFocus" event for you textboxes.
There you can store the sender, that you know which textbox has the focus.
If you then inherit you own Textbox, which provides a string property "SoundLocation", which can be set during design or runtime, you wouldn't need a if statement (or switch) at all.
All the best,
Martin
|
|
|
|
|
hi,
can u provide me some chunk of code.how i use GOTFOCUS.
thanks
|
|
|
|
|
Hello,
I did a little test project to show you the possibilities!
Created an inherited TextBox, like suggested with an additional property:
public class TextBoxSound : System.Windows.Forms.TextBox
{
private string _soundlocation = "";
[DefaultValue("")]
public string SoundLocation
{
get
{
return _soundlocation;
}
set
{
if(value!=_soundlocation)
{
_soundlocation = value;
}
}
}
In the Forms code (where I placed the TextBoxSound instances):
public Form1()
{
InitializeComponent();
foreach(Control c in this.Controls)
{
TextBoxSound tbSound = c as TextBoxSound;
if(tbSound!=null)
{
tbSound.GotFocus+=new EventHandler(tbSound_GotFocus);
}
}
}
private void tbSound_GotFocus(object sender, EventArgs e)
{
TextBoxSound tbSound = sender as TextBoxSound;
if(tbSound!=null)
{
ActTextBoxSound = tbSound;
}
}
private TextBoxSound _actTextBoxSound = null;
public TextBoxSound ActTextBoxSound
{
get
{
return _actTextBoxSound;
}
set
{
if(value!=_actTextBoxSound)
{
_actTextBoxSound = value;
}
}
}
private void bPlaySound_Click(object sender, System.EventArgs e)
{
if(ActTextBoxSound!=null)
{
myPlayer.SoundLocation = ActTextBoxSound.SoundLocation;
myPlayer.Play();
}
else
{
}
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
Silly question..
I have a object[] result, and I have about 7000 objects in that array, and I have a functions like below
Process( object[] records)
{
}
If I want to skip the first and last object in the array, and pass it to my Process function. I doing this by inserting into a ArrayList, and skipping the first and last, then converting back to a object[]. But I still feel this is not clean. Anyone with a cleaner suggestion of doing this.
Thanks
Sk8tZ
|
|
|
|
|
object[] records2 = new object[records.Length - 2];
Array.Copy(records, 1, records2, 0, records.Length - 2);
|
|
|
|
|
Sorry, maybe I was not clear on help wanted..
I want to pass values to Process function, but only object in the range from 1000 to 6000
for example.
object[] result = values; // values holds 7000 objects
Process( values );
// Process( values[1000][values.Length - 1000] ); // something like this
Sk8tZ
|
|
|
|
|
yeah sorry i realised that and modified my original post (I hoped to do it before you read it :P
object[] records2 = new object[records.Length - 2];
Array.Copy(records, 1, records2, 0, records.Length - 2);
where 1 is the start index in the original array and records.Length - 2 is the length to copy. So in this case your chopping off the first and last record.
|
|
|
|
|
|
np took me a while the other day to figure out how to do that
I'm so used to working with generic collections I've lost touch with arrays.
|
|
|
|
|
I need to know that when i use "Webclient" class to download file via http protocol such this
Webclient WC=new Webclient();
WC.Download(url,file1);
WC.Download(url,file2);
WC.Download(url,file3);
WC.Download(url,file4);
...
...
...
when the connection is closed? Is it disconnect every time when finished each downloading file? or It will disconnect only when i use "WC.Dispose();"?
Thank for your answers
=)
|
|
|
|
|
Is there any way to remove all the event handlers associated with buttons click event without using -= operator
|
|
|
|
|
With an event you can use only += or -= operator. Actually keyword "event" is modifying a delegate for this behaviour.
|
|
|
|
|
Hello,
A suggestion I gave some time ago and got no feedback, and never tried it myselfe!
But maybe it helps you.
The control class has a member called Events, which is a list of EventHandler (System.ComponentModel.EventHandlerList).
This class provides a method called "RemoveHandler".
Please let me know if it works for you!
All the best,
Martin
|
|
|
|
|
Hi Martin,
Thanks for the reply.
Control class has a "protected" property called Events which I can't use in my code(which is a Outlook addin)becoz I am using CommandBarButton.
|
|
|
|
|
Hello,
Don't care!
I now tested it with an inherited Control, and found out, that it would not fit your needs.
All the best,
Martin
|
|
|
|
|
No there isn't. You can't set an event to be null or something for example, which is strange because it is initialized to be null . Here's my way of going around it:
public event EventHandler ExampleEvent;
public void UnHook()
{
Collection<EventHandler> ExampleHandlers = new Collection<EventHandler>();
foreach (Delegate d in this.ExampleEvent.GetInvocationList())
ExampleHandlers.Add(d as EventHandler);
foreach (EventHandler e in ExampleHandlers)
this.ExampleEvent-= e;
}
I don't know if there's a better way for this, but this works for me...
Standards are great! Everybody should have one!
|
|
|
|
|
Hi
Is there any support in c# to create and save animated gifs yet?
If so can it be done in c# express and a code snippet would be helpfull.
ty
|
|
|
|
|
I suggest using GIMP.
-^-^-^-^-^-
no risk no funk
|
|
|
|
|
Can anyone explain why EditorAttribute is sealed, whilst DisplayNameAttribute isn't ?
I've no desire to base anything on the latter, but I would like to add some stuff to the former, as things stand I have two attributes, EditorAttribute and MyEditorAttribute, when one would suffice if I could inherit from EditorAttribute.
|
|
|
|
|
hi
any body can help how to develop or to create search engine for a job portal on .net with sqlserver which supports caching
|
|
|
|
|
This is way too big a question. Do you have some sort of design? What problems are you facing?
Don't take this the wrong way, but this is not the place to give your requirements and get a complete app in return.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
Hi vikram thanks for ur reply,
Actually i want the design and introduction to start the search engine development becoz we can use this component any where in the project tats we r planning to develop an serch engine.
thanks
|
|
|
|