LogoLogo
HomeNewsSupportVideos
  • Introduction
  • Getting Started
  • What's new in 4.0
    • Known Issues
    • .NET Core Designer
    • Managed Graphics
    • Fluent Markup
    • Markdown Support
    • Upgrade from 3.x
  • Releases
    • What's new in 4.0
    • What's new in 3.5
    • What's new in 3.2
      • View Builder
      • Validation Rules
      • Enhanced Font Support
      • Design-Time Debug
    • What's new in 3.1
    • What's new in 3.0
      • FAQs
      • Update Existing Projects
      • Multi Targeting
      • Visual Studio Designer
      • Referencing Assemblies
      • Docker Support
      • Troubleshooting
      • Deployment
    • What's new in 2.5
    • What's new in 2.2
    • What's new in 2.1
    • What's new in 2.0
    • Upgrade from 1.x
  • Getting Started
    • New Project
    • Templates
    • Troubleshooting
    • License Activation
    • FAQ
    • API
    • Hybrid
    • Deployment
    • Theme Builder
  • Concepts
    • Startup
    • Configuration
    • Load Balancing
    • Designer
    • Layouts
    • Client Profiles
    • Tab Order
    • Compression
    • Embedded Resources
    • Modal Workflow
    • Localization
    • RightToLeft
    • Background Tasks
    • Real Time Web Applications
    • JavaScript
    • JavaScript Object Model
    • Security
    • Synchronization
    • Session Management
    • Theming
    • Dependency Injection
    • Application Switches
    • Visual Studio Code
  • Controls & Components
    • General
      • Application
      • AutoSizing
      • AutoScroll
      • AutoScaling
      • Accessibility
      • Colors & Fonts
      • Embedded Tools
      • Events
      • Touch Events
      • Images
      • Labels
      • ToolTips
      • Data Binding
      • Common Properties
      • Custom Painting
      • Move & Resize
      • Drag & Drop
      • Validation
      • User Data
      • Responsive Properties
      • VB.NET Extensions
    • Common Dialogs
      • FolderBrowserDialog
      • ColorDialog
      • OpenFileDialog
      • SaveFileDialog
    • Editors
      • TextBox
        • TagTextBox
        • MaskedTextBox
        • TypedTextBox
      • DateTimePicker
      • MonthCalendar
      • TimeUpDown
      • DomainUpDown
      • NumericUpDown
      • TrackBar
    • Buttons
      • Button
      • SplitButton
      • CheckBox
      • RadioButton
    • Containers
      • Page
      • Form
      • Desktop
      • Panel
      • FlexLayoutPanel
      • FlowLayoutPanel
      • TableLayoutPanel
      • GroupBox
      • Accordion
      • TabControl
      • UserPopup
      • UserControl
      • ToolBar
      • StatusBar
      • SplitContainer
      • SlideBar
    • Lists & Grids
      • ComboBox
        • UserComboBox
        • TreeViewComboBox
        • ListViewComboBox
      • ListBox
        • CheckedListBox
      • TreeView
      • ListView
      • DataGridView
        • Column
        • TextBoxColumn
        • ButtonColumn
        • LinkColumn
        • ImageColumn
        • MaskedTextBoxColumn
        • DateTimePickerColumn
        • NumericUpDownColumn
        • CheckBoxColumn
        • ComboBoxColumn
      • DataRepeater
      • PropertyGrid
    • Extenders
      • Animation
      • ToolTip
      • ErrorProvider
      • Rotation
      • StyleSheet
      • JavaScript
    • Media
      • Audio
      • Video
      • FlashPlayer
    • Content
      • Label
      • LinkLabel
      • PictureBox
      • ScrollBars
      • Upload
      • AspNetPanel
      • ImageList
      • PdfViewer
      • ProgressBar
      • Spacer
      • Widget
      • WebBrowser
      • IFramePanel
      • HtmlPanel
      • Canvas
      • Shape
      • Line
    • Menus
      • MainMenu
      • MenuBar
      • MenuItem
      • LinkMenuItem
      • ContextMenu
    • Notifications
      • AlertBox
      • MessageBox
      • Toast
    • Other Components
      • Timer
      • BindingSource
      • BindingNavigator
      • DataSet
      • EventLog
      • MessageQueue
      • PerformanceCounter
Powered by GitBook
On this page
  • Extend the class
  • Tag Property
  • UserData property

Was this helpful?

Export as PDF
  1. Controls & Components
  2. General

User Data

PreviousValidationNextResponsive Properties

Last updated 3 years ago

Was this helpful?

There are at least three ways to add custom properties (or user data) to controls in Wisej.NET:

  1. Extend the class

  2. Tag property

  3. UserData property

Extending the class is the most flexible approach but in some cases it's not feasible to create a new class of a control just to add a value use in a small specific context.

The property is available at design time at provides a quick way to add custom information to an instance of a control.

The property is a dynamic object that allows you to add any kind of fields to a control without having to create a new class.

Extend the class

All Wisej.NET control classes can be used as the base class of your classes. You can create new types of buttons, tab pages, tree nodes, grid cells, grid rows, columns, forms, etc.

For example, if you need to have a instance that is associated with a Customer instance you can create a CustomerTreeNode class.

class CustomerTreeNode : Wisej.Web.TreeNode
{
    public Customer Customer {get; set; }
}

...

this.treeView1.Nodes.Add(new CustomerTreeNode
{
    Customer = goodCustomer
});
Class CustomerTreeNode
    Inherits Wisej.Web.TreeNode
    
    Public Property Customer
    
End Class

...

Me.TreeView1.Nodes.Add(New CustomerTreeNode With 
{
    .Customer = goodCustomer
    

You can use the new CustomerTreeNode class just like the base TreeNode class, including at design time. When adding nodes at design time, the designer will show a drop down button to pick the specific TreeNode class to add.

Tag Property

UserData property

For example, we can "attach" a Customer instance to a TreeNode without creating a CustomerTreeNode class like this:

var node = new TreeNode();
node.UserData.Customer = goodCustomer;
this.treeView1.Nodes.Add(node);

// Alternative using the property name.
var node = new TreeNode();
node.UserData["Customer"] = goodCustomer;
this.treeView1.Nodes.Add(node);
' this is necessary in VB.NET to use dynamic objects.
Option Strict Off

Dim node As New TreeNode();
node.UserData.Customer = goodCustomer
Me.TreeView1.Nodes.Add(node)

' with strict on use the propert name.
Option Strict On

Dim node As New TreeNode();
node.UserData("Customer") = goodCustomer
Me.TreeView1.Nodes.Add(node)

As shown in the code snippet above, the UserData property is a dynamic object and a dictionary.

All controls and components in Wisej.NET expose the property of type object. You can "tag" any control or component with any value of any type.

The property is similar to the Tag property except that it's a dynamic object that can hold any number of fields of any kind.

To check whether an object has any data in the UserData dictionary without forcing the creation of the storage object, use the property.

Tag
UserData
TreeNode
Tag
UserData
HasUserData