|
You need to set it again, obviously
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I know, so i have reset it again, but it still keeps it as blank.
string displayMember = theComboBox.DisplayMember; // Collect the DisplayMember value, because its going to be blank for some reason immediately after re-setting the DataSource.
theComboBox.DataSource = theNewDataSourceObjet;
theComboBox.DisplayMember = displayMember;
Now even though i have re-set the DisplayMember, it is still string.Empty.
Why???????
|
|
|
|
|
The combo box doesn't have a databind method ? the new data source has the same object available as a data source ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Its there. My point is why can't I simply set the control's DataSource property? Is there any special reason that i have to clear the bindings and then add a new binding. Why can't i simply re-set the data source propery and re-set the DisplayMember property straigt-away.
Just curious?
I want to know why's of this so it will help my fundamental understanding. Please help and clarify.
|
|
|
|
|
Setting a datasource does exactly that. But, the datasource is not actually used to do anything until you call DataBind. That's what the method is for, to create a gap between setting a source and using it, so you can set these other properties.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Chris. I get it now.
ONe other question - i am trying to filter teh combobox. When i reset the datasource such that the reset datasource now has less number of items than before. When the new data is displaed, the drop-list window keeps the original size (i.e. the size when it had more items in the list) although the current list is less and hence the drop-list looks pretty ugly, because there is more blank space visible in the drop-list than is neccessary to hold the new fewer items of data. If i manually click hte drop-down arrow to close the window and reopen it then the size is correctly refreshed.
So, I tried to simulate this in code by setting DroppedDown to false and then to true so that i could simulate it to close and re-open the list, but it does not fix the issue.
Is this a known bug in combobox control.
-- modified at 20:41 Wednesday 11th January, 2006
|
|
|
|
|
To be honest, I've never heard that one before, it could be a bug.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi!
if you want to filter your combobox, i suggest to use a dataview as your datasource.
then you can just past your filter to the RowFilter property of the dataview.
this will also solve your problem regarding the dropdown size and if ever you want to sort the items, you can set it to the Sort property of the dataview.
hope that helps!
|
|
|
|
|
Thanks and i will look into that too!
|
|
|
|
|
Hi,
I have a datagrid/datatable and when I click on a row, I want to see if it's already selected (so I can unselect it). What's the syntax for that?
Thanks,
Mel
|
|
|
|
|
Sorry, I didn't see it at first, but I stumbled upon the IsSelected method. Guess that makes sense.
Cheers,
Mel
|
|
|
|
|
if I have some sound Files , and I want to play them one after the other , the performance of hearing them not good because the time to call each one . So, I try to use a MemoryStream to make the sound files become a single group so, I will need only one call , but I failed to make it .
Then I used FileStream to create a sound file and I called it "sound.WAV" , and by using for loop append the sound files in "sound.WAV" , but only the first file appended
...............
I hope you to help me ... here my code after seeing your site .. Really it is a good site ...
//------- here my code --------
public class WAVSounds
{
[DllImport("WinMM.dll")]
public static extern bool PlaySound(byte[]wfname, int fuSound);
// flag values for SoundFlags argument on PlaySound
public int SND_SYNC = 0x0000; // play synchronously (default)
public int SND_ASYNC = 0x0001; // play asynchronously
public int SND_NODEFAULT = 0x0002; // silence (!default) if sound not found
public int SND_MEMORY = 0x0004; // pszSound points to a memory file
public int SND_LOOP = 0x0008; // loop the sound until next sndPlaySound
public int SND_NOSTOP = 0x0010; // don't stop any currently playing sound
public int SND_NOWAIT = 0x00002000; // don't wait if the driver is busy
public int SND_ALIAS = 0x00010000; // name is a registry alias
public int SND_ALIAS_ID = 0x00110000; // alias is a predefined ID
public int SND_FILENAME = 0x00020000; // name is file name
public int SND_RESOURCE = 0x00040004; // name is resource name or atom
public int SND_PURGE = 0x0040; // purge non-static events for task
public int SND_APPLICATION = 0x0080; // look for application specific association
//--------------------------------------------------------------------
public WAVSounds()
{
}
//-------------------------------------------------------------------
~WAVSounds()
{
}
//-------------------------------------------------------------------
public void Play(string wfname,int SoundFlags)
{
byte[] bname = new Byte[256]; //Max path length
bname = System.Text.Encoding.ASCII.GetBytes(wfname);
PlaySound(bname,SoundFlags);
}
//--------------------------------------------------------------------
public void PlayMS(byte[] memory,int SoundFlags)
{
//PlaySound( memory, SND_MEMORY | SND_SYNC );
PlaySound( memory,SoundFlags);
}
//--------------------------------------------------------------------
public void StopPlay()
{
PlaySound(null,SND_PURGE);
}
//----------------------------------------------------------------------
} //End WAVSounds class
//----------------------------
//--- In my Button I wrote ---------
WAVSounds ws = new WAVSounds();
MemoryStream ms = new MemoryStream();
FileStream fsr;
FileStream fsw;
byte[] SoundBuffer = new byte[Max*Max];
//-------------------------------------------------------
// ----------- File Stream ----------
//*************************************
fsw = new FileStream(path+"sound.WAV", FileMode.Create, FileAccess.Write);
//fsw.Close();
int i=0;
//**************************************
// fsw = new FileStream("D:\\c\\Project\\agents\\New Designe\\TextToSpeach\\sound.WAV", FileMode.Append , FileAccess.Write);
fsr = new FileStream(Sound[i],FileMode.Open );
for(i=0;i
|
|
|
|
|
With .NET framework 2.0, you can use System.Media.SoundPlayer to play wav sounds:
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = "c:\windows\media\ding.wav";
player.Play();
If you need to play wav, mp3, and WMA, you might want to look into Managed DirectX's AudioVideoPlayback class.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Little House on the Flickr
Judah Himango
|
|
|
|
|
I can play the sounds by the functions in class WAVSound that I have mentioned in my message , but I need to make the sound files be played with a few time between them or playing them as a single sound file , and for this reason I think to append them in one sound file
please try to see my code in the first message and tell me how could I make this idea , or if you have another idea please explain it .
I think I can decrease the time between calling sound files by storing the sounds it self ( not their paths ) in an array , so, all of them in RAM after that using loop to playing them so at play loop no time to call sounds from hard disk .
but the problem is how can I make an array that store sound files it self not names of sound files ??
thanks a lot ....
I will send my code in your E_maile ... really I can't thanking you ...
crusher_shark
|
|
|
|
|
If you're not using 2.0, you can go to www.pinvoke.net and get the code to use the PlaySound API.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How can I appened sounds if the sound file has a Canonical form , how can I program it ...
thank you .....
crusher_shark
|
|
|
|
|
What do you mean ? You want to merge files ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes ...that's what I meen
Sorry I can't speek English very much
......
crusher_shark
|
|
|
|
|
crusher_shark wrote: Sorry I can't speek English very much
That's cool, I don't speak any other languages at all
I'm not sure how you'd go about joining two wav files, I'd guess you need to know the file format, and then parse them, and write them out manually.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
My program is Text To Speech In my language,
for example, if I have sound for litter 'H' And sound for 'e' and the same thing for 'l' ,'o' and 'w'...
to hear the word "Hellow" I should play each sound , so the performance will be good ( like human speech not machine ) if I merge the litters sounds in one sound file
but to merge them I should change the canonical format of the file , how can I program this ? ...
crusher_shark
|
|
|
|
|
First of all, the end result is plain not going to work, unless your language is very different to English.
Secondly, you will need to read the files as a byte stream, then examine them, and create a new file that is of the correct format. Which means you need to learn about the wav file format. It's uncompressed, so it can't be too hard.
Why don't you create mp3s of all the sounds, turn them into a playlist for each word, and use the Windows Media Player control ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
this is my code and it depends on a class that analysis the word in my langauge ,the first sound can be stored in "sound" , how can I change the format of the new file "sound.wav" to append the other sounds ?
excuse me what is the advantage of mp3 rather than wav ?
//-------
FileStream fsr;
FileStream fsw;
byte[] SoundBuffer = new byte[Max*Max];
//----------------------------------------
fsw = new FileStream("sound.WAV", FileMode.Create);
fsw.Close();
int i;
for(i=0;i
|
|
|
|
|
crusher_shark wrote: how can I change the format of the new file "sound.wav" to append the other sounds ?
Please don't keep asking the same question over and over. The answer remains - you need to read up on the wav file format, and then put apart your data accordingly.
crusher_shark wrote: excuse me what is the advantage of mp3 rather than wav ?
1. The initial files are smaller
2. WMP will almost certainly play your files just as quickly as your joined together wav solution ( will probably do the same for wav files, actually ), without the sort of code you're trying to write at the moment.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Really I cann't thanking you ..
I hope to learn English very well ...
I am so sorry If I cann't explain my questions in a good words ...
crusher_shark
|
|
|
|
|
Hi!
What you're trying to do isn't possible so easily - WAVE audio is not just a bunch of bytes you can concatenate and expect to hear the single parts without interruption.
I guess you'd have to create your own WAVE file (or memory stream) but pay attention to adjust the wave header for each file you append.
IIRC, there's at least one article here on CP with a class for reading and writing wav files - try searching for it.
Regards,
mav
|
|
|
|