.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Listbox control display property

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :.NET Framework

Iam using vb.net 2.0. I have implimented  Autocomplete textbox using  textbox and listbox.These are part of grid view controls. 

If i enter data in 1st row textbox the suggestions listbox  box it is coming in between the 1 st and 2nd row of grid.So alignment is getting disturbed. How can i display the suggestions list box over the second row of grid.

I have tried chaging the display property of listbox..but no change in display..i think some other property is obveriding this.


Please help me in this.

Thanks in Advance,


View Complete Post

More Related Resource Links

Custom Server Control Property not maintaining state


I have created a server control consisting of a TextArea and a div under it.  My goal is to create my own asp:TextArea type control.  the div is for a Character count of the text area and seems to work ok but i added a CharacterCountVisible property to the control that is always returning true.  See Proptery definition below


<Bindable(False), Category("Appearance"), DefaultValue("True"), Localizable(True)> Property CharacterCountVisible() As Boolean
        Return _CountBoxVisible
    End Get
    Set(ByVal value As Boolean)
        _CountBoxVisible = value
    End Set
End Property

Note the _CountBoxVisible variable is define inside the class as :

Dim _CountBoxVisible as Boolean = True

What I am trying to do is give the user/coder the option to show/utilize the char count feature.  Can make it disappear with textarea1.CharacterCountVisible = False but setting it to true will not make it display.


What am i missing





Persist data in a dynamically populated ListBox in a user control


Hi All,

I am trying to persist data in a dynamically populated ListBox in a user control. Here are the details

I have a user control which contains a a listBox and button. On Page_Load of user control I am populating the ListBox control with some values. On Click of button, I am trying to fetch the values which I have selected in ListBox. Though this seems very simple and straight forward I am unable to fetch values.

My Page_Load Function

void Page_Load(object sender, EventArgs e)










My Click Function

Protected Void Button1_Click(object sender, EventArgs e)


       string strValue = listBox.SelectedValue



I have placed brake point at Page_Load and on click function, I am seeing that the moment the breakpoin

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

ActiveX and Visual Basic: Enhance the Display of Long Text Strings in a Combobox or Listbox


The combobox and listbox controls in Visual Basic have no built-in support for displaying text strings that are too long to fit in the visible area of either control. This article describes several techniques to improve the readability of long strings in each control. The first technique uses tooltips to display a combobox or listbox item. The other techniques, which use various Windows APIs, include adding a horizontal scrollbar for a listbox and determining the necessary width of the longest string given the font attributes of the text. The required steps are described for both comboboxes and listboxes.

John Calvert

MSDN Magazine December 2000

Passing Primary Key to User Control to Display Record Detail


I'm building a user control to display detail information on a parent record. The user control will be displayed via an Ajax Modal Popup. The user control works and is displayed when expected. The problem that I'm having is that I'm not able to pass in the primary key for the parent. The control is displayed via the _ItemCommand event of a Repeater. In the markup for the user control, I explicity set the ContactId to 0 to avoid an error when the control loads (its still underdevelopment, eventually that I'll check if the value is valid).

I was assuming that I could change the property in the _ItemCommand event, but obviously its not working.

In the Page_Load event this code successfully sets the ContactId property of the control. The _ItemCommand event appears to set the value. However when I set a test label on the user control to the Me.ContactId, its showing '0' as if it was never passed in.

        UserControlContactDetail.ContactId = "1462"
        test.Text = UserControlContactDetail.ContactId

    Protected Sub RepeaterDirectory_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles RepeaterDirectory.ItemCommand

Protected Sub RepeaterDirectory_ItemCommand(By

User Control and DataSourceID Property


I created a user control (.ascx) that contains a paging-user-control, a repeater and some other controls.
I want to use the property DataSourceID. How should I get the data from the datasource and when?
What is the recommended way?

I did it this way:
- Create a method to get the data by reflection, like:

private void PerformSelect()
	if (!String.IsNullOrEmpty(this.DataSourceID))
		Control control = Page.FindControl(this.DataSourceID);
		if (control == null)
			control = Parent.FindControl(this.DataSourceID);

		MethodInfo method = control.GetType().GetMethod("Select");
		IEnumerable data = (IEnumerable)method.Invoke(control, new object[0]);

		this.DataSource = data;
 - Call this method
In PageLoad when no postback
Changing the current page (paging-user-control)
Changing the current tab (tab-user-control)
Switching Visibility to true

I think that way is not the optimum, is there any better way?
Do you have any suggestions or links?

Thanks for your help, Andreas

User Control as Composite Control Property


I have a composite control (Called Dialog) which has a property "ContentControl"

At design time, I'd like this property to bind to a user control that is on the page.

When I add the items in the designer, the designer loads as expected.

However, when I try to run the web page, I get the following error:

Parser Error Message: Cannot create an object of type 'System.Web.UI.UserControl' from its string representation 'EditTerm1' for the 'ContentControl' property.

Please let me know if there is another way to bind a user control as a property of a composite control.


Designer Code:


	<cc1:Dialog ID="Dialog1" runat="server" Buttons="SaveCancel" 
Title="Edit Term" ContentControl="EditTerm1" />

set an asp control property value with a label value


hi.. please help me on this

i have a control to upload multiple files on server. now i want to set the control's "upload folder"  property with a dynamic value which is different for each user..

<cc1:FileUploader ID="FileUploader1" runat="server">

                    <cc1:FileSaverAdapter FolderName= "FOLDERNAME" />


here i want this 'FolderName' value to be replaced with some label value. how can i do this ?

Thanks in advance .. :)

Model Display Property On View


How can I show display property of Model on View.


public class Model
        [DisplayName("First Name")]
        public string FirstName { get; set; }
        <div>FirstName</div><---Here I want to show Dispaly name
        <div><%= Html.Encode(Model.FirstName) %></div>

Problem in Custom Control Unable to find Control To Validate Property


I make a custome control by taking a TextBox and A Regular Expression Validator.When i Use this on a .aspx page it works fine.But when i use this on .ascx page and dynamically load user control on a place holder in .aspx page it through an Error

Unable to find control id '_ctl0:txtEmail' referenced by the 'ControlToValidate' property of '_ctl0:txtEmailRequired'


My Custome control Code is this"--

public class EmailValidator:System.Web.UI.Control, INamingContainer{

private System.Web.UI.WebControls.TextBox textBox;

private System.Web.UI.WebControls.RegularExpressionValidator regularExpressionValidator;

public EmailValidator(){

textBox = new TextBox();

regularExpressionValidator = new RegularExpressionValidator();

IsErrorTextBelow = true;

IsRequired = false;

Microsoft Report Viewer control to display data on one page


Hello everyone,

I am wondering if the Microsoft Report Viewer control allows for display changes.  Say for instance a user wants would like to see all the data requested then another time would like to toggle thru the pages of infomation.  So does anyone know if the control allows for display changes from complete view to paginated viewing.  I am using MS VS 2008 with ASP.NET 3.0.  Thanks for your response.


Microsoft ListView Control 6.0 cannot correctly display multibyte characters when running on a 64 bi

With all the regional settings set to Russian and the OS being Russion the ListView Control 6.0 does not display the column headers correctly on the Windows Server 2008 64 bit OS. If we switch to using Microsoft ListView Control, version 5 the columns (text strings) are displayed correctly. I am concerned that using an earlier version is going to cause problems. Is there a better solution other than using version 5? Thanks!

UserControl with a control property?

Hi... I have defined a UserControl wich needs to reference another control like this: <ctrl:Cook TheList="listView1" DefaultFileName="MyRecipe"></ctrl:Cook> The code behind of the control has the property defined:         public ListView TheList { get; set; } But I have a runtime error saying: 'ListView' type does not have a public TypeConverter class. And in design time I get: Property TheList of type ListView cannot be specified as string.   I know WPF is trying to read a string instead of a ListView, but dont know the magic solution. Maybe a converter? Please suggest the simpler solution you can, because this is not a vital requirement on the app. Thanks in advance for any help  

Creating a volume control slider/setting one template property based on another

So, what I want to do, is to make a volume control that looks like a right angle triangle with the 90 degree angle on the bottom right, and then when you click on it, the area to the left of the selected point is shown in a different color.  In other words, I've created a slider with the right background, what I can't do, is work out how to show the selected area by filling in the triangle.  I have worked out how to bind the height of my triangle on the left to the value of the control, but right now, the rate of rise is exactly half of what I need it to be.  I need to know how to change the template for the area to the left of the selection ( which is the repeat button ) so that the background is twice the height that it is right now.  No matter what size I make the slider, the area is always 1/2 the size it needs to be, so I am sure if I could get it to double inside my template, it would work fine. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">       <Style x:Key="SliderButtonStyle" TargetType="{x:Type RepeatButton}">         <Setter Property="SnapsToDevicePixels" Value="true"/>         <

Dynamic Binding of a Public Property in a User Control

Hi, I am not sure how to pass a variable from an .aspx page to an .ascx page.  I have a Control that puts rotating banners on a page.  The control has several public properties.  However, only one of those properties changes on the page level.  All the other properties are the same for every page site-wide.  So, instead of setting all the properties on every page in my sites (many sites), I want to set it up so I only have to setup the sitewide properties once and only the page level properties on each page.   I want to create a control with a property of AdKeyword="somename" and pass it to another control that will grab that page-level property and add it to all the other site-wide properties.  I guess what I need could be called a Dynamic Control Property.   My .aspx page has:<%@ Register TagPrefix="uc1" TagName="Banner1" Src="banner1.ascx" %> <asp:Content ID="Leaderboard" runat="server" ContentPlaceHolderID="Leaderboard"> <uc1:Banner1 AdKeyword="L2Chamber" runat="server" OverrideHeight="90" /> </asp:Content> My banner1.ascx page has:<%@ Control Language="VB" ClassName="UserControl297" %> <%@ register tagprefix="uc1&

A reportviewer control bug to display unicode?

  1 Hello everyone, I am using VSTS 2008 + C# + .Net 3.5 + ASP.Net + IIS 7.0 with reportviewer control. The report created by reportviewer control is very simple, just a single line of Chinese characters (I wrote the line of characters statically in a textbox control, no addtional dynamically generating or fetching from database). I upload the error PDF file exported by the report viewer and screen snapshot here, and my most confusion is why the exported PDF file is just 2k bytes size? Is this issue caused by font not embedded in PDF file? Actually I did not find how to embed font in PDF file. Appreciate if anyone could give me some good ideas. This is the error PDF displayed screen snapshot, http://www.4shared.com/photo/gs_KvxSW/characterissue.html This is the error PDF itself, http://www.4shared.com/document/4Fs5rCH_/characterissue.html thanks in advance, George

How Would I Create a Trigger That Changes The Property of Another Control?

I have 4 of the same controls and to make it simple I will act like I am working with the background:  <Style x:Key="backgroundTrigger"> <Style.Triggers> <Trigger Property="GroupBox.Background" Value="Red"> <Setter Property="GroupBox.Background" Value="Blue"></Setter> </Trigger> </Style.Triggers> </Style>   In essence what I am trying to do is when the background of groupBox1 changes I want the trigger to change groupbox2's background to Red without changing GroupBox1 background. I keep running into errors because I am using the same property in the condition and in the setter and also that the the name "GroupBox2" cannot be found. Although what I am actually trying to do isn't related to the background if someone could explain how it could be it would be greatly helpful.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend