CustomListView: ListView que permite reordenar los datos (AllowSorting)

This commit is contained in:
2013-11-22 00:50:24 +01:00
parent 4f7664794f
commit 12e67b0e25
8 changed files with 182 additions and 85 deletions

View File

@@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Collections;
namespace ServerExplorer.Controls
{
[DefaultProperty("Items")]
[DefaultEvent("SelectedIndexChanged")]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[Docking(DockingBehavior.Ask)]
public class CustomListView : ListView
{
#region Declarations
ListViewItemComparer itemComparer = new ListViewItemComparer();
#endregion
#region Properties
private bool allowSorting = false;
public bool AllowSorting
{
get { return allowSorting; }
set { allowSorting = value; }
}
#endregion
#region Control life cicle
public CustomListView()
{
ColumnClick += CustomListView_ColumnClick;
}
#endregion
#region Events
private void CustomListView_ColumnClick(object sender, ColumnClickEventArgs e)
{
if (!allowSorting) { return; }
itemComparer.SetColumn(e.Column);
ListViewItemSorter = itemComparer;
Sort();
}
#endregion
}
#region ListViewItemComparer
class ListViewItemComparer : IComparer
{
private int col;
private bool ascending;
public void SetColumn(int col)
{
if (this.col == col)
{
ascending = ascending ? false : true;
}
else
{
this.col = col;
ascending = true;
}
}
public int Compare(object x, object y)
{
int returnVal = -1;
if (ascending)
{
returnVal = String.Compare(
((ListViewItem)x).SubItems[col].Text,
((ListViewItem)y).SubItems[col].Text);
}
else
{
returnVal = String.Compare(
((ListViewItem)y).SubItems[col].Text,
((ListViewItem)x).SubItems[col].Text);
}
return returnVal;
}
}
#endregion
}

View File

@@ -70,6 +70,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Controls\CustomListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="DatabaseDesc.cs" />
<Compile Include="DocGen.cs" />
<Compile Include="FrmBaseDatos.cs">

View File

@@ -31,15 +31,15 @@
this.txtConString = new System.Windows.Forms.TextBox();
this.lblConString = new System.Windows.Forms.Label();
this.btnCopiarConString = new System.Windows.Forms.Button();
this.lsvTablas = new System.Windows.Forms.ListView();
this.colNombreTabla = new System.Windows.Forms.ColumnHeader();
this.colEsquema = new System.Windows.Forms.ColumnHeader();
this.colTipo = new System.Windows.Forms.ColumnHeader();
this.lsvColumnas = new System.Windows.Forms.ListView();
this.colNombreColumna = new System.Windows.Forms.ColumnHeader();
this.colTipoDatos = new System.Windows.Forms.ColumnHeader();
this.colTamanho = new System.Windows.Forms.ColumnHeader();
this.colClave = new System.Windows.Forms.ColumnHeader();
this.lsvTablas = new ServerExplorer.Controls.CustomListView();
this.colNombreTabla = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colEsquema = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colTipo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.lsvColumnas = new ServerExplorer.Controls.CustomListView();
this.colNombreColumna = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colTipoDatos = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colTamanho = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colClave = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.menuBaseDatos = new System.Windows.Forms.MenuStrip();
this.archivoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuCargar = new System.Windows.Forms.ToolStripMenuItem();
@@ -91,6 +91,7 @@
//
// lsvTablas
//
this.lsvTablas.AllowSorting = true;
this.lsvTablas.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)));
@@ -102,7 +103,7 @@
this.lsvTablas.FullRowSelect = true;
this.lsvTablas.Location = new System.Drawing.Point(3, 40);
this.lsvTablas.Name = "lsvTablas";
this.lsvTablas.Size = new System.Drawing.Size(332, 468);
this.lsvTablas.Size = new System.Drawing.Size(317, 468);
this.lsvTablas.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.lsvTablas.TabIndex = 4;
this.lsvTablas.UseCompatibleStateImageBehavior = false;
@@ -125,6 +126,7 @@
//
// lsvColumnas
//
this.lsvColumnas.AllowSorting = false;
this.lsvColumnas.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)));
@@ -136,7 +138,7 @@
this.lsvColumnas.FullRowSelect = true;
this.lsvColumnas.Location = new System.Drawing.Point(3, 40);
this.lsvColumnas.Name = "lsvColumnas";
this.lsvColumnas.Size = new System.Drawing.Size(458, 439);
this.lsvColumnas.Size = new System.Drawing.Size(473, 439);
this.lsvColumnas.TabIndex = 6;
this.lsvColumnas.UseCompatibleStateImageBehavior = false;
this.lsvColumnas.View = System.Windows.Forms.View.Details;
@@ -168,7 +170,7 @@
this.menuConfiguracion});
this.menuBaseDatos.Location = new System.Drawing.Point(7, 195);
this.menuBaseDatos.Name = "menuBaseDatos";
this.menuBaseDatos.Size = new System.Drawing.Size(181, 24);
this.menuBaseDatos.Size = new System.Drawing.Size(195, 24);
this.menuBaseDatos.TabIndex = 9;
this.menuBaseDatos.Text = "menuBaseDatos";
this.menuBaseDatos.Visible = false;
@@ -180,34 +182,34 @@
this.menuCargar,
this.menuGuardar});
this.archivoToolStripMenuItem.Name = "archivoToolStripMenuItem";
this.archivoToolStripMenuItem.Size = new System.Drawing.Size(88, 20);
this.archivoToolStripMenuItem.Size = new System.Drawing.Size(92, 20);
this.archivoToolStripMenuItem.Text = "Base de Datos";
//
// menuCargar
//
this.menuCargar.Name = "menuCargar";
this.menuCargar.Size = new System.Drawing.Size(152, 22);
this.menuCargar.Size = new System.Drawing.Size(116, 22);
this.menuCargar.Text = "Cargar";
this.menuCargar.Click += new System.EventHandler(this.menuCargar_Click);
//
// menuGuardar
//
this.menuGuardar.Name = "menuGuardar";
this.menuGuardar.Size = new System.Drawing.Size(152, 22);
this.menuGuardar.Size = new System.Drawing.Size(116, 22);
this.menuGuardar.Text = "Guardar";
this.menuGuardar.Click += new System.EventHandler(this.menuGuardar_Click);
//
// menuConfiguracion
//
this.menuConfiguracion.Name = "menuConfiguracion";
this.menuConfiguracion.Size = new System.Drawing.Size(85, 20);
this.menuConfiguracion.Size = new System.Drawing.Size(95, 20);
this.menuConfiguracion.Text = "Configuracion";
this.menuConfiguracion.Click += new System.EventHandler(this.menuConfiguracion_Click);
//
// btnGenerar
//
this.btnGenerar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnGenerar.Location = new System.Drawing.Point(386, 485);
this.btnGenerar.Location = new System.Drawing.Point(401, 485);
this.btnGenerar.Name = "btnGenerar";
this.btnGenerar.Size = new System.Drawing.Size(75, 23);
this.btnGenerar.TabIndex = 10;
@@ -235,7 +237,7 @@
this.lblTituloTabla.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.lblTituloTabla.Location = new System.Drawing.Point(3, 0);
this.lblTituloTabla.Name = "lblTituloTabla";
this.lblTituloTabla.Size = new System.Drawing.Size(458, 37);
this.lblTituloTabla.Size = new System.Drawing.Size(473, 37);
this.lblTituloTabla.TabIndex = 12;
this.lblTituloTabla.Text = "lblTituloTabla";
this.lblTituloTabla.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -249,7 +251,7 @@
this.lblTituloDB.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.lblTituloDB.Location = new System.Drawing.Point(3, 0);
this.lblTituloDB.Name = "lblTituloDB";
this.lblTituloDB.Size = new System.Drawing.Size(332, 37);
this.lblTituloDB.Size = new System.Drawing.Size(317, 37);
this.lblTituloDB.TabIndex = 13;
this.lblTituloDB.Text = "lblTituloDB";
this.lblTituloDB.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -257,7 +259,7 @@
// btnDocGen
//
this.btnDocGen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnDocGen.Location = new System.Drawing.Point(305, 485);
this.btnDocGen.Location = new System.Drawing.Point(320, 485);
this.btnDocGen.Name = "btnDocGen";
this.btnDocGen.Size = new System.Drawing.Size(75, 23);
this.btnDocGen.TabIndex = 14;
@@ -292,6 +294,7 @@
this.splitContainer1.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.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(1, 32);
this.splitContainer1.Name = "splitContainer1";
//
@@ -312,10 +315,10 @@
this.splitContainer1.Panel2.Controls.Add(this.btnProcs);
this.splitContainer1.Panel2.Controls.Add(this.btnVerDatos);
this.splitContainer1.Size = new System.Drawing.Size(806, 511);
this.splitContainer1.SplitterDistance = 338;
this.splitContainer1.SplitterDistance = 323;
this.splitContainer1.TabIndex = 17;
//
// frmBaseDatos
// FrmBaseDatos
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -325,7 +328,7 @@
this.Controls.Add(this.lblConString);
this.Controls.Add(this.txtConString);
this.MainMenuStrip = this.menuBaseDatos;
this.Name = "frmBaseDatos";
this.Name = "FrmBaseDatos";
this.Text = "Base de Datos";
this.Load += new System.EventHandler(this.frmBaseDatos_Load);
this.menuBaseDatos.ResumeLayout(false);
@@ -344,11 +347,11 @@
private System.Windows.Forms.TextBox txtConString;
private System.Windows.Forms.Label lblConString;
private System.Windows.Forms.Button btnCopiarConString;
private System.Windows.Forms.ListView lsvTablas;
private ServerExplorer.Controls.CustomListView lsvTablas;
private System.Windows.Forms.ColumnHeader colNombreTabla;
private System.Windows.Forms.ColumnHeader colEsquema;
private System.Windows.Forms.ColumnHeader colTipo;
private System.Windows.Forms.ListView lsvColumnas;
private ServerExplorer.Controls.CustomListView lsvColumnas;
private System.Windows.Forms.ColumnHeader colNombreColumna;
private System.Windows.Forms.ColumnHeader colTipoDatos;
private System.Windows.Forms.ColumnHeader colTamanho;

View File

@@ -52,9 +52,9 @@
//
// txtCommand
//
this.txtCommand.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.txtCommand.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.txtCommand.Font = new System.Drawing.Font("Lucida Console", 8.25F);
this.txtCommand.Location = new System.Drawing.Point(3, 3);
this.txtCommand.Multiline = true;
@@ -65,9 +65,9 @@
//
// dgvDatos
//
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(3, 3);
this.dgvDatos.Name = "dgvDatos";
@@ -76,9 +76,10 @@
//
// splitContainer1
//
this.splitContainer1.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.splitContainer1.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.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(12, 12);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
@@ -107,13 +108,13 @@
this.btnGenInserts.UseVisualStyleBackColor = true;
this.btnGenInserts.Click += new System.EventHandler(this.btnGenInserts_Click);
//
// frmExec
// FrmExec
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(634, 464);
this.Controls.Add(this.splitContainer1);
this.Name = "frmExec";
this.Name = "FrmExec";
this.Text = "frmExec";
this.Load += new System.EventHandler(this.frmExec_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvDatos)).EndInit();

View File

@@ -28,10 +28,10 @@
/// </summary>
private void InitializeComponent()
{
this.lsvProcs = new System.Windows.Forms.ListView();
this.colNombre = new System.Windows.Forms.ColumnHeader();
this.colFecha = new System.Windows.Forms.ColumnHeader();
this.colTipo = new System.Windows.Forms.ColumnHeader();
this.lsvProcs = new ServerExplorer.Controls.CustomListView();
this.colNombre = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colFecha = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colTipo = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.txtProc = new System.Windows.Forms.TextBox();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer1.Panel1.SuspendLayout();
@@ -41,6 +41,8 @@
//
// lsvProcs
//
this.lsvProcs.Activation = System.Windows.Forms.ItemActivation.OneClick;
this.lsvProcs.AllowSorting = true;
this.lsvProcs.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)));
@@ -53,7 +55,7 @@
this.lsvProcs.GridLines = true;
this.lsvProcs.Location = new System.Drawing.Point(0, 0);
this.lsvProcs.Name = "lsvProcs";
this.lsvProcs.Size = new System.Drawing.Size(262, 369);
this.lsvProcs.Size = new System.Drawing.Size(261, 369);
this.lsvProcs.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.lsvProcs.TabIndex = 0;
this.lsvProcs.UseCompatibleStateImageBehavior = false;
@@ -85,7 +87,7 @@
this.txtProc.Multiline = true;
this.txtProc.Name = "txtProc";
this.txtProc.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.txtProc.Size = new System.Drawing.Size(308, 366);
this.txtProc.Size = new System.Drawing.Size(309, 366);
this.txtProc.TabIndex = 1;
//
// splitContainer1
@@ -93,29 +95,28 @@
this.splitContainer1.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.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(12, 12);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.lsvProcs);
this.splitContainer1.Panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.splitContainer1_Panel1_Paint);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.txtProc);
this.splitContainer1.Size = new System.Drawing.Size(583, 372);
this.splitContainer1.SplitterDistance = 265;
this.splitContainer1.SplitterDistance = 264;
this.splitContainer1.TabIndex = 2;
this.splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitContainer1_SplitterMoved);
//
// frmProcedimientos
// FrmProcedimientos
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(607, 396);
this.Controls.Add(this.splitContainer1);
this.Name = "frmProcedimientos";
this.Name = "FrmProcedimientos";
this.Text = "frmProcedimientos";
this.Load += new System.EventHandler(this.frmProcedimientos_Load);
this.splitContainer1.Panel1.ResumeLayout(false);
@@ -128,7 +129,7 @@
#endregion
private System.Windows.Forms.ListView lsvProcs;
private ServerExplorer.Controls.CustomListView lsvProcs;
private System.Windows.Forms.ColumnHeader colNombre;
private System.Windows.Forms.ColumnHeader colFecha;
private System.Windows.Forms.TextBox txtProc;

View File

@@ -8,6 +8,7 @@ using System.Text;
using System.Windows.Forms;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Collections;
namespace ServerExplorer
{
@@ -104,15 +105,5 @@ namespace ServerExplorer
}
}
private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
{
}
private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e)
{
}
}
}

View File

@@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.lsvServidores = new System.Windows.Forms.ListView();
this.lsvServidores = new ServerExplorer.Controls.CustomListView();
this.colNombreServidor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colInstancia = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colVersion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
@@ -40,7 +40,7 @@
this.txtUsuario = new System.Windows.Forms.TextBox();
this.TxtContrasenha = new System.Windows.Forms.TextBox();
this.btnListarBBDD = new System.Windows.Forms.Button();
this.lsvBBDD = new System.Windows.Forms.ListView();
this.lsvBBDD = new ServerExplorer.Controls.CustomListView();
this.colDBName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colFechaCreacion = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
@@ -51,9 +51,10 @@
//
// lsvServidores
//
this.lsvServidores.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.lsvServidores.AllowSorting = true;
this.lsvServidores.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.lsvServidores.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colNombreServidor,
this.colInstancia,
@@ -84,8 +85,8 @@
//
// btnListarServidores
//
this.btnListarServidores.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnListarServidores.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnListarServidores.Location = new System.Drawing.Point(3, 3);
this.btnListarServidores.Name = "btnListarServidores";
this.btnListarServidores.Size = new System.Drawing.Size(306, 23);
@@ -105,8 +106,8 @@
//
// txtServidor
//
this.txtServidor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtServidor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtServidor.Location = new System.Drawing.Point(70, 6);
this.txtServidor.Name = "txtServidor";
this.txtServidor.Size = new System.Drawing.Size(218, 20);
@@ -132,8 +133,8 @@
//
// txtUsuario
//
this.txtUsuario.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtUsuario.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtUsuario.Location = new System.Drawing.Point(70, 32);
this.txtUsuario.Name = "txtUsuario";
this.txtUsuario.Size = new System.Drawing.Size(218, 20);
@@ -141,8 +142,8 @@
//
// TxtContrasenha
//
this.TxtContrasenha.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TxtContrasenha.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TxtContrasenha.Location = new System.Drawing.Point(70, 58);
this.TxtContrasenha.Name = "TxtContrasenha";
this.TxtContrasenha.Size = new System.Drawing.Size(218, 20);
@@ -151,8 +152,8 @@
//
// btnListarBBDD
//
this.btnListarBBDD.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnListarBBDD.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnListarBBDD.Location = new System.Drawing.Point(6, 84);
this.btnListarBBDD.Name = "btnListarBBDD";
this.btnListarBBDD.Size = new System.Drawing.Size(282, 23);
@@ -163,9 +164,10 @@
//
// lsvBBDD
//
this.lsvBBDD.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.lsvBBDD.AllowSorting = true;
this.lsvBBDD.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.lsvBBDD.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colDBName,
this.colFechaCreacion});
@@ -190,9 +192,9 @@
//
// splitContainer1
//
this.splitContainer1.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.splitContainer1.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.splitContainer1.Location = new System.Drawing.Point(12, 12);
this.splitContainer1.Name = "splitContainer1";
//
@@ -215,13 +217,13 @@
this.splitContainer1.SplitterDistance = 312;
this.splitContainer1.TabIndex = 12;
//
// frmServidores
// FrmServidores
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(631, 445);
this.Controls.Add(this.splitContainer1);
this.Name = "frmServidores";
this.Name = "FrmServidores";
this.Text = "Servidores";
this.Load += new System.EventHandler(this.Form1_Load);
this.splitContainer1.Panel1.ResumeLayout(false);
@@ -234,7 +236,7 @@
#endregion
private System.Windows.Forms.ListView lsvServidores;
private ServerExplorer.Controls.CustomListView lsvServidores;
private System.Windows.Forms.Button btnListarServidores;
private System.Windows.Forms.ColumnHeader colNombreServidor;
private System.Windows.Forms.ColumnHeader colInstancia;
@@ -246,7 +248,7 @@
private System.Windows.Forms.TextBox txtUsuario;
private System.Windows.Forms.TextBox TxtContrasenha;
private System.Windows.Forms.Button btnListarBBDD;
private System.Windows.Forms.ListView lsvBBDD;
private ServerExplorer.Controls.CustomListView lsvBBDD;
private System.Windows.Forms.ColumnHeader colDBName;
private System.Windows.Forms.ColumnHeader colFechaCreacion;
private System.Windows.Forms.SplitContainer splitContainer1;

View File

@@ -80,8 +80,7 @@ namespace ServerExplorer
// Construir cadena de conexion
SqlConnectionStringBuilder constructor = new SqlConnectionStringBuilder();
constructor.DataSource = txtServidor.Text;
constructor.InitialCatalog = "master";
if (txtUsuario.Text.CompareTo("") == 0)
if (String.IsNullOrEmpty(txtUsuario.Text))
{
constructor.IntegratedSecurity = true;
}