Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3550
Exception while loading definitions
posted

var YAHOO = {'Shortcuts' : {}}; if (typeof YAHOO == "undefined") { var YAHOO = {}; } YAHOO.Shortcuts = YAHOO.Shortcuts || {}; YAHOO.Shortcuts.hasSensitiveText = false; YAHOO.Shortcuts.sensitivityType = []; YAHOO.Shortcuts.doUlt = false; YAHOO.Shortcuts.location = "us"; YAHOO.Shortcuts.document_id = 0; YAHOO.Shortcuts.document_type = ""; YAHOO.Shortcuts.document_title = "\u00d7\u0092\u00d7\u00a8\u00d7\u0099\u00d7\u0093"; YAHOO.Shortcuts.document_publish_date = ""; YAHOO.Shortcuts.document_author = "gilad.sefti@mailpoalim.co.il"; YAHOO.Shortcuts.document_url = ""; YAHOO.Shortcuts.document_tags = ""; YAHOO.Shortcuts.document_language = ""; YAHOO.Shortcuts.annotationSet = { "lw_1244631662_0": { "text": "System.IO", "extended": 0, "startchar": 973, "endchar": 981, "start": 973, "end": 981, "extendedFrom": "", "predictedCategory": "", "predictionProbability": "0", "weight": 1, "relScore": 0, "type": ["shortcuts:/us/place/virtual/web_site"], "category": ["IDENTIFIER"], "wikiId": "", "relatedWikiIds": [], "relatedEntities": [], "showOnClick": [], "context": "System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using Infragistics.Win.UltraWinGrid; using Infragistics.Win; namespace CheckRestore { public partial class Form1", "metaData": { "visible": "true" } } }; YAHOO.Shortcuts.headerID = "37507dfe6be42058ab7eeb8524771f76";

I get an exception when loading definitions.

"Object reference not set to an instace of an object."

It seems the problem is when applying condition definitions, Otherwise there is no problem.

I attach the sample.

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win;

namespace CheckRestore
{
    public partial class Form1 : Form
    {

        MemoryStream savedStream = new MemoryStream();
        public Form1()
        {
            InitializeComponent();
        }

        private void btnSaveDefs_Click(object sender, EventArgs e)
        {
            savedStream = new MemoryStream();
            ultraGrid1.DisplayLayout.Save(savedStream, PropertyCategories.Bands);
        }

        private void btnLoadDefs_Click(object sender, EventArgs e)
        {
            savedStream.Seek(0, 0);
            ultraGrid1.DisplayLayout.Load(savedStream, PropertyCategories.Bands);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            List<Item> ls = new List<Item>();
            ls.Add(new Item(0));
            ls.Add(new Item(1));
            ultraGrid1.DataSource = ls;

        }

        private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e)
        {
            UltraGridBand band = e.Layout.Bands[0];
            Infragistics.Win.Appearance appearanceRed = new Infragistics.Win.Appearance();
            appearanceRed.ForeColor = Color.Red;

            OperatorCondition conditionRed = new OperatorCondition(ConditionOperator.LessThanOrEqualTo, 0);
            ConditionValueAppearance valAppearanceAvailable = new ConditionValueAppearance();
            valAppearanceAvailable.Add(conditionRed, appearanceRed);
            band.Columns["Num"].ValueBasedAppearance = valAppearanceAvailable;

        }
    }
    public class Item
    {
        public Item(int num)
        {
            mNum = num;
        }
        private int mNum;

        public int Num
        {
            get { return mNum; }
            set { mNum = value; }
        }

    }
}

namespace CheckRestore
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();
            this.ultraGrid1 = new Infragistics.Win.UltraWinGrid.UltraGrid();
            this.btnSaveDefs = new System.Windows.Forms.Button();
            this.btnLoadDefs = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.ultraGrid1)).BeginInit();
            this.SuspendLayout();
            //
            // ultraGrid1
            //
            appearance4.BackColor = System.Drawing.SystemColors.Window;
            appearance4.BorderColor = System.Drawing.SystemColors.InactiveCaption;
            this.ultraGrid1.DisplayLayout.Appearance = appearance4;
            this.ultraGrid1.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
            this.ultraGrid1.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.False;
            appearance1.BackColor = System.Drawing.SystemColors.ActiveBorder;
            appearance1.BackColor2 = System.Drawing.SystemColors.ControlDark;
            appearance1.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            appearance1.BorderColor = System.Drawing.SystemColors.Window;
            this.ultraGrid1.DisplayLayout.GroupByBox.Appearance = appearance1;
            appearance2.ForeColor = System.Drawing.SystemColors.GrayText;
            this.ultraGrid1.DisplayLayout.GroupByBox.BandLabelAppearance = appearance2;
            this.ultraGrid1.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
            appearance3.BackColor = System.Drawing.SystemColors.ControlLightLight;
            appearance3.BackColor2 = System.Drawing.SystemColors.Control;
            appearance3.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
            appearance3.ForeColor = System.Drawing.SystemColors.GrayText;
            this.ultraGrid1.DisplayLayout.GroupByBox.PromptAppearance = appearance3;
            this.ultraGrid1.DisplayLayout.MaxColScrollRegions = 1;
            this.ultraGrid1.DisplayLayout.MaxRowScrollRegions = 1;
            appearance12.BackColor = System.Drawing.SystemColors.Window;
            appearance12.ForeColor = System.Drawing.SystemColors.ControlText;
            this.ultraGrid1.DisplayLayout.Override.ActiveCellAppearance = appearance12;
            appearance7.BackColor = System.Drawing.SystemColors.Highlight;
            appearance7.ForeColor = System.Drawing.SystemColors.HighlightText;
            this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance = appearance7;
            this.ultraGrid1.DisplayLayout.Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.Dotted;
            this.ultraGrid1.DisplayLayout.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Dotted;
            appearance6.BackColor = System.Drawing.SystemColors.Window;
            this.ultraGrid1.DisplayLayout.Override.CardAreaAppearance = appearance6;
            appearance5.BorderColor = System.Drawing.Color.Silver;
            appearance5.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
            this.ultraGrid1.DisplayLayout.Override.CellAppearance = appearance5;
            this.ultraGrid1.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.EditAndSelectText;
            this.ultraGrid1.DisplayLayout.Override.CellPadding = 0;
            appearance9.BackColor = System.Drawing.SystemColors.Control;
            appearance9.BackColor2 = System.Drawing.SystemColors.ControlDark;
            appearance9.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
            appearance9.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
            appearance9.BorderColor = System.Drawing.SystemColors.Window;
            this.ultraGrid1.DisplayLayout.Override.GroupByRowAppearance = appearance9;
            appearance11.TextHAlignAsString = "Left";
            this.ultraGrid1.DisplayLayout.Override.HeaderAppearance = appearance11;
            this.ultraGrid1.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
            this.ultraGrid1.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
            appearance10.BackColor = System.Drawing.SystemColors.Window;
            appearance10.BorderColor = System.Drawing.Color.Silver;
            this.ultraGrid1.DisplayLayout.Override.RowAppearance = appearance10;
            this.ultraGrid1.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.False;
            appearance8.BackColor = System.Drawing.SystemColors.ControlLight;
            this.ultraGrid1.DisplayLayout.Override.TemplateAddRowAppearance = appearance8;
            this.ultraGrid1.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
            this.ultraGrid1.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate;
            this.ultraGrid1.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy;
            this.ultraGrid1.Location = new System.Drawing.Point(28, 73);
            this.ultraGrid1.Name = "ultraGrid1";
            this.ultraGrid1.Size = new System.Drawing.Size(606, 232);
            this.ultraGrid1.TabIndex = 0;
            this.ultraGrid1.Text = "ultraGrid1";
            this.ultraGrid1.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(this.ultraGrid1_InitializeLayout);
            //
            // btnSaveDefs
            //
            this.btnSaveDefs.Location = new System.Drawing.Point(44, 30);
            this.btnSaveDefs.Name = "btnSaveDefs";
            this.btnSaveDefs.Size = new System.Drawing.Size(97, 23);
            this.btnSaveDefs.TabIndex = 1;
            this.btnSaveDefs.Text = "Save definitions";
            this.btnSaveDefs.UseVisualStyleBackColor = true;
            this.btnSaveDefs.Click += new System.EventHandler(this.btnSaveDefs_Click);
            //
            // btnLoadDefs
            //
            this.btnLoadDefs.Location = new System.Drawing.Point(236, 30);
            this.btnLoadDefs.Name = "btnLoadDefs";
            this.btnLoadDefs.Size = new System.Drawing.Size(97, 23);
            this.btnLoadDefs.TabIndex = 2;
            this.btnLoadDefs.Text = "Load definitions";
            this.btnLoadDefs.UseVisualStyleBackColor = true;
            this.btnLoadDefs.Click += new System.EventHandler(this.btnLoadDefs_Click);
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(672, 317);
            this.Controls.Add(this.btnLoadDefs);
            this.Controls.Add(this.btnSaveDefs);
            this.Controls.Add(this.ultraGrid1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            ((System.ComponentModel.ISupportInitialize)(this.ultraGrid1)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid1;
        private System.Windows.Forms.Button btnSaveDefs;
        private System.Windows.Forms.Button btnLoadDefs;
    }
}

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    I'm afraid I don't understand your question. What line of code are you getting an exception on?

    A Nullreference Exception indicates that the code is trying to reference a property on an object variable which is null.

Children