[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

User control con caracteristicas del DataGridView

VictorLeo

8/22/2007 3:11:00 PM

Hola.

Me encargaron hacer un user control
Es un user control al cual por defecto tiene los botones Adicionar,
Modificar, Eliminar, Consultar, Buscar, Imprimir, Salir.
Este user control tiene una propiedad donde se pude cambiar los
botonos por Aceptar , Cancelar

Tambien puedes agregarle o quitar botones (aqui uso un smart tag que
me levanta una pantalla winforms donde agrego o quito los botones)
todo esto en tiempo de diseño el problema viene cuando ejecuto el
winforms donde he agregado mi user control.

Por ejemplo mi user control tiene los botones standar por default
Adicionar, Modificar, Eliminar, Consultar, Buscar, Imprimir, Salir. y
elimine y cambie algunos quedando asi Cargar, Anular, Marcar cuando
ejecuto el winforms me muestra los botones standar Adicionar,
Modificar, Eliminar, Consultar, Buscar, Imprimir, Salir. y cuando
regresa a modo edicion me sigue mostrando Adicionar, Modificar,
Eliminar, Consultar, Buscar, Imprimir, Salir. todo lo que hize se
perdio.

Lo que se me ocurrio es ver como lo hace el gridview ya que alli se
hace mas o menos lo que intento hacer puedes agregar columnas mediante
smart tag e incluso levantas una ventana donde personalizas la columna
y lo que pones en modo diseño se mantentiene.
Me fije en el codigo del diseñador y me llamo la atencion estas lineas
CType(Me.DataGridView1,
System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataGridView1,
System.ComponentModel.ISupportInitialize).EndInit()
Esto lo pone al agregar un DataGridView

<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.DataGridView1 = New System.Windows.Forms.DataGridView
CType(Me.DataGridView1,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'DataGridView1
'
Me.DataGridView1.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.DataGridView1.Location = New System.Drawing.Point(12, 37)
Me.DataGridView1.Name = "DataGridView1"
Me.DataGridView1.Size = New System.Drawing.Size(240, 150)
Me.DataGridView1.TabIndex = 0
'
'Form4
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.DataGridView1)
Me.Name = "Form4"
Me.Text = "Form4"
CType(Me.DataGridView1,
System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub
Friend WithEvents DataGridView1 As
System.Windows.Forms.DataGridView

Y cuando agregar columnas
Private Sub InitializeComponent()
Me.DataGridView1 = New System.Windows.Forms.DataGridView
Me.Column1 = New
System.Windows.Forms.DataGridViewTextBoxColumn
Me.Column2 = New
System.Windows.Forms.DataGridViewTextBoxColumn
CType(Me.DataGridView1,
System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'DataGridView1
'
Me.DataGridView1.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.DataGridView1.Columns.AddRange(New
System.Windows.Forms.DataGridViewColumn() {Me.Column1, Me.Column2})
Me.DataGridView1.Location = New System.Drawing.Point(12, 37)
Me.DataGridView1.Name = "DataGridView1"
Me.DataGridView1.Size = New System.Drawing.Size(240, 150)
Me.DataGridView1.TabIndex = 0
'
'Column1
'
Me.Column1.HeaderText = "Column1"
Me.Column1.Name = "Column1"
'
'Column2
'
Me.Column2.HeaderText = "Column2"
Me.Column2.Name = "Column2"
'
'Form4
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.DataGridView1)
Me.Name = "Form4"
Me.Text = "Form4"
CType(Me.DataGridView1,
System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub
Friend WithEvents DataGridView1 As
System.Windows.Forms.DataGridView
Friend WithEvents Column1 As
System.Windows.Forms.DataGridViewTextBoxColumn
Friend WithEvents Column2 As
System.Windows.Forms.DataGridViewTextBoxColumn

Al parecer el DataGridView es un contenedor y las columnas son
controles que se agregan al DataGridView tambien me percate que el
archivo de recurso pone esto
Column1.UserAddedColumn Sytem.Boolean True
Column2.UserAddedColumn Sytem.Boolean True

Bueno se que tengo que usar la misma logica que tiene el DataGridView
pero no sabria por donde empezar ya que intente usar
System.ComponentModel.ISupportInitialize pero me sale error haber si
alguien tiene un ejemplo o pista de por donde empezar la solucion de
esto . De antemano gracias

6 Answers

Hope

6/30/2010 11:55:00 AM

0

On Jun 29, 1:00 pm, Aine <mladya...@yahoo.com> wrote:
> On Jun 28, 11:32 pm, "Lady Azure, Baroness of the North Pole"
>
> <laddie'o'lugh@gall's.org> wrote:
> > Aine was right.<
>
> Actually, I was left this time.
>
Interesting choice of words.

Aine

6/30/2010 5:48:00 PM

0

On Jun 30, 4:55 am, Hope <holleratwal...@gmail.com> wrote:
> On Jun 29, 1:00 pm, Aine <mladya...@yahoo.com> wrote:> On Jun 28, 11:32 pm, "Lady Azure, Baroness of the North Pole"
>
> > <laddie'o'lugh@gall's.org> wrote:
> > > Aine was right.<
>
> > Actually, I was left this time.
>
> Interesting choice of words.

Thanks.

Hope

6/30/2010 7:42:00 PM

0

On Jun 30, 12:48 pm, Aine <mladya...@yahoo.com> wrote:
> On Jun 30, 4:55 am, Hope <holleratwal...@gmail.com> wrote:
>
> > On Jun 29, 1:00 pm, Aine <mladya...@yahoo.com> wrote:> On Jun 28, 11:32 pm, "Lady Azure, Baroness of the North Pole"
>
> > > <laddie'o'lugh@gall's.org> wrote:
> > > > Aine was right.<
>
> > > Actually, I was left this time.
>
> > Interesting choice of words.
>
> Thanks.

Welcome.

Aine

6/30/2010 7:59:00 PM

0

On Jun 30, 12:41 pm, Hope <holleratwal...@gmail.com> wrote:
> On Jun 30, 12:48 pm, Aine <mladya...@yahoo.com> wrote:
>
> > On Jun 30, 4:55 am, Hope <holleratwal...@gmail.com> wrote:
>
> > > On Jun 29, 1:00 pm, Aine <mladya...@yahoo.com> wrote:> On Jun 28, 11:32 pm, "Lady Azure, Baroness of the North Pole"
>
> > > > <laddie'o'lugh@gall's.org> wrote:
> > > > > Aine was right.<
>
> > > > Actually, I was left this time.
>
> > > Interesting choice of words.
>
> > Thanks.
>
> Welcome.

Glad posting does not require postage. Really would not be worth the
manner posts.

Hope

6/30/2010 9:47:00 PM

0

On Jun 30, 2:59 pm, Aine <mladya...@yahoo.com> wrote:
> On Jun 30, 12:41 pm, Hope <holleratwal...@gmail.com> wrote:
>
>
>
>
>
> > On Jun 30, 12:48 pm, Aine <mladya...@yahoo.com> wrote:
>
> > > On Jun 30, 4:55 am, Hope <holleratwal...@gmail.com> wrote:
>
> > > > On Jun 29, 1:00 pm, Aine <mladya...@yahoo.com> wrote:> On Jun 28, 11:32 pm, "Lady Azure, Baroness of the North Pole"
>
> > > > > <laddie'o'lugh@gall's.org> wrote:
> > > > > > Aine was right.<
>
> > > > > Actually, I was left this time.
>
> > > > Interesting choice of words.
>
> > > Thanks.
>
> > Welcome.
>
> Glad posting does not require postage. Really would not be worth the
> manner posts.

Unless the stamps belonged to the company and you got to be polite on
someone else's dime. Er, half dollar. Otherwise, yeah, please and
thank you would probably be done. Sarcasm and belligerence on the
other hand? Totally worth even Fed-X prices! ;-)

Lady Azure, Baroness of the North Pole

7/1/2010 4:18:00 AM

0



Aine wrote:

> On Jun 30, 12:41 pm, Hope <holleratwal...@gmail.com> wrote:
> > On Jun 30, 12:48 pm, Aine <mladya...@yahoo.com> wrote:
> >
> > > On Jun 30, 4:55 am, Hope <holleratwal...@gmail.com> wrote:
> >
> > > > On Jun 29, 1:00 pm, Aine <mladya...@yahoo.com> wrote:> On Jun 28, 11:32 pm, "Lady Azure, Baroness of the North Pole"
> >
> > > > > <laddie'o'lugh@gall's.org> wrote:
> > > > > > Aine was right.<
> >
> > > > > Actually, I was left this time.
> >
> > > > Interesting choice of words.
> >
> > > Thanks.
> >
> > Welcome.
>
> Glad posting does not require postage. Really would not be worth the
> manner posts.

Not in today's market anyway!!!