|
pontonet wrote: WTF!
Why not learn more about the environment in which you are developing before exclaiming "WTF!". The difference between value and reference types is in any good beginners guide to .NET and/or C#.
|
|
|
|
|
sometimes we forgot the basic, even after read a lot of stuffs.
sometimes we are kinda influencied by other languages, like java.
a DateTime tends to be a real object instead of a value type - it has properties, methods, constructors, etc. so the difference isn`t so obvious.
|
|
|
|
|
If you're using C# 2.0 you can declare DateTime as nullable with the following:
DateTime? dataTermino = null;
if(txtDataInicio.Text != "")
dataTermino = DateTime.Parse(txtDataTermino.Text);
if(dataTermino != null)
insertCommand.Parameters.Add(new SqlParameter("@DataTermino", dataTermino));
(note the "?" after DateTime)would work. If you're not using 2.0 & need to pass null date to SQL , have a look at:
http://www.c-sharpcorner.com/Code/2003/Sept/EnterNullValuesForDateTime.asp[^]
Hope this helps
|
|
|
|
|
Does anyone know of an easy way to maintain a series of assembly 'reference paths' across a large number of projects.
I understand they are persisted in the proejct 'user' settings files. Initially i was wondering whether you could do something similar to a #Include in a xml. So at least they would only be stored once.
Cheers
Aj
|
|
|
|
|
what you want isn`t the same result achieved with a added DLL reference mapped directly to the user file system?
|
|
|
|
|
Hello,
How can I get all contents in RichTextBox and convert it to HTML format
My RichTextBox on winform. And I want to get it contents in HTML to sent it to my mail. But it doesn't work properly when I set BodyFormat = HTML.
Thank you,
ACB
-- modified at 12:25 Thursday 26th October, 2006
ngh
|
|
|
|
|
You could set it so it can only save as .htm(L)
|
|
|
|
|
I've used this in the past:
<pre> public string ToHTML(RichTextBox Box)
{
string sReturn;
long lColour;
bool bBold;
bool bItalic;
string sFont;
long lSize;
long lOldSelStart;
long lOldSelLength;
long a;
//Initial box setup
{
lOldSelStart = Box.SelStart;
lOldSelLength = Box.SelLength;
Box.SelStart = 0;
Box.SelLength = 1;
}
//Initial text
sReturn = "<html>";
//Inital paramaters
lColour = Box.SelColor;
bBold = Box.SelBold;
bItalic = Box.SelItalic;
sFont = Box.SelFontName;
lSize = Box.SelFontSize;
//Initial font setup
sReturn = sReturn + "<font size=\"" + Box.SelFontSize + "\" face=\"" + Box.SelFontName + "\" color=\"" + Box.SelColor + "\">";
//Initial bold setup
if (Box.SelBold == true)
{
sReturn = sReturn + "<b>";
}
//Initial italic setup
if (Box.SelItalic == true)
{
sReturn = sReturn + "<i>";
}
//Append new character
sReturn = sReturn + Strings.Mid(Box.Text, 1, 1);
for (a = 2; a <= Strings.Len(Box.Text); a++) {
//Set up reading paramater
{
Box.SelStart = a - 1;
Box.SelLength = 1;
}
//Check for updated font tage
if (Box.SelColor != lColour | Box.SelFontName != sFont | Conversion.Int(Box.SelFontSize) != lSize)
{
sReturn = sReturn + "</font><font size=\"" + Box.SelFontSize + "\" face=\"" + Box.SelFontName + "\" color=\"" + Box.SelColor + "\">";
}
//Check for changed boldness
if (Box.SelBold != bBold)
{
if (Box.SelBold == false)
{
sReturn = sReturn + "</b>";
}
else
{
sReturn = sReturn + "<b>";
}
}
//Check for changed italics
if (Box.SelItalic != bItalic)
{
if (Box.SelItalic == false)
{
sReturn = sReturn + "</i>";
}
else
{
sReturn = sReturn + "<i>";
}
}
sReturn = sReturn + Strings.Mid(Box.Text, a, 1);
//Update paramaters
lColour = Box.SelColor;
bBold = Box.SelBold;
bItalic = Box.SelItalic;
sFont = Box.SelFontName;
lSize = Box.SelFontSize;
}
//Check ending bold and italic
if (bBold == true) sReturn = sReturn + "</b>";
if (bItalic == true) sReturn = sReturn + "</i>";
//Terminate HTML
sReturn = sReturn + "</font></html>";
//Restore box values
{
Box.SelStart = lOldSelStart;
Box.SelLength = lOldSelLength;
}
return sReturn;
//Return value
}
</pre>
|
|
|
|
|
how can i get to know if a file is still copying?
thank you
|
|
|
|
|
Surely if you call
System.IO.File.Copy synchronously you'll know when it finishes when the call returns?
Regards,
Rob Philpott.
|
|
|
|
|
sorry that isn't what i want because i am not the coppier.
the file will be copied by someone else and i will work with the file.
but i must get to know if the file was copied completely before i work with it
|
|
|
|
|
If you try the following code
try{
System.IO.File.OpenWrite("MyFile.txt");
} catch (System.IO.IOException ex) {
System.Windows.Forms.MessageBox.Show("File is locked");
}
This will throw an error because the file is locked if it is still copying.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
|
|
|
|
|
Simple and to the point 'The Man from U.N.C.L.E.'
Thanks and Regards,
Aby
|
|
|
|
|
isn't there a possibility without throwing an exception?
|
|
|
|
|
Hey All,
I've been playing with the textbox in C#. I cannot seem to get it so that uppercase characters and lowercase characters take up the same amount of space in the box. For example like in the textbox here on CP to enter messages:
this line aligns perfectly with
THIS LINE ALIGNS PERFECTLY
They both align perfectly regardless of case. In my textbox, if I use uppercase on one line and lowercase on the next line, the uppercase line takes up a lot more space and they do not line up.
TIA!
|
|
|
|
|
...the two lines lign up perfect in the textbox here to enter in the message, but when it is displayed it is displaying exactly like I am talking about in my application.
|
|
|
|
|
Have you tried using a font like Lucida Console?
(Fixed width font - every character uses the same width)
|
|
|
|
|
Incredibly cool, that worked!!!! Thanks! Do you know how to tell (other than trying them one by one) which fonts are fixed width?
Again, thanks a lot!
|
|
|
|
|
You can retrieve a fixed width font family using System.Drawing.FontFamily family = System.Drawing.FontFamily.GenericMonospace.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
i'm looking for a method that searches for a string in another string;
for example i have str and i have strap and if i search for str in strap , the method is supposed to return a value(where the string was found), but if i search for stp in strap, it's supposed to return null. Can you name this method??
rzvme
|
|
|
|
|
Hi there,
I believe the method that you are looking for is String.IndexOf(). IndexOf() will not return null, but will return -1 if it does not find the substring.
String sMyString = "strap";
int iPosition = sMyString.IndexOf("str"); // iPosition will equal 0 (start of the string)
iPosition = sMyString.IndexOf("stp"); // iPosition will equal -1 (not found)
On another note, just to let you know. If you are just looking for a substring within a string and you don't care about the position it was found in, you could use String.Contains() ...
<br />
String sMyString = "strap";<br />
if (sMyString.Contains("str"))<br />
{<br />
MessageBox.Show("STR WAS FOUND IN " + sMyString);<br />
}<br />
|
|
|
|
|
|
This question is more about programming methedology than anything else.
The question is simpily which is better out of the following programming methods:
This is a C# project.
There are five different classes in the project.
There are 2 classes that that need to be used by other classes. There may be more classes used by others in the future.
Communications method 1:
Any class that needs to use another class, simpilly calls methods from the other class. The class methods are called from are passed into the first class when it is instanced.
e.g.
Class A = class that writes to files.
Class B = class that needs to use files.
so when creating class B
private B beta = new B(A);
Communications method 2:
There is an overall Communications class.
Every class that needs to call upon methods in another class is required to use the comms class to do so.
e.g.
Class A = class that writes to files.
Class B = class that needs to use files.
Class C = the communications class.
so while in class B,
c.comms(<class to="" talk="" id="">,<items passed="" in="">);
Which would you use?
Or would you use something else?
(If this is the wrong place, feel free to tell me)
Munty
|
|
|
|
|
How about letting any class just create objects from the class that it needs?
---
b { font-weight: normal; }
|
|
|
|