[Mono-bugs] [Bug 462818] New: Mono DataGridView is hiding rows

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Dec 29 14:18:09 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=462818


           Summary: Mono DataGridView is hiding rows
           Product: Mono: Class Libraries
           Version: 2.2.x
          Platform: PC
        OS/Version: openSUSE 11.0
            Status: NEW
          Severity: Blocker
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: rodrigosilvabrito at hotmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: DeveloperNet


Description of Problem:

In MS's runtime this code work fine, in mono linux behavior unexpected!

Steps to reproduce the problem:

1. Generate and compile the code!

-- Program.cs

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace DataGridViewProblem
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmDataGridProblem());
        }
    }
}

-- frmDataGridProblem.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DataGridViewProblem
{
    public partial class frmDataGridProblem : Form
    {
        BindingList<Cash> list;

        public frmDataGridProblem()
        {
            InitializeComponent();

            list = new BindingList<Cash>();

            for (int i = 0; i <= 6; i++)
            {
                Cash cash = new Cash();
                cash.Date = DateTime.Now;
                cash.Memo = "Memo "  + i.ToString();
                cash.Increase = i;
                cash.Reduce = 0;

                list.Add(cash);
            }

            dgvList.DataSource = list;
        }

        public Cash Selected
        {
            get
            {
                return this.dgvList.CurrentRow.DataBoundItem as Cash;
            }
            set
            {
                for (int i = 0; i < this.dgvList.Rows.Count; i++)
                {
                    if (value == dgvList.Rows[i].DataBoundItem as Cash)
                    {
                        dgvList.Rows[i].Selected = true;
                        dgvList.CurrentCell = dgvList.Rows[i].Cells[0];
                        break;
                    }
                }
            }
        }

        private void Find(string lookFor)
        {
            foreach (Cash cash in this.list)
            {
                if (lookFor.Length <= cash.Memo.Length)
                {
                    if (cash.Memo.Substring(0, lookFor.Length) == lookFor)
                    {
                        this.Selected = cash;
                        return;
                    }
                }
            }
        }

        private void tsbFind_Click(object sender, EventArgs e)
        {
            this.Find(tscLookFor.Text);
        }

        private void tscLookFor_TextChanged(object sender, EventArgs e)
        {
            if (tscLookFor.Text.Length > 0)
            {
                tsbFind.Enabled = true;
                this.Find(tscLookFor.Text);
            }
            else
            {
                tsbFind.Enabled = false;
                if (dgvList.Rows.Count > 0)
                {
                    dgvList.Rows[0].Selected = true;
                    dgvList.CurrentCell = dgvList.Rows[0].Cells[0];
                }
            }
        }

        private void tsbShowCurrent_Click(object sender, EventArgs e)
        {
            MessageBox.Show(this.Selected.Memo);
        }
    }

    public class Cash
    {
        private Nullable<DateTime> date = DateTime.Today;
        private string memo = string.Empty;
        private decimal increase = 0;
        private decimal reduce = 0;

        public Nullable<DateTime> Date
        {
            get { return date; }
            set { date = value; }
        }

        public string Memo
        {
            get { return memo; }
            set { memo = value; }
        }

        public decimal Increase
        {
            get { return increase; }
            set { increase = value; }
        }

        public decimal Reduce
        {
            get { return reduce; }
            set { reduce = value; }
        }
    }
}

-- frmDataGridProblem.Designer.cs

namespace DataGridViewProblem
{
    partial class frmDataGridProblem
    {
        /// <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()
        {
            System.ComponentModel.ComponentResourceManager resources = new
System.ComponentModel.ComponentResourceManager(typeof(frmDataGridProblem));
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 =
new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 =
new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 =
new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 =
new System.Windows.Forms.DataGridViewCellStyle();
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.tslSearch = new System.Windows.Forms.ToolStripLabel();
            this.tscLookFor = new System.Windows.Forms.ToolStripComboBox();
            this.tsbFind = new System.Windows.Forms.ToolStripButton();
            this.tsbShowCurrent = new System.Windows.Forms.ToolStripButton();
            this.dgvList = new System.Windows.Forms.DataGridView();
            this.toolStrip1.SuspendLayout();
           
((System.ComponentModel.ISupportInitialize)(this.dgvList)).BeginInit();
            this.SuspendLayout();
            // 
            // toolStrip1
            // 
            this.toolStrip1.GripStyle =
System.Windows.Forms.ToolStripGripStyle.Hidden;
            this.toolStrip1.Items.AddRange(new
System.Windows.Forms.ToolStripItem[] {
            this.tslSearch,
            this.tscLookFor,
            this.tsbFind,
            this.tsbShowCurrent});
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(584, 25);
            this.toolStrip1.TabIndex = 0;
            this.toolStrip1.TabStop = true;
            // 
            // tslSearch
            // 
            this.tslSearch.Name = "tslSearch";
            this.tslSearch.Size = new System.Drawing.Size(60, 22);
            this.tslSearch.Text = "Look for:  ";
            // 
            // tscLookFor
            // 
            this.tscLookFor.FlatStyle =
System.Windows.Forms.FlatStyle.Standard;
            this.tscLookFor.Name = "tscLookFor";
            this.tscLookFor.Size = new System.Drawing.Size(121, 25);
            this.tscLookFor.TextChanged += new
System.EventHandler(this.tscLookFor_TextChanged);
            // 
            // tsbFind
            // 
            this.tsbFind.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Text;
            this.tsbFind.Enabled = false;
            this.tsbFind.Image =
((System.Drawing.Image)(resources.GetObject("tsbFind.Image")));
            this.tsbFind.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.tsbFind.Name = "tsbFind";
            this.tsbFind.Size = new System.Drawing.Size(34, 22);
            this.tsbFind.Text = "&Find";
            this.tsbFind.Click += new System.EventHandler(this.tsbFind_Click);
            // 
            // tsbShowCurrent
            // 
            this.tsbShowCurrent.Alignment =
System.Windows.Forms.ToolStripItemAlignment.Right;
            this.tsbShowCurrent.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Text;
            this.tsbShowCurrent.Image =
((System.Drawing.Image)(resources.GetObject("tsbShowCurrent.Image")));
            this.tsbShowCurrent.ImageTransparentColor =
System.Drawing.Color.Magenta;
            this.tsbShowCurrent.Name = "tsbShowCurrent";
            this.tsbShowCurrent.Size = new System.Drawing.Size(81, 22);
            this.tsbShowCurrent.Text = "Show current";
            this.tsbShowCurrent.Click += new
System.EventHandler(this.tsbShowCurrent_Click);
            // 
            // dgvList
            // 
            this.dgvList.AllowUserToAddRows = false;
            this.dgvList.AllowUserToDeleteRows = false;
            this.dgvList.AllowUserToOrderColumns = true;
            this.dgvList.AllowUserToResizeRows = false;
            dataGridViewCellStyle1.BackColor =
System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))),
((int)(((byte)(238)))));
            this.dgvList.AlternatingRowsDefaultCellStyle =
dataGridViewCellStyle1;
            this.dgvList.BackgroundColor = System.Drawing.Color.GhostWhite;
            this.dgvList.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.dgvList.ColumnHeadersBorderStyle =
System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
            dataGridViewCellStyle2.BackColor =
System.Drawing.Color.LightSteelBlue;
            dataGridViewCellStyle2.Font = new System.Drawing.Font("Tahoma",
8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
            dataGridViewCellStyle2.ForeColor =
System.Drawing.SystemColors.ControlDarkDark;
            dataGridViewCellStyle2.SelectionBackColor =
System.Drawing.SystemColors.Highlight;
            dataGridViewCellStyle2.SelectionForeColor =
System.Drawing.SystemColors.HighlightText;
            dataGridViewCellStyle2.WrapMode =
System.Windows.Forms.DataGridViewTriState.True;
            this.dgvList.ColumnHeadersDefaultCellStyle =
dataGridViewCellStyle2;
            this.dgvList.ColumnHeadersHeight = 20;
            this.dgvList.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            this.dgvList.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dgvList.Location = new System.Drawing.Point(0, 25);
            this.dgvList.MultiSelect = false;
            this.dgvList.Name = "dgvList";
            this.dgvList.RowHeadersBorderStyle =
System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
            dataGridViewCellStyle3.BackColor =
System.Drawing.SystemColors.ButtonFace;
            dataGridViewCellStyle3.Font = new System.Drawing.Font("Tahoma",
8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
            dataGridViewCellStyle3.ForeColor =
System.Drawing.SystemColors.WindowText;
            dataGridViewCellStyle3.SelectionBackColor =
System.Drawing.SystemColors.Highlight;
            dataGridViewCellStyle3.SelectionForeColor =
System.Drawing.SystemColors.HighlightText;
            dataGridViewCellStyle3.WrapMode =
System.Windows.Forms.DataGridViewTriState.True;
            this.dgvList.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
            this.dgvList.RowHeadersVisible = false;
            this.dgvList.RowHeadersWidth = 4;
            dataGridViewCellStyle4.SelectionBackColor =
System.Drawing.Color.FromArgb(((int)(((byte)(37)))), ((int)(((byte)(73)))),
((int)(((byte)(84)))));
            dataGridViewCellStyle4.SelectionForeColor =
System.Drawing.Color.White;
            this.dgvList.RowsDefaultCellStyle = dataGridViewCellStyle4;
            this.dgvList.RowTemplate.DefaultCellStyle.Font = new
System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dgvList.RowTemplate.Height = 18;
            this.dgvList.SelectionMode =
System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            this.dgvList.Size = new System.Drawing.Size(584, 347);
            this.dgvList.TabIndex = 1;
            // 
            // frmDataGridProblem
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(584, 372);
            this.Controls.Add(this.dgvList);
            this.Controls.Add(this.toolStrip1);
            this.Name = "frmDataGridProblem";
            this.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "DataGridView not is selecting the row!";
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
           
((System.ComponentModel.ISupportInitialize)(this.dgvList)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.ToolStrip toolStrip1;
        private System.Windows.Forms.ToolStripButton tsbShowCurrent;
        private System.Windows.Forms.DataGridView dgvList;
        private System.Windows.Forms.ToolStripLabel tslSearch;
        private System.Windows.Forms.ToolStripButton tsbFind;
        private System.Windows.Forms.ToolStripComboBox tscLookFor;
    }
}


2. Execute the program in mono linux, select first row "Memo 0", after press
down arrow key, bookmark select next row, press again down arrow key and again
until select last row. When the last row is selected, the rows 0,1,2,3,4 are
hided.

Actual Results:
    The rows are being hided from DataGridView

Expected Results:
    No hide rows.

How often does this happen? 
Ever, All!


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list