|
I realized the problem was somewhere else in the code
I did want to point out that while ArrayList doesn't support a key search My_al[keyName] it has two search options, Contains which leverages off of Equals, and BinarySearch which leverages off of the IComparable interface.
Is there an article here that explains how to override Equals and IComparable. The help on MSDN doesn’t give a complex example.
Ronald Hahn, CNT - Computer Engineering Technologist
New Technologies Analyst
HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
|
|
|
|
|
is there a way i can read a file that was create with print to file (the pcl file) and do a print preview on it
thanks
chad
|
|
|
|
|
hello i am new to C# and im trying to create some arrays
im trying to use an enum to specify the size of the arrow but its not allowing me to do so
here is an example
enum Size {MaxSize = 1};
int[] array;
array = new int[Size.MaxSize]
however when i try to do this im getting compile errors
can someone can me some pointers as to how to work with C# arrays
|
|
|
|
|
new int [] {Size.MaxSize }
You may have to cast it to an int as well.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Try this:
enum Size {MaxSize = 1};
int[] array;
array = new int[(int)Size.MaxSize]
|
|
|
|
|
Hi,
I want to be able to Align the Text (in each column) when printing ListView control. I was able to achieve this by creating rectangles. The RightAlign dosn't seem to work perfectly... any ideas why? Is there a better way to Align the text in each column when printing?
for (int row = 0; row < lv.Items.Count; row++)
{
int nextColumnPosition = lv.Bounds.X;
RectangleF drawRect;
StringFormat stringFormat = new StringFormat();
for (int col = 0; col < lv.Items[row].SubItems.Count; col++)
{
if (lv.Columns[col].TextAlign == HorizontalAlignment.Right)
{
drawRect = new RectangleF(nextColumnPosition + leftMargin, (lv.Items[row].Bounds.Y + lv.Bounds.Y) + topMargin, lv.Columns[col].Width - 3, lv.Bounds.Height);
stringFormat.Alignment = StringAlignment.Far;
}
else if (lv.Columns[col].TextAlign == HorizontalAlignment.Center)
{
drawRect = new RectangleF(nextColumnPosition + leftMargin, (lv.Items[row].Bounds.Y + lv.Bounds.Y) + topMargin, lv.Columns[col].Width, lv.Bounds.Height);
stringFormat.Alignment = StringAlignment.Center;
}
else
{
drawRect = new RectangleF(nextColumnPosition + leftMargin + 3, (lv.Items[row].Bounds.Y + lv.Bounds.Y) + topMargin, lv.Columns[col].Width, lv.Bounds.Height);
stringFormat.Alignment = StringAlignment.Near;
}
//print data
g.DrawString(lv.Items[row].SubItems[col].Text, lv.Items[row].Font, Brushes.Black, drawRect, stringFormat);
//Add the width of the current column to get your next column position
nextColumnPosition += lv.Columns[col].Width;
}
}
thanks,
ron
|
|
|
|
|
I have some "large" image data stored in a message queue, and have a remote program to read from the message queue. The first call of reading queue often takes a long time to finish (20 sec). After that the communication becomes fast. BTW, the message queue is not empty when reading begins.
I tried to run the problem local to the msq, the first call of reading did not cause any problem. I also tried to read "small" image data, and that was fast too.
Any idea what is happening and how to avoid it?
Thanx
|
|
|
|
|
Hi! I want to select only 10 rows from a dataTable each time, just as from a database("SELECT TOP 10 FROM orders WHERE ID <100 ORDER BY ID"). for example:
DataTable myTable = new DataTable("orders");
DataRow[] rows = myTable.Select("TOP 10 ID < 100");
1)How can I write the correct statement.
2)Can I ues "TOP" key word or there's other way to do it?
Thank you very much.
|
|
|
|
|
I'm kinda new to this but this is how i did it.
SqlCommand cmd = new SqlCommand(("SELECT TOP 10 FROM orders WHERE ID <100 ORDER BY ID",SQLConn);
cmd.CommandType = CommandType.Text;
SqlDataReader SQLData = cmd.ExecuteReader();
DataTable My_DataTable = SQLData.GetSchemaTable();
int iColumns = My_DataTable.Rows.Count; //shuld be 10
while(SQLData.Read())
{
string sOut = "";
for(int i=0; i
|
|
|
|
|
After I posted this message I keep searching the net and I find the solution to my problem.
The problem was caused by McAfee VirusScan Enterprise 8.0i's Buffer overflow protection.
I tried to disable it and my comboboxes start working well again.
If someone has the same problem read the document in
this location
|
|
|
|
|
In C or C++ we used to be able to call functions from DLL's by loading the dll library (Ex: LoadLibrary("library.dll");) then using the method GetProcAddress("functionName") to find a function by name in the library.dll.
Now in C# the Dll's contain classes rather than isolated functions.
Is is possible to call functions from Dll's in c#?
I am mainly interested in being able to pass a function name as parameter then use something like the GetProcAddress method that uses that function name to find it in the dll so we can call it.
Example in C++:
//this method will call a function from the library (no error checks to simplify)
void CallFunction(char* libraryName, char* functionName)
{
//declare the function that will be called:
typedef void * (FUNC)(int); //function that returns void and takes an int
FUNC pFunction;
//load dll library:
HINSTANCE hLibrary = LoadLibrary("Library.dll");
//find function in library:
pFunction = (FUNC) GetProcAddress(hLibrary, functionName);
//call function
pFunction(35);
}
|
|
|
|
|
|
|
SqlCommand cmd = null;<br />
<br />
cmd = connDB.CreateCommand();<br />
cmd.CommandText = "INSERT INTO MandantMC (" +<br />
"Mand, " +<br />
"MID, " +<br />
"VALUES " +<br />
"(?,?)";<br />
<br />
cmd.Parameters.Add("Mand", txtBoxMandant.Text.ToString());<br />
cmd.Parameters.Add("MID", txtBoxKürzel.Text.ToString());<br />
<br />
<br />
cmd.ExecuteNonQuery();
The connDB works. But this code does not. I try to get data from textboxes to SQL DB. If I make hardcoded code like :
... VALUES ('W','Y') then it works. But if I want data from controls, there is an error while passing cmd.ExcecuteNonQuery(). Also if I insert the ' ( within an own string ) it doesn't work. Only ' works in CommandText.
Any sols ?
|
|
|
|
|
The SqlClient uses named parameters, so you need to use @Mand and @MID instead of the ?'s in your sql string. In addition, you may need to specify @ when adding the parameters.
my blog
|
|
|
|
|
Yes, you do need to specify "@" before the parameter names when adding them to the SqlCommand.Parameters collection property.
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]
|
|
|
|
|
SqlCommand cmd = null;
cmd = connDB.CreateCommand();
cmd.CommandText = "INSERT INTO MandantMC (" +
"Mand, " +
"MID, " +
"VALUES " +
"(?,?)";
cmd.Parameters.Add(@"Mand", txtBoxMandant.Text.ToString());
cmd.Parameters.Add(@"MID", txtBoxKürzel.Text.ToString());
???
I tested it, still doesn't work.
Also placed it in CommandText and instead the ? with Parameter Names
|
|
|
|
|
You really should read the SqlParameter documentation. The solution is:
SqlCommand cmd = cmd.connDB.CreateCommand();
cmd.CommandText = @"INSERT INTO MandantMC (
Mand,
MID
VALUES (@Mand, @MID)";
cmd.Parameters.Add("@Mand", SqlDbType.NVarChar, 40).Value = txtBoxMandant.Text;
cmd.Parameters.Add("@MID", SqlDbType.NVarChar, 40).Value = txtBoxKürzel.Text; Notice the placement of "@". These are used for the parameter names. Replace "NVarChar" with whatever string type you defined in your SQL Server table and "40" with whatever length you defined for each column.
Also, why are you using Text.ToString() ? The Control.Text (inheritted by every derivative of Control like TextBox ) is already a string. You're wasting CPU time on unnecessary instructions.
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]
|
|
|
|
|
Thank you !
Remember my first code ?
Here the new CommandText
cmd.CommandText = @"INSERT INTO MandantMC (Mand,MID) VALUES (@Mand,@MID)";
Only 1 Line used. My last code doesn't work in multiple lines seperated by "+". Don't understand it...maybe compiler has problems with translating.
I never use toString on Textboxes. It was only for testing purpose while SQL Error occured. Also waste of typing
|
|
|
|
|
You shouldn't use string concatentation and "@" together. The literal character, "@", is so that you don't have to escape special characters (like backslashes) or so that your text can span multiple lines. Both your original code and my example of using "@" (but honestly, such a short SQL command is easier to read as a single line) would compile. Your only problem is that in the first code you posted you had a comma after MID which may cause a SqlException to be thrown; it's an extraneous comma.
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]
|
|
|
|
|
I am writing a c# windows application and want it to fill out a simple HTML form, submit the form, and return the content of the returned webpage. Is this possible?
I know how to use WebRequest and WebResponse to retrieve the content of a specific webpage, but I can not figure out how to retrieve the content of a webpage accessed by submitting a form.
Here's what the form looks like for some more info:
<html>
<form method=post action="../cgi-bin/homestead/mail.pl?mama172">
Name:
<input type="text" size="35" name="name">
Address?
input type="text" size="40" name="address">
City?
<input type="text" size="25" name="city">
<input type ="submit" value="Send">
</form>
</html>
|
|
|
|
|
Take a look at the HttpWebRequest.GetRequestStream[^] for HttpWebRequest.GetRequestStream which shows a good example of sending a POST request to a CGI sitting off on some web server.
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]
|
|
|
|
|
|
|
I have some code to open up a word document and add paragraph to the end of the document and then save and close the document. Now creating a word application object is fine, the opening a word document is fine. The problem occurs when I use this code
1. Word.Paragraph wordPara;
2. wordPara = wordDoc.Content.Paragraphs.Add(ref wordRng);
3. wordPara.Range.Text = "Original electronically authenticated by " + physName + " on " + strDateTime;
4. wordPara.Range.Font.Bold = 1;
5. wordPara.Range.InsertParagraphAfter();
For some reason after line 3 runs I recieve this error: "The server threw an excpetion". That is only error I recieve. In my project I am referencing the Microsoft Word 10.0 Object Library can anyone help?
Nicholas Ingratta
ningratt@hotmail.com
|
|
|
|