|
Thanks both.
I think that your solution, Dave, could do the trick!!! Thankssss!!
Kind regards
|
|
|
|
|
Hi,
How can I get the number 123456789012
displayed as: 1234-5678-9012
I tried the following but it didn't work..
String.Format("{0:000-000-000-000}",123456789012);
Thank you.
|
|
|
|
|
Try this:
string.Format("{0:0000-0000-0000}", 123456789012);
|
|
|
|
|
I code in C++ so I'll leave it to you to work out the C# code.
Why not break it into 3 integers for example 1234, 5678 & 9012 & then use String.Format with the 3 numbers.
You get 1234 (the first integer) by taking the integer part of dividing by 100000000 that is int(123456789012/100000000)
You get 5678 (the second integer) by taking the modulus (remainder) on dividing by 10000 that is
mod(int(123456789012/10000), 1000)
You get 9012 (the third integer) by taking the modulus relative to 10000 that is mod(123456789012, 10000)
Hope this helps 
|
|
|
|
|
Thanks mate, I just remembered that a masked textbox control is all I need
|
|
|
|
|
System.Console.WriteLine ( System.String.Format("{0:0000-0000-0000}",123456789012) ) ;
System.Console.WriteLine ( 123456789012.ToString("0000-0000-0000") ) ;
Both seem to work to me. What problem does it give?
|
|
|
|
|
Funny, none of them work with me but it doesn't matter as I'm using the masked textbox now.. I'll have to find out later when I have the time.. Thank you guys!
|
|
|
|
|
Hi.
First of all, I have done a few C# applications, but are quite new to C# asp.net web applications.
What I am trying to receive is a simple Media player control on an aspx page. And furthermore a button, that starts the media player with a videostream url. Thats all!
I can easily achieve this in an ordinary c# form, by importing:
AxInterop.WMPLib.dll, Interop.WMPLib.dll and wmp.dll
references in the project. Now i am able to choose a "Windows media player" control in the toolbox, which i can drag into my form. Nice and easy.
But when i import these dll´s in my ASP.NET Web application, I cannot see the media player control in the toolbox. Ive tried to right-click the toolbox, and click "Choose items", and see that 'Windows media player' is checked under the COM components tab. But i still cannot see the control in the toolbox. Only in an ordinary c# application form.
This is driving me nuts. Ive tried googling for hours, but cant find the answer.
So if any kind sould could pinpoint me in the right direction, or make a quick solution file that holds this simple control on an aspx page, i would be very glad!
Thanks alot for your time.
Kind regards,
Lars
|
|
|
|
|
How Change the size in dataGridView for specific cells ?
|
|
|
|
|
Hi,
AFAIK you can't change the size of a single cell, however you can set properties for an entire column; example:
dgv.Columns[1].Width = 100;
|
|
|
|
|
i need to override the base CheckedListBox behaviour.
it is possible to check and uncheck a CheckedListBox without any code attached to it.
i need to disable this behaviour so that i can implement custom code.
any ideas?
for example:
if (ListenCheckedListBox.GetItemChecked(0)) { ListenCheckedListBox.SetItemChecked(0, false); }
if (!ListenCheckedListBox.GetItemChecked(0)) { ListenCheckedListBox.SetItemChecked(0, true); }
does not work because the controls default behaviour already does this anyway.
hopefully you can understand my issue.
thanks.
|
|
|
|
|
Have you looked at the CheckedListBox.CheckOnClick property?
|
|
|
|
|
yes i have. but default behaviour is toggle between states. what i dont want.
|
|
|
|
|
How can I break recursive function;
For example;
private string MyFunction(string val)
{
//ToDo Calculate xyz
if(xyz != "test") //<----This condition three times true.
{
val = MyFunction(xyz);
}
return val;
}
How can I return "val" when (xyz == "test")
I don't want to call back MyFunction when if condition is true.
Thanks...
|
|
|
|
|
Hi,
the normal way to use recursive functions is by providing parameters that have different values each time; the typical example is the factorial function:
public int Factorial(int n) {
if (n<=1) return 1;
return n*Factorial(n-1);
}
Did you notice:
1. I used PRE tags to show code, so it is formatted and rendered in a non-proportional font for optimal readability.
2. the Factorial function, taking n as a parameter, calls itself not with n but with n-1.
|
|
|
|
|
Most recursive methods have two parts: one that handles the deepest recursion and the normal path that recurses. You've done this in your example, but I would write:
string MyFunction( string val )
{
if ( val == "test" ) return val;
string xyz = ...
return MyFunction( xyz );
}
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
Why not,
private string MyFunction(string val)
{
if(xyz != "test")
{
val = MyFunction(xyz);
}
else
{
return val;
}
}
I'm not sure, though, what you mean by "This condition three times true."
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
"This condition three times true." It is just an example, so that assumption.
Thanks...
|
|
|
|
|
I am about to embark on creating a service for the first time. Does anyone have any good pointers or reading material that will help me understand how to code a service?
I am very familiar with Application based apps with user and nonuser interaction. But a service I am not to familiar with though I do know the services function vs a applications function.
Second Question...
In building a service I need for a mechanism for a application to pass a command or paramater to the service and have the service return the results of the command or parameter to the application. Does anyone have any pointers on how I can accomplish this?
|
|
|
|
|
Services are pretty easy. I'm sure google will provide plenty of articles.
As for communicating between your service and an application, that's just normal Inter Process Communication ( IPC ). WCF is the technology de jour.
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
hi there, I am using sql 2008 express to keep orders and each time I finish with the orders, I want to reset the identity value. I manipulate the database over c#, how can I reset the identity value when I deleted all the records? (I already have the code to read and write to database) Thanks in advance
|
|
|
|
|
teknolog123 wrote: how can I reset the identity value when I deleted all the records?
From SQL (haven't tried to execute it over a SqlCommand , but I guess that it would work);
DBCC CHECKIDENT (yourtable, reseed, 6798) Would start the numbering at 6798, which is a good a place to start counting as any
I are Troll
|
|
|
|
|
thanks where and how can I put that code below?
SqlConnection sqlBaglanti = new SqlConnection();
SqlDataAdapter sqlAdaptor;
SqlCommandBuilder sqlKomut;
DataTable dtTablo = new DataTable();
private void masaCubuk_MouseDown(object sender, MouseEventArgs e)
{
sqlBaglanti.ConnectionString = @"Data Source=SOUNDMAXP\SQLEXPRESS;
Initial Catalog=Kafe;Integrated Security=SSPI;";
sqlAdaptor = new SqlDataAdapter("Select * From dbo.Masa1", sqlBaglanti);
sqlKomut = new SqlCommandBuilder(sqlAdaptor);
sqlAdaptor.Fill(dtTablo);
for (int i = 0; i < dtTablo.Rows.Count; i++)
{
dtTablo.Rows[i].Delete();
}
sqlAdaptor.Update(dtTablo);
sqlBaglanti.Close();
sqlBaglanti.Dispose();
}
|
|
|
|
|
teknolog123 wrote: thanks where and how can I put that code below?
If you paste code, then highlight it and press on the "code block" button; that makes it somewhat more readable. I assume that you'd execute a SqlCommand[^].
You'd need to do something similar to this at the end of your method;
const string myConnectionString = @"
Data Source=SOUNDMAXP\SQLEXPRESS;
Initial Catalog=Kafe;
Integrated Security=SSPI;";
const string myCommandText = @"
DBCC CHECKIDENT (yourtable, reseed, 6798)";
using(SqlConnection con = new System.Data.SqlClient.SqlConnection())
{
con.Open();
using(SqlCommand cmd = con.CreateCommand())
{
cmd.CommandText = myCommandText;
cmd.ExecuteNonQuery();
}
con.Close();
}
This can be further adapted to use your connection-object, off course
I are Troll
|
|
|
|
|
Hi All
I want to print the report using the Microsoft Report without showing the report on the screen (Print Direct When I Click On Button Name Print Report)
thanks
Thaer
|
|
|
|