FrmDatos: Evitar fallos con imágenes vacías

This commit is contained in:
2013-11-26 21:37:05 +01:00
parent b2d7fda236
commit 9940c5dcb9
2 changed files with 27 additions and 9 deletions

View File

@@ -37,26 +37,25 @@
this.dgvDatos.AllowUserToAddRows = false;
this.dgvDatos.AllowUserToDeleteRows = false;
this.dgvDatos.AllowUserToOrderColumns = true;
this.dgvDatos.AllowUserToResizeRows = false;
this.dgvDatos.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvDatos.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgvDatos.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvDatos.Location = new System.Drawing.Point(12, 12);
this.dgvDatos.Name = "dgvDatos";
this.dgvDatos.ReadOnly = true;
this.dgvDatos.RowHeadersVisible = false;
this.dgvDatos.Size = new System.Drawing.Size(347, 308);
this.dgvDatos.TabIndex = 0;
this.dgvDatos.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvDatos_CellContentClick);
this.dgvDatos.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvDatos_CellDoubleClick);
this.dgvDatos.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvDatos_CellFormatting);
//
// frmDatos
// FrmDatos
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(371, 332);
this.Controls.Add(this.dgvDatos);
this.Name = "frmDatos";
this.Name = "FrmDatos";
this.Text = "frmDatos";
this.Load += new System.EventHandler(this.frmDatos_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvDatos)).EndInit();

View File

@@ -11,6 +11,8 @@ namespace ServerExplorer.UI
{
public partial class FrmDatos : Form
{
#region Form life cycle
public FrmDatos(DataTable dt, String titulo)
{
InitializeComponent();
@@ -21,6 +23,23 @@ namespace ServerExplorer.UI
private void frmDatos_Load(object sender, EventArgs e) { }
private void dgvDatos_CellContentClick(object sender, DataGridViewCellEventArgs e) { }
#endregion
#region Events
private void dgvDatos_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { }
private void dgvDatos_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (e.DesiredType == typeof(Image))
{
if (e.Value is DBNull || ((byte[])e.Value).Length <= 0)
{
e.Value = new Bitmap(1, 1);
}
}
}
#endregion
}
}