|
The CheckedChanged event is raised when the radio button is checked or unchecked. The problem with your code above is that: Assuming 1 was previously checked
when 2 is clicked, a checkedchanged for 2 is raised,which unchecked 1
this raises checkedchanged for 1 which also disables 2. At such both are disable
(The scenario above assumes that the control are in different containers)
You could use this code
<code>private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
radioButton2.Checked = !radioButton1.Checked;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
radioButton1.Checked = !radioButton2.Checked;
}</code>
|
|
|
|
|
the suggested solutions will work, even you can simplfy this by putting both the radio buttons in Group box and there is no need to write any code. group box itself will take care these logic
|
|
|
|
|
Is it possible for multiple instances of the same service to be running simultaneously?
If so, is there a way that you can check to see if the service is already running and stop the second instance from starting up?
|
|
|
|
|
No I dont think so, services need unique names.
If you WANT the same service twice, use different names.
|
|
|
|
|
New to C#
And I have a project addressing broadcasting stations. Somehow I have to activate a server that will sent a flux read by the user's real player plugin. I was able to activate thru a form and a button, to have the form webbrowser read a html file in which I have and embeded command that selects and open the right radio station. That html file is accompanied with an xml css file to have a little "look and feel" on the tiny webbrowser. The whole thing works ok, but I have to store 3 files accompaning my exe file. To my taste this is too much files. Most broadcast radioswidgets have only one exe file.
Please have you an idea how to consolidate all this ? One of my exe radio widget offered by the Radio stations seems to be recognized by my firewall protection when I activate it as a macromedia flash player although it is a an exe appli.
Last is there Html in commands in C#, or how can I activate flash plugins.
To Sum it:
1: Consolidating files
2: Activating flash file
3: Local C# Html commands
Thanks for any help
If you dont know were you are,look back were you come from. (Some time one dont know how far they travelled) Next time before you complain ! Give a friendly look to your sole. (African Wisdom).
|
|
|
|
|
Hi.
I have several datatables that each have the same structure. They represent individual bank accounts.
When the user selects the bank account and then saves the transaction I use the following code:
if (cbPayBillsWhichAccount.Text == "Administration Fund")<br />
{<br />
try<br />
{<br />
mybodycorpDataSet.AdminFundRow newRow = this.mybodycorpDataSet.AdminFund.NewAdminFundRow();<br />
<br />
if (this.dtpPayBillsTransactionDate.Text == string.Empty)<br />
{<br />
newRow.Date = DateTime.Today;<br />
}<br />
else<br />
{<br />
newRow.Date = Convert.ToDateTime(this.dtpPayBillsTransactionDate.Text);<br />
}<br />
<br />
newRow.Debit = true;<br />
newRow.ChequeNumber = this.tbPayBillsChequeNumber.Text.ToString();<br />
newRow.Payee = paySupplierName;<br />
newRow.Amount = Convert.ToDecimal(tbPayBillsHowMuch.Text);<br />
newRow.Reconciled = false;<br />
<br />
this.mybodycorpDataSet.AdminFund.Rows.Add(newRow);<br />
this.adminFundTableAdapter.Update(mybodycorpDataSet.AdminFund);<br />
}
What I wish to do is re-use the code (essentially all the "newRow" lines) as ammended for each chosen bank account.
How would you suggest I go about this?
Glen Harvy
|
|
|
|
|
Which of the following is better? And why?
public void DoSomething(bool status)<br />
{<br />
status = false;<br />
<br />
...
<br />
if (everything is okay) status = true;<br />
}
or
public bool DoSomething()<br />
{<br />
...
<br />
if (everything is okay)<br />
return TRUE;<br />
else<br />
return FALSE;<br />
}
Brad
The secret to creativity is knowing how to hide your sources. - Albert Einstein
|
|
|
|
|
static void testThis(bool bValue)
{
bValue = false;
}
static int Main(string[] args)
{
bool myBool = true;
Console.WriteLine(myBool);
Console.WriteLine("Calling testThis()");
testThis(myBool);
Console.WriteLine(myBool);
Console.WriteLine("Did I learn anything?");
}
led mike
|
|
|
|
|
Brilliant response. Got my 5!
|
|
|
|
|
If you're returning a status then the second option is best because people can use the function inline then and it makes more sense anyway.
|
|
|
|
|
it is not consider a good coding style by having 2 return. Declare a single variable that will elimanate 2 returns in your function
|
|
|
|
|
Arguable.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
You would need to use a ref or out keyword to make the first work, but that is rarely used in object oriented programming.
The second option is clearly the best option.
---
single minded; short sighted; long gone;
|
|
|
|
|
or
enum Result{Ok, Failure}<br />
<br />
public Result DoSomething()<br />
{<br />
...
<br />
if (everything is okay)<br />
return Result.Ok;<br />
else<br />
return result.Failure;<br />
}
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Generally, the second option is the best (for many of the reasons already mentioned) and is what you should use most of the time. There are, however, times when passing parameters by reference is useful. For example, a function may need to return multiple values (this is often a sign that refactoring is in order, but there are legitimate examples of this need). Also, when passing a large value type by value, the type must be copied. This takes extra memory and cycles. Because of this, it may be acceptable (and even neccessary) at times to pass a large value type by reference.
Also, when passing parameters by reference, C# requires the 'out' or 'ref' keywords. Although they are compiled into identical IL, when using the 'out' keyword, it is expected that the method being called will initialize the value. When 'ref' is used, it is expected that the calling method will initialize the value.
So, while you won't usually need (or want) to pass by reference, there are times when it is appropriate.
Ian
|
|
|
|
|
Hi there !
I've getting in trouble using fileinfo.Delete() method in C#.
When I attempt to use it I got the message :
"The process cannot access the file 'foo.txt' because it is being used by another process."
How can I delete it ?
Thanks in advance.
|
|
|
|
|
You can't you just have to wait (or kill) until the process which is accessing the file.
|
|
|
|
|
Hi,
deleting a file immediately is very hard, for one you need sole access, which you
can not easily obtain. There are lots of programs trying to read the files you are
working with, such as AntiVirus tools, desktop search tools, etc. As a net result
a program that creates a temporary file often fails in deleting it when done with it !!
That is why Windows Explorer tacitly tries up to 5 times (with 1 second interval)
to delete a file when instructed to do so, before reporting failure.
My FileDelete() method does the same; most often it succeeds in those 5 seconds.
|
|
|
|
|
Convert.ToInt32(object);
I'm listening but I only speak GEEK.
|
|
|
|
|
Hello AreJay
Thanx for the reply. I have looked into that and I realised I have the options of Int16, Int32, and Int64. Could you be kind enough to tell me what is the diffences in these and does it make any difference which one I chose.
I have chosen Int32 and everything works fine.
Thanx for your help, mate.
Khoramdin
|
|
|
|
|
Khoramdin wrote: Int16, Int32, and Int64. Could you be kind enough to tell me what is the diffences in these and does it make any difference which one I chose.
Different sizes of integer. Int16 uses 16 bits to represent a number. Therefore you can store a number between -32768 and +32767. Int32 (synonymous with int ) uses 32 bits for a range of -2billion to +2billion (approx). Int64 uses 64 bits.
|
|
|
|
|
Hi,
I would like to know if some component vendors have a DateTimePicker replacement. I don't mean a calendar or any complex component, just a DateTime picker. Optimally it would add what lacks to the microsoft control, like changing the Culture, accepting null values, text formatting, custom fields (like what is available with the win32 control) and so on (I am aware of the free components showcased here at CP). Thank you
|
|
|
|
|
Hi,
I'm new in here.
I want to send a wav file through a socket in C#. The socket works fine, text can be send through it. How can I send a file in "parts" over the network. For example a file of 100kb must be send in parts of 4kb (25 * 4kb). On the other side of the socket, it will be stored in a buffer and it will be played.
Or is there another method to send audio?
A detail: the software is running on WinCE. (some parts of the code may be different from C# for WinXP)
Thanks in advance.
|
|
|
|
|
The most important part of streaming data over the network is to remember to use:
System.Net.IPAddress.NetworkToHostOrder
and
System.Net.IPAddress.HostToNetworkOrder
If you are using a TcpIp socket don't send in parts, the nagle algorithm is very efficient. However, on the receiving end you can choose which chunks to use and when.
If order is not important, speed is paramount, and only 4kb at a time use Udp datagrams.
File Not Found
|
|
|
|
|
Tnx,
I've read about the nagle algorithm... and yes I'm using a TCPIP socket.
I'm trying to implement it.
If there is something not working I'll post it.
Thanks.
|
|
|
|