Procedimientos recomendados para ajustar la escala del control DataGridView en formularios Windows FormsBest Practices for Scaling the Windows Forms DataGridView Control
El DataGridView control está diseñado para proporcionar la máxima escalabilidad.The DataGridView control is designed to provide maximum scalability. Si necesita mostrar grandes cantidades de datos, debe seguir las instrucciones descritas en este tema para evitar el consumo de grandes cantidades de memoria o la degradación de la capacidad de respuesta de la interfaz de usuario (UI).If you need to display large amounts of data, you should follow the guidelines described in this topic to avoid consuming large amounts of memory or degrading the responsiveness of the user interface (UI). En este tema se describen los siguientes problemas:This topic discusses the following issues:
Usar estilos de celda eficazmenteUsing cell styles efficiently
Uso eficaz de los menús contextualesUsing shortcut menus efficiently
Usar el cambio de tamaño automático eficazmenteUsing automatic resizing efficiently
Usar las colecciones de celdas, filas y columnas seleccionadas de forma eficazUsing the selected cells, rows, and columns collections efficiently
Usar filas compartidasUsing shared rows
Impedir que las filas se conviertan en no compartidasPreventing rows from becoming unshared
Si tiene necesidades de rendimiento especiales, puede implementar el modo virtual y proporcionar sus propias operaciones de administración de datos.If you have special performance needs, you can implement virtual mode and provide your own data management operations. Para obtener más información, vea modos de presentación de datos en el control DataGridView Windows Forms.For more information, see Data Display Modes in the Windows Forms DataGridView Control.
Usar estilos de celda eficazmenteUsing Cell Styles Efficiently
Cada celda, fila y columna puede tener su propia información de estilo.Each cell, row, and column can have its own style information. La información de estilo se almacena en DataGridViewCellStyle objetos.Style information is stored in DataGridViewCellStyle objects. Crear objetos de estilo de celda para muchos DataGridView elementos individuales puede ser ineficaz, especialmente cuando se trabaja con grandes cantidades de datos.Creating cell style objects for many individual DataGridView elements can be inefficient, especially when working with large amounts of data. Para evitar un impacto en el rendimiento, utilice las siguientes directrices:To avoid a performance impact, use the following guidelines:
Evite establecer propiedades de estilo de celda DataGridViewCell para DataGridViewRow objetos individuales.Avoid setting cell style properties for individual DataGridViewCell or DataGridViewRow objects. Esto incluye el objeto de fila especificado por la RowTemplate propiedad.This includes the row object specified by the RowTemplate property. Cada fila nueva clonada de la plantilla de fila recibirá su propia copia del objeto de estilo de celda de la plantilla.Each new row that is cloned from the row template will receive its own copy of the template's cell style object. Para obtener la máxima escalabilidad, establezca las propiedades de estilo de celda en el DataGridView nivel.For maximum scalability, set cell style properties at the DataGridView level. Por ejemplo, establezca la DataGridView.DefaultCellStyle propiedad en lugar de la DataGridViewCell.Style propiedad.For example, set the DataGridView.DefaultCellStyle property rather than the DataGridViewCell.Style property.
Si algunas celdas requieren un formato que no sea el predeterminado, use la misma DataGridViewCellStyle instancia en todos los grupos de celdas, filas o columnas.If some cells require formatting other than default formatting, use the same DataGridViewCellStyle instance across groups of cells, rows, or columns. Evite establecer directamente propiedades de tipo DataGridViewCellStyle en celdas, filas y columnas individuales.Avoid directly setting properties of type DataGridViewCellStyle on individual cells, rows, and columns. Para obtener un ejemplo de uso compartido de estilos de celda, vea Cómo: establecer estilos de celda predeterminados para el control DataGridView Windows Forms.For an example of cell style sharing, see How to: Set Default Cell Styles for the Windows Forms DataGridView Control. También puede evitar una reducción del rendimiento al establecer los estilos de celda individualmente mediante el control del CellFormatting controlador de eventos.You can also avoid a performance penalty when setting cell styles individually by handling the CellFormatting event handler. Para obtener un ejemplo, vea Cómo: personalizar el formato de datos en el control DataGridView Windows Forms.For an example, see How to: Customize Data Formatting in the Windows Forms DataGridView Control.
Al determinar el estilo de una celda, utilice la DataGridViewCell.InheritedStyle propiedad en lugar de la DataGridViewCell.Style propiedad.When determining a cell's style, use the DataGridViewCell.InheritedStyle property rather than the DataGridViewCell.Style property. Al tener acceso a la Style propiedad, se crea una nueva instancia de la DataGridViewCellStyle clase si aún no se ha utilizado la propiedad.Accessing the Style property creates a new instance of the DataGridViewCellStyle class if the property has not already been used. Además, este objeto podría no contener la información de estilo completa de la celda si algunos estilos se heredan de la fila, la columna o el control.Additionally, this object might not contain the complete style information for the cell if some styles are inherited from the row, column, or control. Para obtener más información sobre la herencia del estilo de celda, vea estilos de celda en el control DataGridView de Windows Forms.For more information about cell style inheritance, see Cell Styles in the Windows Forms DataGridView Control.
Uso eficaz de los menús contextualesUsing Shortcut Menus Efficiently
Cada celda, fila y columna puede tener su propio menú contextual.Each cell, row, and column can have its own shortcut menu. Los menús contextuales del DataGridView control se representan mediante ContextMenuStrip controles.Shortcut menus in the DataGridView control are represented by ContextMenuStrip controls. Al igual que con los objetos de estilo de celda, la creación de menús contextuales para muchos DataGridView elementos individuales afectará negativamente al rendimiento.Just as with cell style objects, creating shortcut menus for many individual DataGridView elements will negatively impact performance. Para evitar esta penalización, utilice las siguientes directrices:To avoid this penalty, use the following guidelines:
Evite crear menús contextuales para celdas y filas individuales.Avoid creating shortcut menus for individual cells and rows. Esto incluye la plantilla de fila, que se clona junto con el menú contextual cuando se agregan nuevas filas al control.This includes the row template, which is cloned along with its shortcut menu when new rows are added to the control. Para obtener la máxima escalabilidad, use solo la ContextMenuStrip propiedad del control para especificar un solo menú contextual para todo el control.For maximum scalability, use only the control's ContextMenuStrip property to specify a single shortcut menu for the entire control.
Si necesita varios menús contextuales para varias filas o celdas, controle los CellContextMenuStripNeeded RowContextMenuStripNeeded eventos o.If you require multiple shortcut menus for multiple rows or cells, handle the CellContextMenuStripNeeded or RowContextMenuStripNeeded events. Estos eventos le permiten administrar los objetos de menú contextual usted mismo, lo que le permite ajustar el rendimiento.These events let you manage the shortcut menu objects yourself, allowing you to tune performance.
Usar el cambio de tamaño automático eficazmenteUsing Automatic Resizing Efficiently
Se puede cambiar automáticamente el tamaño de las filas, columnas y encabezados según los cambios de contenido de celda para que todo el contenido de las celdas se muestre sin recortes.Rows, columns, and headers can be automatically resized as cell content changes so that the entire contents of cells are displayed without clipping. Cambiar los modos de cambio de tamaño también puede cambiar el tamaño de filas, columnas y encabezados.Changing sizing modes can also resize rows, columns, and headers. Para determinar el tamaño correcto, el DataGridView control debe examinar el valor de cada celda que debe adaptarse.To determine the correct size, the DataGridView control must examine the value of each cell that it must accommodate. Cuando se trabaja con grandes conjuntos de datos, este análisis puede afectar negativamente al rendimiento del control cuando se produce un cambio de tamaño automático.When working with large data sets, this analysis can negatively impact the performance of the control when automatic resizing occurs. Para evitar penalizaciones de rendimiento, utilice las siguientes directrices:To avoid performance penalties, use the following guidelines:
Evite usar el ajuste de tamaño automático en un DataGridView control con un conjunto grande de filas.Avoid using automatic sizing on a DataGridView control with a large set of rows. Si utiliza el ajuste automático de tamaño, solo tiene que cambiar el tamaño en función de las filas mostradas.If you do use automatic sizing, only resize based on the displayed rows. Use solo las filas mostradas en modo virtual.Use only the displayed rows in virtual mode as well.
Para las filas y columnas, use
DisplayedCells
elDisplayedCellsExceptHeaders
campo o de DataGridViewAutoSizeRowsMode las DataGridViewAutoSizeColumnsMode DataGridViewAutoSizeColumnMode enumeraciones, y.For rows and columns, use theDisplayedCells
orDisplayedCellsExceptHeaders
field of the DataGridViewAutoSizeRowsMode, DataGridViewAutoSizeColumnsMode, and DataGridViewAutoSizeColumnMode enumerations.En el caso de los encabezados de fila, utilice el AutoSizeToDisplayedHeaders AutoSizeToFirstHeader campo o de la DataGridViewRowHeadersWidthSizeMode enumeración.For row headers, use the AutoSizeToDisplayedHeaders or AutoSizeToFirstHeader field of the DataGridViewRowHeadersWidthSizeMode enumeration.
Para obtener la máxima escalabilidad, desactive el ajuste de tamaño automático y use el cambio de tamaño mediante programación.For maximum scalability, turn off automatic sizing and use programmatic resizing.
Para obtener más información, consulte Opciones de ajuste de tamaño en el control DataGridView Windows Forms.For more information, see Sizing Options in the Windows Forms DataGridView Control.
Usar las colecciones de celdas, filas y columnas seleccionadas de forma eficazUsing the Selected Cells, Rows, and Columns Collections Efficiently
La SelectedCells colección no funciona de forma eficaz con selecciones grandes.The SelectedCells collection does not perform efficiently with large selections. Las SelectedRows SelectedColumns colecciones y también pueden ser ineficaces, aunque a un menor grado, ya que hay muchas menos filas que las celdas de un DataGridView control típico y muchas menos columnas que filas.The SelectedRows and SelectedColumns collections can also be inefficient, although to a lesser degree because there are many fewer rows than cells in a typical DataGridView control, and many fewer columns than rows. Para evitar las penalizaciones de rendimiento al trabajar con estas colecciones, use las siguientes directrices:To avoid performance penalties when working with these collections, use the following guidelines:
Para determinar si todas las celdas de DataGridView se han seleccionado antes de tener acceso al contenido de la SelectedCells colección, compruebe el valor devuelto del AreAllCellsSelected método.To determine whether all the cells in the DataGridView have been selected before you access the contents of the SelectedCells collection, check the return value of the AreAllCellsSelected method. Sin embargo, tenga en cuenta que este método puede hacer que las filas dejen de estar compartidas.Note, however, that this method can cause rows to become unshared. Para obtener más información, vea la siguiente sección.For more information, see the next section.
Evite el uso Count de la propiedad de System.Windows.Forms.DataGridViewSelectedCellCollection para determinar el número de celdas seleccionadas.Avoid using the Count property of the System.Windows.Forms.DataGridViewSelectedCellCollection to determine the number of selected cells. En su lugar, use el DataGridView.GetCellCount método y pase el DataGridViewElementStates.Selected valor.Instead, use the DataGridView.GetCellCount method and pass in the DataGridViewElementStates.Selected value. Del mismo modo, use los DataGridViewRowCollection.GetRowCount DataGridViewColumnCollection.GetColumnCount métodos y para determinar el número de elementos seleccionados, en lugar de tener acceso a las colecciones de filas y columnas seleccionadas.Similarly, use the DataGridViewRowCollection.GetRowCount and DataGridViewColumnCollection.GetColumnCount methods to determine the number of selected elements, rather than accessing the selected row and column collections.
Evite los modos de selección basados en celdas.Avoid cell-based selection modes. En su lugar, establezca la DataGridView.SelectionMode propiedad en DataGridViewSelectionMode.FullRowSelect o DataGridViewSelectionMode.FullColumnSelect .Instead, set the DataGridView.SelectionMode property to DataGridViewSelectionMode.FullRowSelect or DataGridViewSelectionMode.FullColumnSelect.
Usar filas compartidasUsing Shared Rows
El uso eficaz de la memoria se logra en el DataGridView control a través de filas compartidas.Efficient memory use is achieved in the DataGridView control through shared rows. Las filas compartirán tanta información como sea posible en la apariencia y el comportamiento compartiendo las instancias de la DataGridViewRow clase.Rows will share as much information about their appearance and behavior as possible by sharing instances of the DataGridViewRow class.
Aunque compartir instancias de fila ahorra memoria, las filas pueden dejar de estar compartidas fácilmente.While sharing row instances saves memory, rows can easily become unshared. Por ejemplo, cada vez que un usuario interactúa directamente con una celda, su fila deja de estar compartida.For example, whenever a user interacts directly with a cell, its row becomes unshared. Dado que esto no se puede evitar, las instrucciones de este tema solo son útiles cuando se trabaja con grandes cantidades de datos y solo cuando los usuarios interactúan con una parte relativamente pequeña de los datos cada vez que se ejecuta el programa.Because this cannot be avoided, the guidelines in this topic are useful only when working with very large amounts of data and only when users will interact with a relatively small part of the data each time your program is run.
No se puede compartir una fila en un control sin enlazar DataGridView si cualquiera de sus celdas contiene valores.A row cannot be shared in an unbound DataGridView control if any of its cells contain values. Cuando el DataGridView control está enlazado a un origen de datos externo o al implementar el modo virtual y proporcionar su propio origen de datos, los valores de celda se almacenan fuera del control en lugar de los objetos de celda, lo que permite compartir las filas.When the DataGridView control is bound to an external data source or when you implement virtual mode and provide your own data source, the cell values are stored outside the control rather than in cell objects, allowing the rows to be shared.
Un objeto Row solo puede compartirse Si el estado de todas sus celdas se puede determinar a partir del estado de la fila y de los Estados de las columnas que contienen las celdas.A row object can only be shared if the state of all its cells can be determined from the state of the row and the states of the columns containing the cells. Si cambia el estado de una celda para que ya no se pueda deducir del estado de su fila y columna, no se puede compartir la fila.If you change the state of a cell so that it can no longer be deduced from the state of its row and column, the row cannot be shared.
Por ejemplo, una fila no se puede compartir en ninguna de las situaciones siguientes:For example, a row cannot be shared in any of the following situations:
La fila contiene una sola celda seleccionada que no está en la columna seleccionada.The row contains a single selected cell that is not in a selected column.
La fila contiene una celda con sus ToolTipText ContextMenuStrip propiedades o establecidas.The row contains a cell with its ToolTipText or ContextMenuStrip properties set.
La fila contiene un DataGridViewComboBoxCell con su Items propiedad establecida.The row contains a DataGridViewComboBoxCell with its Items property set.
En modo enlazado o en modo virtual, puede proporcionar información sobre herramientas y menús contextuales para celdas individuales mediante el control de los CellToolTipTextNeeded CellContextMenuStripNeeded eventos y.In bound mode or virtual mode, you can provide ToolTips and shortcut menus for individual cells by handling the CellToolTipTextNeeded and CellContextMenuStripNeeded events.
El DataGridView control intentará usar automáticamente las filas compartidas cada vez que se agreguen filas a DataGridViewRowCollection .The DataGridView control will automatically attempt to use shared rows whenever rows are added to the DataGridViewRowCollection. Utilice las siguientes directrices para asegurarse de que las filas se comparten:Use the following guidelines to ensure that rows are shared:
Evite llamar a la
Add(Object[])
sobrecarga del Add método y a laInsert(Object[])
sobrecarga del Insert método de la DataGridView.Rows colección.Avoid calling theAdd(Object[])
overload of the Add method and theInsert(Object[])
overload of the Insert method of the DataGridView.Rows collection. Estas sobrecargas crean automáticamente filas no compartidas.These overloads automatically create unshared rows.Asegúrese de que la fila especificada en la DataGridView.RowTemplate propiedad se puede compartir en los casos siguientes:Be sure that the row specified in the DataGridView.RowTemplate property can be shared in the following cases:
Al llamar a
Add()
lasAdd(Int32)
sobrecargas o del Add método o laInsert(Int32,Int32)
sobrecarga del Insert método de la DataGridView.Rows colección.When calling theAdd()
orAdd(Int32)
overloads of the Add method or theInsert(Int32,Int32)
overload of the Insert method of the DataGridView.Rows collection.Al aumentar el valor de la DataGridView.RowCount propiedad.When increasing the value of the DataGridView.RowCount property.
Al establecer la DataGridView.DataSource propiedad.When setting the DataGridView.DataSource property.
Asegúrese de que se puede compartir la fila indicada por el
indexSource
parámetro al llamar a AddCopy los AddCopies métodos,, InsertCopy y InsertCopies de la DataGridView.Rows colección.Be sure that the row indicated by theindexSource
parameter can be shared when calling the AddCopy, AddCopies, InsertCopy, and InsertCopies methods of the DataGridView.Rows collection.Asegúrese de que se pueden compartir las filas especificadas al llamar a la
Add(DataGridViewRow)
sobrecarga del Add método, el AddRange método, laInsert(Int32,DataGridViewRow)
sobrecarga del Insert método y el InsertRange método de la DataGridView.Rows colección.Be sure that the specified row or rows can be shared when calling theAdd(DataGridViewRow)
overload of the Add method, the AddRange method, theInsert(Int32,DataGridViewRow)
overload of the Insert method, and the InsertRange method of the DataGridView.Rows collection.
Para determinar si una fila está compartida, utilice el DataGridViewRowCollection.SharedRow método para recuperar el objeto de fila y, a continuación, Compruebe la propiedad del objeto Index .To determine whether a row is shared, use the DataGridViewRowCollection.SharedRow method to retrieve the row object, and then check the object's Index property. Las filas compartidas siempre tienen un Index valor de propiedad de – 1.Shared rows always have an Index property value of –1.
Impedir que las filas se conviertan en no compartidasPreventing Rows from Becoming Unshared
Las filas compartidas pueden dejar de estar compartidas como resultado del código o de la acción del usuario.Shared rows can become unshared as a result of code or user action. Para evitar un impacto en el rendimiento, debe evitar que las filas dejen de estar compartidas.To avoid a performance impact, you should avoid causing rows to become unshared. Durante el desarrollo de la aplicación, puede controlar el RowUnshared evento para determinar si las filas dejan de estar compartidas.During application development, you can handle the RowUnshared event to determine when rows become unshared. Esto resulta útil al depurar problemas de uso compartido de filas.This is useful when debugging row-sharing problems.
Para evitar que las filas deje de estar compartidas, utilice las siguientes directrices:To prevent rows from becoming unshared, use the following guidelines:
Evite indizar la Rows colección o recorrer en iteración con un
foreach
bucle.Avoid indexing the Rows collection or iterating through it with aforeach
loop. Normalmente, no necesitará tener acceso a las filas directamente.You will not typically need to access rows directly. DataGridView los métodos que operan en filas toman argumentos de índice de fila en lugar de instancias de fila.DataGridView methods that operate on rows take row index arguments rather than row instances. Además, los controladores de los eventos relacionados con filas reciben objetos de argumento de evento con propiedades de fila que se pueden usar para manipular las filas sin provocar que dejen de estar compartidas.Additionally, handlers for row-related events receive event argument objects with row properties that you can use to manipulate rows without causing them to become unshared.Si necesita tener acceso a un objeto de fila, use el DataGridViewRowCollection.SharedRow método y pase el índice real de la fila.If you need to access a row object, use the DataGridViewRowCollection.SharedRow method and pass in the row's actual index. Tenga en cuenta, sin embargo, que la modificación de un objeto de fila compartido recuperado a través de este método modificará todas las filas que comparten este objeto.Note, however, that modifying a shared row object retrieved through this method will modify all the rows that share this object. Sin embargo, la fila de los nuevos registros no se comparte con otras filas, por lo que no se verá afectada cuando modifique cualquier otra fila.The row for new records is not shared with other rows, however, so it will not be affected when you modify any other row. Tenga en cuenta también que las distintas filas representadas por una fila compartida pueden tener menús contextuales diferentes.Note also that different rows represented by a shared row may have different shortcut menus. Para recuperar el menú contextual correcto de una instancia de fila compartida, use el GetContextMenuStrip método y pase el índice real de la fila.To retrieve the correct shortcut menu from a shared row instance, use the GetContextMenuStrip method and pass in the row's actual index. Si tiene acceso a la propiedad de la fila compartida ContextMenuStrip , utilizará el índice de fila compartida de-1 y no recuperará el menú contextual correcto.If you access the shared row's ContextMenuStrip property instead, it will use the shared row index of -1 and will not retrieve the correct shortcut menu.
Evite indizar la DataGridViewRow.Cells colección.Avoid indexing the DataGridViewRow.Cells collection. El acceso a una celda directamente hará que su fila primaria deje de estar compartida, creando una instancia de un nuevo DataGridViewRow .Accessing a cell directly will cause its parent row to become unshared, instantiating a new DataGridViewRow. Los controladores de los eventos relacionados con las celdas reciben objetos de argumento de evento con propiedades de celda que se pueden usar para manipular celdas sin hacer que las filas dejen de estar compartidas.Handlers for cell-related events receive event argument objects with cell properties that you can use to manipulate cells without causing rows to become unshared. También puede utilizar la CurrentCellAddress propiedad para recuperar los índices de fila y columna de la celda actual sin tener acceso directamente a la celda.You can also use the CurrentCellAddress property to retrieve the row and column indexes of the current cell without accessing the cell directly.
Evite los modos de selección basados en celdas.Avoid cell-based selection modes. Estos modos hacen que las filas dejen de estar compartidas.These modes cause rows to become unshared. En su lugar, establezca la DataGridView.SelectionMode propiedad en DataGridViewSelectionMode.FullRowSelect o DataGridViewSelectionMode.FullColumnSelect .Instead, set the DataGridView.SelectionMode property to DataGridViewSelectionMode.FullRowSelect or DataGridViewSelectionMode.FullColumnSelect.
No controle los DataGridViewRowCollection.CollectionChanged DataGridView.RowStateChanged eventos o.Do not handle the DataGridViewRowCollection.CollectionChanged or DataGridView.RowStateChanged events. Estos eventos hacen que las filas dejen de estar compartidas.These events cause rows to become unshared. Además, no llame a los DataGridViewRowCollection.OnCollectionChanged DataGridView.OnRowStateChanged métodos o, que provocan estos eventos.Also, do not call the DataGridViewRowCollection.OnCollectionChanged or DataGridView.OnRowStateChanged methods, which raise these events.
No tener acceso a la DataGridView.SelectedCells colección cuando el valor de la DataGridView.SelectionMode propiedad es FullColumnSelect , ColumnHeaderSelect , FullRowSelect o RowHeaderSelect .Do not access the DataGridView.SelectedCells collection when the DataGridView.SelectionMode property value is FullColumnSelect, ColumnHeaderSelect, FullRowSelect, or RowHeaderSelect. Esto hace que todas las filas seleccionadas dejen de estar compartidas.This causes all selected rows to become unshared.
No llame al DataGridView.AreAllCellsSelected método.Do not call the DataGridView.AreAllCellsSelected method. Este método puede hacer que las filas dejen de estar compartidas.This method can cause rows to become unshared.
No llame al DataGridView.SelectAll método cuando el valor de la DataGridView.SelectionMode propiedad sea CellSelect .Do not call the DataGridView.SelectAll method when the DataGridView.SelectionMode property value is CellSelect. Esto hace que todas las filas dejen de estar compartidas.This causes all rows to become unshared.
No establezca la ReadOnly propiedad o Selected de una celda en
false
cuando la propiedad correspondiente de su columna esté establecida entrue
.Do not set the ReadOnly or Selected property of a cell tofalse
when the corresponding property in its column is set totrue
. Esto hace que todas las filas dejen de estar compartidas.This causes all rows to become unshared.No tener acceso a la DataGridViewRowCollection.List propiedad.Do not access the DataGridViewRowCollection.List property. Esto hace que todas las filas dejen de estar compartidas.This causes all rows to become unshared.
No llame a la
Sort(IComparer)
sobrecarga del Sort método.Do not call theSort(IComparer)
overload of the Sort method. La ordenación con un comparador personalizado hace que todas las filas dejen de estar compartidas.Sorting with a custom comparer causes all rows to become unshared.
Vea tambiénSee also
- DataGridView
- Ajuste del rendimiento del control DataGridView en formularios Windows FormsPerformance Tuning in the Windows Forms DataGridView Control
- Modo virtual del control DataGridView de formularios Windows FormsVirtual Mode in the Windows Forms DataGridView Control
- Modos de presentación de datos en el control DataGridView de formularios Windows FormsData Display Modes in the Windows Forms DataGridView Control
- Estilos de celda en el control DataGridView de formularios Windows FormsCell Styles in the Windows Forms DataGridView Control
- Procedimiento para establecer estilos de celda predeterminados para el control DataGridView de formularios Windows FormsHow to: Set Default Cell Styles for the Windows Forms DataGridView Control
- Opciones de ajuste de tamaño en el control DataGridView de formularios Windows FormsSizing Options in the Windows Forms DataGridView Control