473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Treeview select highlight problem

3
I am populating a treeview in C# from a SQL Server 2005 database.
Table tree( id int, parent_id int, name varchar(50).

The treeview is populated succesfully and when I select a node it is highlited. But if the nodename for example is 5 characters long the highlite is much longer. I think the treeview takes the width from the database table because I have already changed the varchar(50) to varschar(20) and the highlight width is smaller then, but it is still a fixed width.

What must I do so that the hightlighting is as long as the actual length of a nodename?
Mar 17 '07 #1
4 1814
Hi,

is it possible that something has added spaces to the ends of the data?

for instance, when you see "John"...does the computer see "John" followed by several space characters?

try iterating thru the data (or the tree nodes)...and call the trim method

ex:
myDataString.Trim() ... or ... myTreeNode.Text.Trim()

that will remove all white space from the front and back of the tree node's text. if you still have the problem after this...then extra space characters is not the issue.
Mar 18 '07 #2
....here is what may be the culprit...what the ANSI-PADDING option was set to when the data table was created...

from a page at microsoft's website:
"The varchar data type is a variable-length data type. Values shorter than the size of the column are not right-padded to the size of the column. If the ANSI_PADDING option was set to OFF when the column was created, any trailing blanks are truncated from character values stored in the column. If ANSI_PADDING was set ON when the column was created, trailing blanks are not truncated."
keep in mind i've never worked with sql...so i could be way off base here.

but if this is the case...seems like there ought to be a way to fix the data before you add it to the treeview.
Mar 18 '07 #3
HeavyD
3
Thank you for your help.

ANSI padding off or the trim() method when ANSI padding is on does the trick.
What is the best setting for ANSI padding. Default it was on but isn't off better for performance?
Mar 18 '07 #4
Thank you for your help.

ANSI padding off or the trim() method when ANSI padding is on does the trick.
What is the best setting for ANSI padding. Default it was on but isn't off better for performance?
hi heavyd,

i would guess "off" is better...but that's a guess...this is a good question for the SQL SERVER forum.

--William
Mar 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve | last post by:
I have created a transparent custom drawn treeview in c#(using lots of native code as well) that has a bitmap for its background. As well as that, I have created a custom highlight that is a...
1
by: ADAM BETCHER | last post by:
Hi: I am using TreeView in a Microsoft Access 2000 form. I can create the tree, populate it and select items. Now I want to Programmatically select and highlight a node on the tree based...
4
by: Phill | last post by:
Here's what I'm doing to make the right context mnue show up based on what node was cliked: private void tvwMenu_MouseUp(object sender, MouseEventArgs e) { //Select Node When Right Clicked &...
2
by: Carl Gilbert | last post by:
Hi I have a Treeview component on a form which when loaded selects a node from the treeview. The problem is that I can not get the node to remain highlighted. The app is sucessfully...
0
by: Treeview Trouble | last post by:
I have an application where there are two radio buttons each of which populates a treeview control with a directory structure. Each radio button corresponds to a different directory which may or...
4
by: praveen | last post by:
I have a form with treeview control loaded from xml document,text box, two buttons named "Find" and "FindNext" and my treeview which looks like below. Details |__ policy status |__ created by...
3
by: Michael_Burgess | last post by:
Hi there, I've looked around the different groups and still can't figure this out without resorting to scrappy code............ I want to programtically select and highlight a TreeView node,...
1
by: Nikron | last post by:
Hi, I'm having an issue with the ASP.NET 2.0 Treeview control and persisting its' state accross requests. My Control is embedded within a master page and is used for site navigation. My problem...
18
by: =?Utf-8?B?TGkgV2VuZw==?= | last post by:
Hi, Is there a way for TreeView to have multiple selections? But I am not talking about its checked boxes. I want a way similar to ListView with MultiSelect = True. So I can use or key and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.