|
Hi there,
I've used the following string to create a multiline string.
String str = "line1 \n newline2 \n newline3";
but I didn't get the appropriate result. I got something like this:
line1 newline2 newline3
How can I create multi line string?
thank you in advance.
|
|
|
|
|
Try replacing '\n' with line feed '\x0a' and carriage return = '\x0d'
|
|
|
|
|
I think you cannot save the currage return functionality in a string.
Try Console.WriteLine("line1\nnewline2\nnewline3");
or
String str1 = "line1";
String str2 = "newline2";
String str3 = "newline3";
Console.WriteLine(str1 "\n" str2 "\n" str3 );
hope this helps
|
|
|
|
|
Use "\r\n" instead of just "\n"
|
|
|
|
|
|
|
Hi,
Option 1:
string str = "line1" + "\n" + "newline2" + "newline3";
Option 2:
String str = "line1 \n\r newline2 \n\r newline3";
Majid, Tell me if these does not work.
Regards,
Sugandh
|
|
|
|
|
non of them doesn't work Sugandh.
I wanna use it in header text of a column of DataGrid control.
|
|
|
|
|
What do you think "multi line strings" are?
For the String class, the character '\n' is handled exactly like an 'a' or '7'. It's just a character like any other. String itself doesn't have a concept of multi line!
So you'll have to tell us where you want to _use_ the string.
In a TextBox , the line separator is "\r\n".
In a RichTextBox , the line separator is "\n".
So depending on where you need the string the answers will be different.
mav
|
|
|
|
|
I wanna use it in the header text of a column of DataGrid control.
|
|
|
|
|
Then I would guess it is the DataGrid that strips the newlines.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
In this case I doubt that you'll succeed with any of these approaches.
You see, the DataGrid is responsible for drawing the column headers according to their current texts, but I don't think the developers took multiline headings into consideration.
That's why you get blanks where your not-printable characters ('\n', '\r') are.
In order to achive multiline headings you'd have to perform drawing of the DataGrid column headers by yourself (perhaps you're able to do this using P/Invoke, I'm not sure).
Anyway: My suggestion would be _not_ to use multiline headings. Headings are used to give the user a short information what the contents of a column are. You're not supposed to write lengthy texts there.
mav
|
|
|
|
|
I am trying to develop the following functionality. The user selects a button. In the on-click event I then want to bring up a new web page (small one) that contains a dropdowm list box. This list box would be bound to a data base. When the user selects an item the page disappears. I then work with the data that was selected.
How do I do this?
Thanks in advance
|
|
|
|
|
Try the ASP.NET[^] forum.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi.
Any of you have an working exampel of the function mmioInstallIOProcA??
|
|
|
|
|
Never mind..... made it work.
But thanks anyway.
|
|
|
|
|
I want to track the mouse position by drawing a line or cross at the location of the pointer.
What I can't figure out is how to erase the previous location from the display.
In other languages I would have done used a XOR pen but I can't find the same thing in C#.
I want the behavior to be something similar to the tracking line when panels are resized.
Thanks,
Eric
|
|
|
|
|
Hi, Im having trouble creating an rtp header at the moment as I need to convert a short into a 2 bytes for the sequence number!
I have tried going to an string them byte but this then produces 5 bytes not 2! and also using the Convert class but this only converts to a single byte!
How do I go about this?
Many thanks, Mat
|
|
|
|
|
Try BitConverter.GetBytes
|
|
|
|
|
Hi!
I am wondering about the c# code-technique "using".
As I understand, when the program leaves the using-block, the resourse defined whith the statement is disposed. In that case the two cases below should be identical:
//*** Case 1: (without myConnection.Close()) ***//
using(SqlConnection myConnection = new SqlConnection(sConnectionString))
{
SqlCommand myCommand = new SqlCommand("GetUsers", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myConnection.Open();
//Fetch data
}
//*** Case 2: (with myConnection.Close()) ***//
using(SqlConnection myConnection = new SqlConnection(sConnectionString))
{
SqlCommand myCommand = new SqlCommand("GetUsers", myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myConnection.Open();
//Fetch data
myConnection.Close();
}
Can anyone confirm that there is no defferences between the who. Case 1 just seems a bit dangerous to me
Thanx!
/Paul
|
|
|
|
|
I think you are asking two questions:
1.
using (SqlConnection myConnection = new SqlConnection(sConnectionString))
{
}
is equal to
SqlConnection myConnection;
try {
myConnection = new SqlConnection(sConnectionString);
} finally {
if (myConnection != null)
myConnection.Dispose();
}
This works good and you can trust in it
2. The other question is if a Dispose call on a SqlConnection is going to close it and yes it does.
|
|
|
|
|
Hi
I want to write a program that use notifyicon but i don't want to use a form container . i create a console aplication and use a notifyicon !
everything was well but my icon does not responce events ?
my goal is to prevent showing a form and reduce memory usage .
how can reach this ?
Thanks Amir Jalaly
|
|
|
|
|
|
Hello,
I have a C# WMEncoder application which is using a C++ transform plugin(DirectShow), I would like to send additional information to the filter and recieve information from the filter.From the filter I can use the SendMessage() function, but how can I send information to the filter?
I tried to create another c++ com, where I give it the IUnknown of the filter(thru a property of the com I created) and use the QueryInterface() method(in a method called SetEvent() I created in the com) inorder to use the IMyInterface of the filter but I get an error trying to use it in C#:
"Object reference not set to an instance of an object"
|
|
|
|
|
While your explanation could use a little bit of elaboration, do make sure that you're accessing an instance of the COM object and not creating another one. This can be tricky in .NET. In your native application you could add an instance of your DMO to the RunningObjectTable (ROT; fairly easy in native code) and then get it out in your managed application using Marshal.GetActiveObject(string progId) (so make sure to register your COM object class with a ProgID).
Note that you can also send information to the filter using SendMessage , but you must P/Invoke it. The generic signature follows:
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd,
[MarshalAs(UnmanagedType.U4)] int msg,
IntPtr wParam,
IntPtr lParam); Depending on the message parameters and return code, you can redefine this a little differently. If you must pass a pointer to a struct, for example, you can do the following (since a pointer to a struct is the size of an IntPtr ):
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd,
[MarshalAs(UnmanagedType.U4)] int msg,
IntPtr wParam,
ref MyStruct lParam); What QueryInterface method are you using? Marshal.QueryInterface ? Please post some example code.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|