|
Add a "\n" at the spot in the line where you want it to break.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
e.Graphics.DrawString("Line1\r\nLine2",font,Brushes.Black,e.Margin);
Should do it, you might want to use Environment.Newline instead of \r\n though. And if you more than a few lines, i suggest you use a StringBuilder to make the string before drawing it it.
And if your string goes beyond the area in e.Margin then it simply won't be drawn (at least it shouldn't)
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
You need to adjust the value in e.Margin to point to the next line for each item. Use MeasureString to get the size of the string you want to print (and add a bit so that the lines of text don't run together).
|
|
|
|
|
Thanks guys atleast somwhat it works but the problem is after printing text i want to added a horizontal Line so how could i determine to a start a new line now.
Can anymore show me some examples
StringBuilder sb = new StringBuilder();
if (CokeNameChecked)
{
sb.AppendLine("Name: " + CokeName);
}
if (PersonNameChecked)
{
sb.AppendLine("Subtopic: " + Person.Name);
}
e.Graphics.DrawString(sb.ToString(), _headingFont, Brushes.Black, e.MarginBounds);
e.Graphics.DrawLine(Pens.Black,e.MarginBounds);
}
|
|
|
|
|
As I said before - use MeasureString to find out how big your string is, i.e. what's the bounding rectangle.
|
|
|
|
|
instead of \n or \r\n, use Environment.NewLine
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I need to create my own set of Windows Forms controls. These are inherited from the standard .NET controls, but all these controls share some methods with the same iumplementation (like subscribing for notifications, some initializations, ...).
So in C++, I'd implement this with multiple inheritance, but since this is not possible in C# and interfaces can't implement any methods, I'm stuck with duplicating the code for every control I create.
Is there any to get around these limitations?
|
|
|
|
|
hai ,
i have a problem when deploying my c# windows application 1.1 with
msde 2000 . every thing works fine but when i execute sql query script it trows an error that incorrect syntax near go and when i remove
go keyword from script file it throws error create view or proc will be the first statement of the query
i tried this code but it does not works
string statements=loadmainfestresource("install.Dbuninstall.sql");
statements.Replace("go",";");
statements = String.Format(statements,this.databasename());
return statements.Split(';');
loadmanifestresource is my function to load emmbede resource
my other question is that can i use attach or de attach file method to this.
if yes how to apply this after install and before install events
Pls give the whole deployment steps
sincierly
modified on Thursday, May 22, 2008 3:20 PM
|
|
|
|
|
Hi! I think I have some answers...
First question:
The GO keyword is special - it is used only in SQL Query Analyzer or similar tools. It tells the tool that the statement batch is complete and should be executed. After that, it continues wit the next statement. It is not passed on to SQL Server (MSDE), and SQL Server doesn't understand it.
If you want to run scripts saved from the query analyzer, you have to parse the scripts yourself (making sure you don't mess up if a string contains a "GO" somewhere), split them into batches and run the batches individually.
You can't just remove the lines containing GO, as (like the second error you get tells you), each "create procedure" or similar statement must be the first in a batch (i.e. must be run in separate SQL commands from your program).
Second question:
IF you had googled for five seconds before asking this, you would have found this rather exhaustive article right here on CodeProject:
Hands on how to configure the MSDE[^]
It should contain all the information you need, and then some...
EDIT: It also tells you how to use osql - which you could call from a CMD file called the PostBuildEvent in your installer - either to attach a database or run query analyzer script files or do both.
--
Peter
modified on Thursday, May 22, 2008 4:14 PM
|
|
|
|
|
i am asking that i have to run sqlscript file that is generated by enterprize manager after installing msde on after_install event of
installer class .
when iam trying this all works fine but when scripts runs throws an error
that incorrect syntax near keyword go and even when i replace it buy ";"
and split it by ';'
can u have some code for deploying application with msde toolkit
i know how to attach or de-attach database but my question is that where
to keep those sql files while attaching and de attaching
|
|
|
|
|
Yes, I understood the problem. I'll try to repeat the answers so that they are easier to understand:
Again: The "GO" keyword is NOT an SQL keyword. It works ONLY in SQL Query Analyzer, Enterprise Manager or OSQL.
You must do EITHER a OR b below:
a) Split your files on the GO keywords and execute each part separately, one at a time. You cannot just remove the GO keywords and execute it all at once, as some statements need to be executed separately (such as create procedure). You must be careful not to just split on the text GO, as it can be embedded in strings or table names or something. You could use a regular expression for that (google regular expressions).
b) Use osql to execute the files. It understands GO.
I don't have 1.1 installed any more, but in Visual Studio 2005 you can specify commands to be run post install, using practical macros for your application folder and similar important locations. You'll have to figure out how that works in 1.1 unless you already know. If I'm wrong and you can only run code in the installer class - search for articles on executing external commands from code (you should find plenty of them).
As for location of files: Add the script files (SQL and CMD) files as dependencies to your setup project and have them installed to your app path. It's a bit trickier with picking a destination for the database, as data shouldn't be placed in the app path, and the default data location for the MSDE data files (for the instance you install) may be hard to figure out (might not be the same on all machines). On the other hand, they don't HAVE to be installed there, so you could place them in the application data folder (which should be available as an alias in the setup project configuration and in the postinstall command editor - they are in 2005). Note that the user must select "install for all user" for that to be the shared appdata folder.
Again, I don't remember how 1.1 worked anymore, but I think it was pretty similar. The documentation should be of help - or use google, or search on CodeProject. You should find lots of articles on the subject.
--
Peter
|
|
|
|
|
One more thought: Please note that both the 1.1 framework and MSDE are obsolete. The current framework version is 3.5 (which is actually 2.0 with addons). The current free SQL Server database to use is SQL Server 2005, Express Edition (a.k.a. SQLEXPRESS).
Nobody builds new stuff with the old tools any more (hopefully), so you may find it hard to get good answers about them on these forums (memories are short). However, Google and the CodeProject article search should be of help, as a lot of old stuff is still out there - and you're not the first one to have these questions. There are articles out there, I'm sure.
Hmmm... the only place I can think of that uses 1.1/MSDE for new projects would be a school. Are you trying to get me to do your homework?
--
Peter
|
|
|
|
|
I have declared a OLEDB connection string with the follwing details:
myCon = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;" + @"data source=empDB.mdb");
In the form_load, i have opend the connnection as( myCon.open();) but its showing this error :
Error Message : An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
The same error is being displayed even with try catch................pls help me ..............thnx
Subin Verghese
Software Engineer
|
|
|
|
|
Verghese,
Try and below:
myCon = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;Data Source=empDB.mdb");
OLE Db Exception[^]
If that doesn't work, is there any text provided with the error?
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Gareth, thnx for the reply but it isnt working still.......i have included the main codes below, just check thru.........
using System.Data.OleDb;
private OleDbConnection myCon;
public Form1()
{
myCon = new OleDbConnection(@"Provider=Microsoft.JET.OLEDB.4.0;" + @"data source=empDB.mdb");
InitializeComponent();
}
private void Form1_Load(object sender, System.EventArgs e)
{
myCon.Open();
MessageBox.Show("Successfully Connected");
}
And this is the error message which I'm getting :
"An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll"
Thanks
|
|
|
|
|
Gareth, i got the solution.........i entered the full path and it worked.........and this is for ur info.......tek care.............happy coding............
Thanks
|
|
|
|
|
hi verghese,
Try this
1. If you are using standard security
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dbsample.mdb;User Id=admin;Password=;
2. If you are using a password for your access file
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dbsample.mdb;Jet OLEDB:Database Password=MyDbPassword;
regards
|
|
|
|
|
Good job Sujith.........tht was the problm with the path.......i gave the full path and it worked........thanx a lot..........bye
Thanks
|
|
|
|
|
I read the MSDN documentation on System.Windows.Forms.Application.SetCompatibleTextRenderingDefault (bool), and I still don't understand why I need it and what it does. I've passed true and false for different programs (not remembering which to use) and I don't see a difference.
|
|
|
|
|
Basically, it specifies whether GDI or GDI+ is used under the hood. Setting it to false will use GDI and should look better and localize better.
All it does is set the default value for Control.UseCompatibleTextRendering. But it gets overrided for a particular control if you set someControl.UserCompatibleTextRendering to a different value.
Put a label on a form and set, through code (not the designer) the label.UseCompatibleTextRendering property. Try setting it to true and false. On flatscreen monitors, it definitely is easy to spot -- without it, text looks jaggy and rigid. Set it to false, and it looks nice and smooth.
Life, family, faith: Give me a visit.
From my latest post: "And you think, 'To keep my anti-Judaic theology alive I must reinterpret this verse too as being a blessing for Christians and not for Jews. I know it strains all manner of principles of interpretation. I don’t read the newspaper this sloppily, but, man, I have a theology to defend.'"
Judah Himango
|
|
|
|
|
So I should pass in false to SetCompatibleTextRenderingDefault (bool)? It basically sets anti-alaising (spelling)?
|
|
|
|
|
Yes, try false and see how it works out for you.
Life, family, faith: Give me a visit.
From my latest post: "And you think, 'To keep my anti-Judaic theology alive I must reinterpret this verse too as being a blessing for Christians and not for Jews. I know it strains all manner of principles of interpretation. I don’t read the newspaper this sloppily, but, man, I have a theology to defend.'"
Judah Himango
|
|
|
|
|
I am reading data from a datafile and comparing it to a literal string. What is puzzling is that no matter what data I read from the data file for the variable "username", the boolean expression
(username == "lexsystem")
evaluates to "true", as if every string matches.
I tried "==", and ".Equals", and "Compare" and all give the same result.
Help!
Here is my code
--------------------------------------------------------------------------
private void btnSubmit_Click(object sender, EventArgs e)
{
FileStream file = new FileStream("LexPassword.txt", FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(file);
string username = reader.ReadLine();
string password = reader.ReadLine();
MessageBox.Show(username);
//MessageBox.Show(password);
//MessageBox.Show(Convert.ToString(txtUsername));
//MessageBox.Show(Convert.ToString(txtPassword));
if (username == "lexsystem")
{
Hide();
LexSystemfrm Form1 = new LexSystemfrm();
Form1.ShowDialog();
Close();
}
else
MessageBox.Show("Invalid Login, Please Enter the Correct Information");
----------------------------------------------------------------------
|
|
|
|
|
Jerry Graham,
Works fine for me. Also, it would be a good idea to use the "using" syntax around the FileStream and StreamReader so it gets disposed correctly.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
hi.. i have a question related to the listview.. i did the below things.. but how do i assign the value to the listview /?
void call_listview()
{
cmd.Connection = con;
cmd.CommandText = "select * from contact";
da.SelectCommand = cmd;
DataTable store = new DataTable();
try
{
ds.Clear();
con.Open();
da.Fill(ds);
store = ds.Tables[0];
int count_friend = store.Rows.Count;
contact_total_friends.Content = count_friend;
contact_listview.DataContext = ds.Tables[0].DefaultView;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}
}
|
|
|
|