|
I am creating an instance of class at runtime from assembly through reflection.I then Serialize the class(including the delegates) and send it to remote machine from where I deserialize the received bytes.I can get an Exception i.e. its not deserialized in short!
However when I perform this whole mechanism without including Delegates... it works and the result is exactly what i want.
Can somebody help me on this ?
Thanks in Advance!
|
|
|
|
|
|
hey guys, i need to check a stirng if it contain the "ESC" character i searched for the representation of this char which was '\e' but when i write this char in the C# code it doesn't recognize it, does anyone knows how to do it?
|
|
|
|
|
What do you mean "when i write this char in the C# code"? How do you "write" it? The .NET Framework General Reference states that \e is the escape sequence for the ESC character, but it really matters what your "string" contains, how it's encoded, and how you're searching for the string. How are you searching the string? How is it encoded?
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 ment simply writing a string whith this character as the following:
string strTest = "This is a Test\e string" ;
the '\e' character should represent an ESC but the compiler doesn't recognize this escape character, any way i found another way which is represnting the ESC as the follwoing:
string strTest = "This is a Test\u001B string" ;
the '\u001B' match the ESC char.
actully u can write the following:
char chTest = '\u001B' ;
which is totally legal.
|
|
|
|
|
Hello,
I am using the generic TreeView Control from .Net 2002.
I want to have the root nodes of the control to have a bold font and I thought this could be easily done by setting the NodeFont attribute of the node.
However, when I do this the font is indeed bold but it seems that the control does not resize the text box the node text is drawn in and the text gets clipped (I assume becase the new bold font is wider than the previously assigned text which isn't bold by default).
Does anybody know what I can do to fix this.
Sample of code below:
TreeView treeView = new TreeView();
...
TreeNode tn = new TreeNode("Test");
tn.NodeFont = new Font(treeView.Font, FontStyle.Bold);
...
Thank you in advance,
Eric
|
|
|
|
|
Simply add this line to ur code
TreeView treeView=new TreeView();
..
TreeNode tn = new TreeNode("Test");
System.Drawing.Font newFont=new System.Drawing.Font(treeView.Font, FontStyle);
tn.NodeFont = newFont;
treeView.Font = newFont;
...
//I hope u wud have understand the reason :P
Take Care
|
|
|
|
|
As I was afriad, the additional line of code (i.e. setting the treeView Font) just makes every node in treeView have the same font.
I only want the root nodes to be different!
Any other help; or maybe I didn't understand what you meant.
Eric
|
|
|
|
|
Alright !
TreeView treeView=new TreeView();
..
//-----Code For Adding the Root Node------
TreeNode tn = new TreeNode("Test");
System.Drawing.Font newFont=new System.Drawing.Font(treeView.Font, FontStyle.Bold);
tn.NodeFont = newFont;
treeView.Font = newFont;
...
//-----Code For Adding the Children Node------
TreeNode tn = new TreeNode("Test");
System.Drawing.Font newFont=new System.Drawing.Font(treeView.Font, FontStyle.Normal);
tn.NodeFont = newFont;
//OfCourse You add this Children to the Parent Node
//So add it to the Parent Node here but dont
//set or change the treeview Font.Only Set the Font of the Node
//OKAY ????
...
//The moral of the story is that u set the font of the treeview Ctrl
//to one that takes more graphical units (in value of course) for display text, so to avoid the clipping of text.Since displaying
//text in bold takes more graphical units as compared to same text in same
//normal font.So thats the reason u set the font treeview while adding the
//root node.
I hope u got the point
|
|
|
|
|
I see.
Seems like a funny way to have to set fonts for a node but I understand the reason why.
Thanks,
Eric
|
|
|
|
|
Hi,
i want to display multiple images into listview by using imagelist,but main problem is that only first image is getting displayed but rest of selected all can't displayed.Here is code for that.
ImageList = new ImageList();
int j=0;
LstVwImage.Items.Clear();
for (int i = 0; i < 4; j++)
{
try
{
System.Drawing.Image myImage = Image.FromFile(openImage.FileNames[j]);
ImageList.Images.Add(myImage);
//openImage.FileNames[j].IndexOf(openImage.FileNames[j]);
LstVwImage.Items.Add(openImage.FileNames[j],j);
//openImage.FileNames[j] = openImage.FileNames[j] + 1;
}
catch (System.IndexOutOfRangeException Ex)
{
break;
}
}
regards,
montu3377
|
|
|
|
|
You're declaring j outside your for loop, then i inside your for loop but you increment j inside yoru for loop which will never terminate because i will never be less than 4 (you're not increment it at all). Please either fix your code or correct the example because what you have doesn't make sense. What you have will loop forever and j will keep increasing till either an IndexOutOfRangeException is thrown - and this is an exception that can easily be avoided with proper bounds-checking - or an OverflowException occurs from j incrementing past the Int32.MaxValue .
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]
|
|
|
|
|
hello i am working on control derived from a rich text box i have overrided the Text method and am trying to parse the string to not display certain characters however here is my problem
i am creating a new string within a loop with all the usefull chars in the passed string. i know this works i can see the new data in debug and it works correctly the problem is when i assign it to base.Text nothing happens however when i use the original string it display all of the original data so what is preventing showing the new string? ive tried adding \n \r and \0 but non do anythning
|
|
|
|
|
First of all understand that the Text property is merely the plain-text version of what you see; it encodes almost no formatting.
That beind said, what characters are you trying to eliminate? Are you assuming single-byte characters or are you using the appropriate classes in the System.Text namespace to remove characters?
Also, for performance reasons you should be using the StringBuilder class if you're not already. String s are immutable. Any operation you perform on a string requires a new string to be created and manipulated and the old string destroyed. Every time you simply add a single character this is done. Using a StringBuilder eliminates this problem. Use StringBuilder.ToString to get a string from the instance of the StringBuilder .
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]
|
|
|
|
|
here is what it looks like
void parsestring(string str)
{
string str2 = "";
for(int i = 0; i < str.Length; i++)
if(str[i] != '&')
str2 += str[i];
base.Text = str2;
}
i know that the string is being created properly when i am in debug cuase i can see the new value it just isnt setting base.Text if i used base.Text = str it would work fine
|
|
|
|
|
And where does str come from? What you think is meaningless may not be.
Once again, you should not use string concatenation for the reasons I mentioned before. Every time you execute str2 += str[i] a new string is allocated to hold str2.Length + 1 characters, then all of str2 is copied in and then str[i] is copied. That's very expensive. Using a StringBuilder for str2 and using StringBuilder.Append is much faster since a new string is not allocated with every iteration. Then just set base.Text = str2.ToString() .
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]
|
|
|
|
|
str comes from the overriden Text its value
|
|
|
|
|
Can you please post all relevent code, like what you actually assign to the overridden Text 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]
|
|
|
|
|
i tried the stringbuilder and got the same results
public override string Text
{
get
{
return base.Text;
}
set
{
ColorAnsiString(value);
}
}
public void ColorAnsiString(string s)
{
StringBuilder str = new StringBuilder(s.Length);
Color col = colors[(int)ColorCodes.BLACK].Col;
int i = 0, x = 0, y = 0, n = 0;
for(i = 0; i < s.Length; i++)
{
if(i > s.Length || i+1 > s.Length)
break;
if(s[i] == '&')
{
if(i+1 < s.Length)
{
if(s[i+1] == '+')
{
for(x = 0; x< (int)ColorCodes.MAX; x++)
{
if(s[i+2] == colors[x].Key)
{
col = colors[x].Col;
break;
}
}
}
}
for(n = 0, y = i+3; y < s.Length; y++, n++)
{
str.Append(s[y]);
if(s[y] == '&' || s[y] == '\0' || s[y] == '\n' || s[y] == '\r')
{
//str += '\r';
base.Text = str;
//this.Select(base.Text.Length-str.Length, base.Text.Length);
// SelectionColor = col;
// i+=str.Length;
//
// col = colors[(int)ColorCodes.WHITE].Col;
return;
}
}
}
}
}
if you replace base.Text with s it works when its str it doesnt
|
|
|
|
|
Do not use \r, \n, or \r\n but Environment.NewLine . That will always return the correct line ending for text on the current platform.
Also, what exactly are you trying to do? As I've been trying to get from you this whole time, your code isn't necessarily wrong but what you're attempting to do may be. The RichTextBox.Text property is plain text with only new line and tab characters being supported as the only "format" characters. If you're trying to encode text with color information you need to be modifying the RichTextBox.Rtf property.
Since you're replacing - or at one point was replacing - character with invalid escape sequence the RichTextBox (rather, the Rich Edit common control that is encapsulated) is most likely rejecting the text completely. Immediately after setting base.Text use Marshal.GetLastWin32Error() and compare that with what you see in teh documentation for the Rich Edit Message reference online at http://msdn.microsoft.com/library[^]. You may actually have to look at the headers (installed with VS.NET by default, but you can download them from http://msdn.microsoft.com/platformsdk[^] to see what those error values correspond to.
You should also use a decompiler like .NET Reflector (google for it) to see how the RichTextBox actually sets the text.
Whatever text you're giving to the RichTextBox.Text property is not acceptable, which is what I've been trying to get you to see. The code itself is fine, and my suggestion about using StringBuilder was not to fix your problem but to help you avoid other performance problems with veyr inefficient 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]
|
|
|
|
|
im not doing any fancy text or inserting new characters im just trying to remove some characters from the original string put it in a new string and put it in the text box im just simply trying to find out why my new string isnt getting put into the text box yet my original one shows just fine if i use it instead of the new one
|
|
|
|
|
i just tried to do base.Text = "hello" and this doesnt even work or if i modify the string that was passed that doesnt work either
|
|
|
|
|
I am trying to iterate over an array and grab performance values for each value in the array.
For instance:
public void getstuff()
{
string[] computers = {"coruscant", "tatooine", "alderran"};
foreach ( string comp in computers)
{
try
{
this.performanceCounter2.MachineName = comp;
string cpu =performanceCounter2.NextValue().ToString();
}
catch ( Exception e)
{
MessageBox.Show(e.Message);
}
The thing is im looking for an exception of sort so that if the node is not available/perf service stopped) it just moves along to the next value. The above doesn't seem to throw an exception, but the lil app wedges up pretty hard after a few loops.
Is there anyway I can check, fairely quickly that the value exists then if it doesn't move on to the next value in the array?
sween3
--
Thank you.
|
|
|
|
|
i stored a Time field in MySQL database and the DBAdapter.Fill() use DateTime to store the return value. and, this leads to 'FormatException'.
do u know any method to do some custom datatype matching to solve this problem? or, i just go to change the datatype in database to string or other simply datatype?
thanks,
jim
|
|
|
|
|
Try to use ToString() method before passing into the database.
Eg: DateTime dt;<br />
<br />
Assume that,<br />
dt is 12-12-2004 12:24:44 Am;<br />
<br />
dt.ToString("yyyy-MMM-dd") will return 2004-Dec-12.<br />
dt.ToString("yyyy/MMM/dd") will return 2004/Dec/12.<br />
<br />
dt.ToString("yyyy-MM-dd") will return 2004-12-12.<br />
dt.ToString("yyyy/MM/dd") will return 2004/12/12.<br />
<br />
dt.ToString("mm-DD-yyyy") will return 12-12-2004.<br />
dt.ToString("mm/DD/yyyy") will return 12/12/2004.
Hope this will serve your purpose.
Sreejith Nair
[ My Articles ]
|
|
|
|