user-controls

Design-time editor support for controls collection

邮差的信 提交于 2019-12-30 02:29:24
问题 I'd like to add a property which represents a collection of controls to a component and have a collection editor with which I can easily select the controls that belong to the collection. VS does almost what I want automatically with the following code: Private _controls As New List(Of Control) <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Public ReadOnly Property SelectedControls() As List(Of Control) Get Return _controls End Get End Property I get the default

load a user control programmatically in to a html text writer

别说谁变了你拦得住时间么 提交于 2019-12-30 01:27:06
问题 I am trying to render a user control into a string. The application is set up to enable user to use tokens and user controls are rendered where the tokens are found. StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); HtmlTextWriter writer = new HtmlTextWriter(sw); Control uc = LoadControl("~/includes/HomepageNews.ascx"); uc.RenderControl(writer); return sb.ToString(); That code renders the control but none of the events called in the Page_Load of the control are

load a user control programmatically in to a html text writer

不羁的心 提交于 2019-12-30 01:27:06
问题 I am trying to render a user control into a string. The application is set up to enable user to use tokens and user controls are rendered where the tokens are found. StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); HtmlTextWriter writer = new HtmlTextWriter(sw); Control uc = LoadControl("~/includes/HomepageNews.ascx"); uc.RenderControl(writer); return sb.ToString(); That code renders the control but none of the events called in the Page_Load of the control are

add user control to a form

て烟熏妆下的殇ゞ 提交于 2019-12-30 00:49:04
问题 I have created a user control with a TextBox and two Buttons, but I haven't created events, just I place them to user control. When I want to add the user control to my form it says: Cannot move Task_control.cs. The destination folder is the same as the source folder. I can't understand why. 回答1: After creating your user control, you should build the project ( F6 or Ctrl + Shift + B ). Then Visual Studio automatically adds the control to the Toolbox . You should drag the control from the

UserControl DependencyProperty binding in ListView

戏子无情 提交于 2019-12-29 09:22:16
问题 When I try to use a custom UserControl in a ListView, it fails and only empty blocks are displayed (the following TextBlock works though). While the customControl outside the ListView works pretty well. What's the problem? MainWindow.xaml <Grid> <StackPanel> <controls:CustomControl x:Name="customControl" CustomText="Test"/> <ListView x:Name="listView"> <ListView.ItemTemplate> <DataTemplate> <StackPanel> <controls:CustomControl CustomObject="{Binding}"/> <TextBlock Text="{Binding Text}"/> <

Simple OpenGL GUI Framework User Interaction Advice? [closed]

ぃ、小莉子 提交于 2019-12-29 09:13:11
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I'm designing a simple GUI framework from scratch as a project, using OpenGL and nothing else external and need some advice on how I might implement user interaction. Basically, I've a base class GUIItem from which all elements inherit. This gives each item some basic

Remove Row inside TableLayoutPanel makes a layout problem

别等时光非礼了梦想. 提交于 2019-12-29 09:11:22
问题 I have a WinForms application that has a TableLayoutPanel ; this is the definition code: tableLayoutPanel1 = new TableLayoutPanel(); tableLayoutPanel1.Dock = DockStyle.Fill; tableLayoutPanel1.AutoScroll = true; tableLayoutPanel1.RowCount = users.Count + 1; tableLayoutPanel1.ColumnCount = 1; tableLayoutPanel1.GrowStyle = TableLayoutPanelGrowStyle.FixedSize; tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); foreach (String user in users) { tableLayoutPanel1.RowStyles

UserControl has IsPostBack, but Control does not

落花浮王杯 提交于 2019-12-29 01:53:08
问题 i'm trying to solve a bug in Visual Studio, the suggestion is to stop using UserControls and use Control instead.. So i'm converting all my UserControl into just Control , e.g.: public partial class Controls_UserManagement_GroupManager : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) becomes public partial class Controls_UserManagement_GroupManager : System.Web.UI.Control { protected void Page_Load(object sender, EventArgs e) { if (

Simple Dependency Property and UserControl issues in C#

ぃ、小莉子 提交于 2019-12-29 01:44:13
问题 My end goal is to expose the Text value of a TextBox that I have in a UserControl , from the UserControl 's call in XAML. <my:UserControl SetCustomText="Blah blah this is variable"> would render the UserControl with that TextBox 's text filed in. I've been working at it using various examples but I always end up with "The Property SetCustomText was not found in type UserControl" 回答1: Example of how you can do this: <UserControl x:Class="Test.UserControls.MyUserControl1" xmlns="http://schemas

A 'Binding' can only be set on a DependencyProperty of a DependencyObject

做~自己de王妃 提交于 2019-12-28 05:36:18
问题 From a custom control based on TextBox , I created a property named Items , in this way: public class NewTextBox : TextBox { public ItemCollection Items { get; set; } } When using the custom control in XAML, I cannot bind the property because it raises exception "A 'Binding' can only be set on a DependencyProperty of a DependencyObject.". How do I solve this exception? 回答1: As a side note, it is also worth noting that you will get these binding errors if you copy and paste between objects and