locked
problem with a grid RRS feed

  • Question

  • Hi, I apologize you for my English. I´ll try to explain.

    I work in Visual Studio 2008 with a application for one PDA. I have the next code in a button and I want to apply a format to two columns.  I can see the grid with two columns but the format isn´t  applied. How I can to set a "width" format?

    Thanks in advance



    *********************************************
    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim cmd As IDbCommand
            Dim rtn As String = ""
            Dim res As IDataReader
            Dim err As String
          
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
            System.Windows.Forms.Cursor.Show()

            Connect(BDLite, PasswordLite)
            cmd = GetConnection().CreateCommand()
            Indice = 0
            Try
                ' Se comprueba que los criterios de búsqueda se cumplen y se recuperan o no los datos de la tabla
                cmd = CreateCommand()
                cmd.CommandText = "SELECT codigo,descripcion FROM APDA"

                res = cmd.ExecuteReader()

              
                ' Carga de cada uno de los campos
                Oda.SelectCommand = CType(cmd, OracleCommand)


                ' Se cargan los datos
                Datos = New DataSet
                Oda.Fill(Datos)
                Tabla = Datos.Tables(0)
                DataGrid1.DataSource = Tabla.DefaultView


                DataGrid1.ForeColor = Color.Blue
                DataGrid1.BackColor = Color.Bisque


                '****************************************************************************
                Dim agridestilo As New DataGridTableStyle
                agridestilo.MappingName = "APDA"

                Dim colstyle1 As New DataGridTextBoxColumn
                Dim colstyle2 As New DataGridTextBoxColumn

                colstyle1.MappingName = "CODIGO"
                colstyle1.HeaderText = "cod"
                colstyle1.Width = 50
                agridestilo.GridColumnStyles.Add(colstyle1)

                colstyle2.MappingName = "DESCRIPCION 2"
                colstyle2.HeaderText = "Descripción"
                colstyle2.Width = 250
                agridestilo.GridColumnStyles.Add(colstyle2)

                '            DataGrid1.TableStyles.Clear()
                DataGrid1.TableStyles.Add(agridestilo)

                '***************************************************************************




                Dim nfila = Tabla.Columns.Count
                MsgBox("n= " & nfila)


                res.Close()
                cmd.Dispose()
                Disconnect()


                System.Windows.Forms.Cursor.Current = Cursors.Default
                System.Windows.Forms.Cursor.Show()

            Catch ex As Exception
                err = ex.Message & ": " & cmd.CommandText
                MsgBox(err, MsgBoxStyle.Information, "Error")
                cmd.Dispose()
                Disconnect()
                System.Windows.Forms.Cursor.Current = Cursors.Default
                System.Windows.Forms.Cursor.Show()
            End Try
        End Sub
    ***************************************************
    Thursday, August 14, 2008 11:18 AM

Answers

  • Do you develop the smart device application? If you do, it is the best option to post this issue to Smart Device Development for the better answers. 
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Xingwei Hu Wednesday, August 20, 2008 8:52 AM
    Monday, August 18, 2008 8:20 AM
    Moderator

All replies

  • Do you develop the smart device application? If you do, it is the best option to post this issue to Smart Device Development for the better answers. 
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Xingwei Hu Wednesday, August 20, 2008 8:52 AM
    Monday, August 18, 2008 8:20 AM
    Moderator
  • Sorry .I´ll put my answer in Smart Device forum.

    Monday, August 18, 2008 3:32 PM