|
Thanks!
|
|
|
|
|
hi,
adding to what Luc Pattyn explained, here is a remark from specification
"The statement-lists of a switch-block may contain declaration statements (§15.5). The scope of a local variable or constant declared in a switch block is the switch block."
please note that a statement-list has obviosly to be in a sequence and reachable.
|
|
|
|
|
This question has already been answered, but I just wanted to add that you can use more curly braces to further delimit the scope of variables. For example:
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "1":
{
HiddenField n = (HiddenField)e.Item.FindControl("IDProizvoda");
...
break;
}
case "2":
{
Hiddenfield n = (HiddenField)e.Item.FindControl("IDProizvoda");
...
break;
}
}
}
In your example it probably doesn't matter, but this certainly comes in handy when case blocks become larger and you want to keep your code partitioned.
|
|
|
|
|
Useful tip Thanks!
|
|
|
|
|
I don't know how to create a file.
txt or inf.
Vasildb
|
|
|
|
|
There are many ways, e.g.
void example() {
string[] strings=Environment.GetCommandLineArgs();
writeStringArray(strings, @"C:\myFolder\myNewFile.txt");
}
void writeStringArray(string[] strings, string fileSpec) {
Directory.CreateDirectory(Path.GetDirectoryName(fileSpec));
using (StreamWriter sw=new StreamWriter)fileSpec)) {
foreach(string s in strings) sw.WriteLine(s);
}
}
Luc Pattyn
|
|
|
|
|
Hallo there! I am trying to set up a simple client - server application for educational reasons and I have a problem resolving the real IP address of my server app. I use the code presented below :
IPHostEntry IPHost = Dns.GetHostEntry(Dns.GetHostName());
label1.Text = "Server IP: " + IPHost.AddressList[0].ToString();
and i keep taking in the label "Server IP: 192.168.2.2" that works locally but if i try it through an external PC in another subnet it doesn't seem to work. And the question is how can i take my real address (which i guess it's the router's address) that is 85.75.1.3?
Thank u in advance!
There is no patch for human stupidity
|
|
|
|
|
patonios wrote: but if i try it through an external PC in another subnet it doesn't seem to work
What kind of error or data are you getting?
patonios wrote: how can i take my real address (which i guess it's the router's address) that is 85.75.1.3
You could use the gateway details if your router is configured as one.
You can also try to use the Tracert(try run->cmd->tracert www.codeproject.com) and adding some logic could fetch you the router address. You may have to find out the last ip address which falls within the private address cat and the next entry to it would be your router address.
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
|
|
|
|
|
Thanks for your response. First of all i want to clarify that when i say it doesnt seem to work i mean that the label's text show my local address 192.168.2.2 and not my real address 85.75.1.3 so i guess if i finish my app it wouldnt be possible to find my server if i put 192.168.2.2 as the server's address.
I can retrieve my real IP address by using me routers settings or using a traceroute app or simply by visiting whatismyip.com but i want to have it dynamically through my C# code. And i was wondering if there is a way using the dns class or another existing class.
i am waiting for more ideas.
Thanks again for your time.
There is no patch for human stupidty
|
|
|
|
|
I have folderBrowserDialog1 and openFileDialog1 .
How to check that the file selected with openFileDialog1 is in the folder selected with folderBrowserDialog1 .
Vasildb
|
|
|
|
|
if (folderBrowserDialog1.SelectedPath == Path.GetDirectoryName(openFileDialog1.FileName)) {}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
if(Path.GetDirectoryName(openFileDialog1.FileName) == folderBrowserDialog1.SelectedPath)
{
}
PS.
I haven't tested it. Maybe it would need some adjustment.
Regards
|
|
|
|
|
hi everyone,
anyone knows how to play two sounds together without interrupting the previous sound?? any good articles??
many thanx
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi Muammar,
I dont think you can easily get multiple sounds.
I have seen many games with a single sound; when two sounds are required, the
second one is not launched, or the first one gets aborted.
Now as long as only one sheep is visible this should not be a problem
Luc Pattyn
|
|
|
|
|
|
System.Media.SoundPlayer should work, no?
|
|
|
|
|
Of course.
I'm still trying to write code that also runs on .NET 1.1 and have not used
System.Media namespace yet.
Luc Pattyn
|
|
|
|
|
oh please dont be sad Luc, cuz i tried it and it's not working either
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Nope!!
thanx for your help
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hello !
I'm trying to get URL from IE which is currently opened. Is there any way to get it? Is it possible with C# ?
Regards,
|
|
|
|
|
Hello ,
There is only one way I think.Try to hook IE .when ever it will start ...Try to get text from the address bar.
regards ,
nishu
|
|
|
|
|
Hello,
I'm trying to figure out how I could make the same "effect" like in Windows CardSpace (just blocking all screens, change their luminosity and show one WinForm to execute my procedure).
Any ideas?
ps: you can view this "effect" after installing framework 3 and going to Control panel -> Windows CardSpace
-- Everything is possible, even the impossible! ^_^
|
|
|
|
|
That effect is called security sandbox and you should be able to enable it using some windows API. By why would you want to? It's very restrictive towards your application.
WM.
What about weapons of mass-construction?
"You can always try to smash it with a wrench to fix that. It might actually work" - WillemM
|
|
|
|
|
I'm writing a differed tasks framework for an application, intercepting computer shutdown and launching a form to execute planified tasks. ^^
Security sandbox is framework 3 only feature?
-- Everything is possible, even the impossible! ^_^
|
|
|
|
|
I have .NET 1 WinForms dataGrid bound to dataTable.
dataTable has primary key field.
dataTable constraints should be checked during editing.
If user moves out from new row, an error occurs.
RowChanging event does not fire before error.
How to fill field with dynamic default value when new row is added to DataGrid ?
To reproduce:
1. Run code
2. Enter data to first column only
3. Press Down Arrow
Observed error:
---------------------------
Committing the row to the original data store has caused an error.
---------------------------
Value Column 'Column2' does not allow nulls. Do you want to correct this value?
Expected:
No error. Primary key column should be filled.
using System.Windows.Forms;
using System.Data;
static class Program {
static void Main() {
Application.Run(new Frm());
}
}
class Frm: Form {
public Frm() {
DataTable table = new DataTable();
DataColumn[] keys = new DataColumn[1];
DataColumn column1 = new DataColumn();
DataColumn column2 = new DataColumn();
DataGrid grid = new DataGrid();
grid.Dock = DockStyle.Fill;
table.Columns.Add(column1);
table.Columns.Add(column2);
keys[0] = column2;
table.PrimaryKey = keys;
Controls.Add(grid);
table.RowChanging += new DataRowChangeEventHandler(OnRowChanging);
grid.SetDataBinding(table, "");
}
private void OnRowChanging(object sender, DataRowChangeEventArgs e) {
if (e.Action == DataRowAction.Add) {
string pk = e.Row.Table.PrimaryKey[0].ColumnName;
if (e.Row[pk] == null)
e.Row[pk] = new System.Guid();
}
}
}
Andrus
|
|
|
|