|
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 ]
|
|
|
|
|
He's trying to fill a DataSet , not update the database. Besides, if you specify SqlDbType.DateTime for the column type then the value should be an instance of the DateTime struct.
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]
|
|
|
|
|
There is no time type in SQL Server. If you're referring to the timestamp type then be sure to read the documentation for the SqlDbType enumeration.
A timestamp translates to a byte[] array. In SQL Server a timestamp is an automatically generated array of binary numbers that is guaranteed to be unique with a database. It is not a time portion of a DateTime or anything like it.
If DataAdapter.Fill is having trouble determining the proper type then you'll need to define the DataColumn s in your DataTable within the DataSet manually. The easiest way to do this is to create a typed DataSet using VS.NET.
You can drag-n-drop tables, views, or stored procedures from Server Explorer (i.e., from connected databases) into the designer when you create a new DataSet type. Right-click on your project (or a folder within your project) and click Add->Add New Type. Then click "DataSet", give it a name, and click OK. Now you get what looks like (and actually is) the XML Schema designer. Drag any of those objects from the Server Explorer I mentioned above onto this surface, or design the tables and fields (elements and child elements) yourself. You can even add DataRelation s and keys in this view as well.
When you compile your project a typed DataSet is created. Instantiate a new instance of this DataSet instead of the base DataSet class.
For performance improvements, use the typed table and column properties which decrease the number of required look-ups to find the correct table or column, respectively.
On the other hand, you chould change the type in SQL Server. If you intended to have a field that stores just the time, then you need to declare it as a DateTime field in SQL Server. It's your views and what you do with the data that determine if the time, date, or both matter.
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]
|
|
|
|
|
Is there any way for me to store forms that are minimized in a separate container window?
I would like the forms, when maximized to be shown on the main window form and when minimised stored in this separate container window.
|
|
|
|
|
Within your own application there's not much you cannot do. If you want to capture minimized windows from other processes that's a different matter. The Windows shell (Windows Explorer) handles this and there's not much you can do.
You could install a Windows hook using the WH_CBT (0x5) message and handling the HCBT_MINMAX (0x1) notification message in your CBTProc callback. These refer to native functionality so you'll need to be familiar with P/Invoke. Above all - be careful. Windows system hooks are hooks for messages throughout the entire system. Your code must be efficient and robust, meaning that it can fail gracefully and cleans itself up if problems occur.
For more information about using system hooks in C#/.NET, read Using Hooks from C#[^] here on CodeProject. Do be sure to read the information in the Platform SDK specifically for the WH_CBT hook for information about the callback parameter values (like which ones pass you the HWND (an IntPtr in managed code) that you can use in calls to other native APIs).
While you won't be able to stop the default behavior using this approach (and I honestly can't think of any other hooks or sinks you can use from all my experience and research), you could P/Invoke other native APIs like GetWindowText to collect information about windows and display some captioned icon in a window of your choosing.
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]
|
|
|
|
|
Suppose I have built program that can save it state in some files. I'm interested in basics on how can I register an file type to my application (when file with extension .myProj is doubleclicked my program opens and loads state from that file)... I'm using Setup for deploying application.
Tnx in advance for any idea
|
|
|
|
|