|
Yes you can. Find all instances of the space character in your long string. Then only send strings based on the space not based on the character position. You can then add padding to the end if necessary.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Use the LastIndexOf method to find the last space within the first 30 characters and split the string there. Use the PadRight method to add spaces.
Example:
string msg = "Hi Jocey!! I Hope you have a stupendous 30th birthday! I'm aorry I can't make it! Suexoxo";
List<string> lines = new List<string>();
while (msg.Length > 30) {
int pos = msg.LastIndexOf(' ', 29, 30);
if (pos != -1) {
lines.Add(msg.Substring(0, pos).PadRight(30));
msg = msg.Substring(pos + 1);
} else {
lines.Add(msg.Substring(0, 30));
msg = msg.Substring(30);
}
}
lines.Add(msg.PadRight(30));
foreach (string s in lines) Console.WriteLine("\""+s+"\"");</string></string>
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
your anser works like a miracle. one more question for you. how can I clean up the text from carriage returns and line feeds? before starting the process?
please advice.
|
|
|
|
|
I suppose that you want spaces in place of the line breaks?
msg = msg.Replace("\r\n", " ");
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi friends
How to implement union of C++ in C#
thanks in advance
-kk.tvm-
|
|
|
|
|
|
thanks 4 your reply, but i getting a error offset is error
public struct _ABC
{
[FieldOffset(0)]
public int a;
[FieldOffset(4)]
public short b;
[FieldOffset(6)]
public int c;
[FieldOffset(6)]
public int d;
}
I am getting an error while compiling above code, fieldoffset(6) is not aligned
Can u help me
-kk.tvm-
|
|
|
|
|
hmm, it works for me:
_ABC test;
test.d = 0;
test.c = 5;
Console.WriteLine("d = {0}", test.d);
outputs
d = 5
the only thing that I had to change about your struct definition is that it's missing this above it:
[System.Runtime.InteropServices.StructLayout(LayoutKind.Explicit)]
|
|
|
|
|
good afternoon to everyone out there!! I am having a setup for my app (freshly baked) and I need to install third party tool within the app so the app can work normally. I want to know if is possible somehow the setup for the third party tool be installed together with the installation of my app. I don't want to bother the clients with two setups and I want to install both (app + third party tool) in one setup. Is that possible?? Thx in advance
|
|
|
|
|
Hi all,
I am very new to c#,
My current project is on E-Learning Domain(Asp.net 2.0 and c#).
can any one suggest me which type of Design pattern is best suited for this type of Projects.
Please respond as early as possible
Thanks and regards,
Y.A.krishna Prasad.
fttyhtrhyfytrytrysetyetytesystryrty
|
|
|
|
|
Design patterns are patterns that describe sections of the software architecture. You don't just have 1 pattern that describes an entire software application. I suggest you do some reading on design patterns (if that is what you want to learn about) and try to understand how the patterns can be applied to your specific application.
Don't overuse patterns though, as they can merely increase complexity without providing any advantage.
Simon
|
|
|
|
|
try to Read GOF (Gang of Four ) Desing pattern, there types, appliclibility and consequence and then you can decide which pattern you want to use.
cheers,
Abhijit
Think Sharp | Code Sharp | C Sharp
|
|
|
|
|
Hi there! I have an app and I have a local database within the app. After I finished building, I was testing the app at my local computer and it was working fine. After that I installed on a computer without any kind of sql server instance installed on it and it didn't run at all and was giving me error that the remote connections are not allowed. Is it possible the app not to run cause there is no instance of sql server or it's something else?? Thx ahead for your advices
|
|
|
|
|
Yes, if you are using a local SQL database in the app, you will need to install SQL server on the pc for it to work. You can use SQL Express[^] to reduce the amount you need to install. SQL express is a smaller version of SQL server that just handles small database files. It is specifically designed to be redistributed with applications.
Make sure you check the restrictions on database size etc for SQL express:
http://en.wikipedia.org/wiki/SQL_Server_Express[^]
Simon
|
|
|
|
|
Thx for your interest about this issue, I have a sql express within visual studio as well, but most of the clients what will use this app are people who are not related with developing thus they do not have any VS or SQL express instance installed on the computer. You want to say that for running at their machine, installing at least sql express is mandatory?? Thx ahead for any other advice
|
|
|
|
|
Yes, you must install SQL express on their PC.
(The alternative is to use a database on a server like Guffa has suggested)
Simon
|
|
|
|
|
Hi Laziale,
You donot need to install SQLServer in each client m/c.If you are using SQL DMO for backup and restore of db throgh application than only you need to add the required DLL in your setup(Using merge module).
Thanks
Hem
|
|
|
|
|
As your application is using a database, it has to have a database to use.
You either have to install a local database on the client computer, or you need an instance of SQL Server (not express) on a server that they can access via LAN/internet.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
IF you plan to run the application on a different machine, BUT connect to the database on your local machine, you will need to allow remote connection on the SQL server, using Surface Area Configuration. It is turned off by default. Also check the firewall to allow the port to go through also.
IF you plan to run the application on a different machine AND connect to the database on that machine, yeah, you will need to install SQL server on that machine.
|
|
|
|
|
Hello. Got an annoying problem here. I'm trying to create a custom TextBox which renders the text central vertically. Additionally, I want the font to reduce in size if it is wider than the TextBox so it is all visible. The problem is the text renders fine until it's too wide, then it won't draw at all. Here's the KeyPress event handler:
private void TextArea_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 8)
{
if (baseString.Length > 0) baseString.Remove(baseString.Length - 1, 1);
}
else
baseString.Append(e.KeyChar);
if (baseString.Length == 0)
{
using (Graphics gfx = this.CreateGraphics())
{
gfx.Clear(this.BackColor);
return;
}
}
// Setup the graphics object
Graphics g = this.CreateGraphics();
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
SizeF stringSize = g.MeasureString(baseString.ToString(), this.Font);
if (stringSize.Width > this.Width)
{
while (stringSize.Width > this.Width)
{
this.Font = new Font(this.Font.FontFamily, this.Font.Size - 1);
stringSize = g.MeasureString(baseString.ToString(), this.Font);
}
}
else
{
while (stringSize.Height < (this.Height - 6))
{
this.Font = new Font(this.Font.FontFamily, this.Font.Size + 1);
stringSize = g.MeasureString(baseString.ToString(), this.Font);
}
}
g.Clear(this.BackColor);
float posX, posY;
posX = (this.Width / 2) - (stringSize.Width / 2);
posY = (this.Height / 2) - (stringSize.Height / 2);
g.DrawString(baseString.ToString(), this.Font, new SolidBrush(this.ForeColor), posX, posY);
g.Dispose();
}
You can see the reduced size string flicker in and out when typing fairly fast but then it disappears. Any help would be appreciated.
-----------------------------------------------------------------
EDIT: Realised I should have put the painting in the OnPaint method which I did, and found an unintentional loop which I've removed. It's working correctly now apart from the fact that as the text gets longer, and therefore the font smaller, my alignment veers off to the left a bit.
modified on Wednesday, September 24, 2008 9:29 AM
|
|
|
|
|
How can i count all location respectively while licking a city...by using class r any material avilable?
krishna
|
|
|
|
|
Create a integer variable. Set it to 0 to begin with. Increment it by one every time a city is clicked.
When you have finished, output the integer. This is the number of times cities were clicked.
Simon
|
|
|
|
|
krishnavaradharajan wrote: licking a city
Ooh yuck . I'd rather not lick a city - it tastes all concretey.
|
|
|
|
|
Pete O'Hanlon wrote: I'd rather not lick a city - it tastes all concretey.
Yeah. And all the graffiti leaves my tounge looking really funny...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
That's a typo; he meant "clitty".
|
|
|
|