Exemplo n.º 1
0
    private void AddTableRow(Table T, DataRow myDataRow,
                             int NumeroRiga, int[] orderedcols, string PanelId)
    {
        if (T == null)
        {
            return;
        }
        if (myDataRow == null)
        {
            return;
        }

        DataTable TT = myDataRow.Table;

        //Nuova Riga
        TableRow TR1 = new TableRow();

        //TR1.Height = 24;
        T.Rows.Add(TR1);


        if ((NumeroRiga & 1) == 0)
        {
            TR1.CssClass = "odd";
        }

        TableCell  T_Chk = new TableCell();
        hwCheckBox HwC   = new hwCheckBox();

        HwC.ID = "Chk_Selector_" + PanelId + "_" + NumeroRiga;

        HwC.Tag = NumeroRiga.ToString();
        T_Chk.Controls.Add(HwC);
        TR1.Cells.Add(T_Chk);

        for (int i = 0; i < orderedcols.Length; i++)
        {
            DataColumn C = TT.Columns[orderedcols[i]];
            //Aggiungo tutte le celle.
            TableCell TC1 = new TableCell();
            TC1.Text = GetValoreFormattato(myDataRow, C.ColumnName, HelpForm.GetFormatForColumn(C));
            System.Windows.Forms.HorizontalAlignment HA = HelpForm.GetAlignForColumn(C);
            if (HA == System.Windows.Forms.HorizontalAlignment.Right)
            {
                TC1.HorizontalAlign = HorizontalAlign.Right;
            }
            else
            {
                TC1.HorizontalAlign = HorizontalAlign.Left;
            }
            TR1.Cells.Add(TC1);
        }
    }
Exemplo n.º 2
0
 string GetAlignForColumn(DataColumn C)
 {
     System.Windows.Forms.HorizontalAlignment H = HelpForm.GetAlignForColumn(C);
     if (H == System.Windows.Forms.HorizontalAlignment.Center)
     {
         return(" align='center' ");
     }
     if (H == System.Windows.Forms.HorizontalAlignment.Right)
     {
         return(" align='right' ");
     }
     return("");
 }
Exemplo n.º 3
0
        private void SetListView(ListView L, DataTable T, DataRow[] rows, bool IsCheckList)
        {
            L.BeginUpdate();
            L.Clear();
            string [] colnames = new string[T.Columns.Count];
            int       ncols    = 0;
            Graphics  GG       = Graphics.FromHwnd(L.FindForm().Handle);

            int [] sizes = new int[T.Columns.Count];
            foreach (DataColumn C in T.Columns)
            {
                if (C.Caption == "")
                {
                    continue;
                }
                colnames[ncols] = C.ColumnName;
                sizes[ncols]    = Convert.ToInt32(GG.MeasureString(C.ColumnName, L.Font).Width) + 5;
                ncols++;
            }

            string [] items = new string[ncols];
            //Fills ListBox
            foreach (DataRow R in rows)
            {
                for (int i = 0; i < ncols; i++)
                {
                    string colname = colnames[i];
                    items[i] = HelpForm.StringValue(R[colname],
                                                    "",
                                                    T.Columns[colname]);
                    int ss = Convert.ToInt32(GG.MeasureString(items[i], L.Font).Width) + 10;
                    if (sizes[i] < ss)
                    {
                        sizes[i] = ss;
                    }
                }
                ListViewItem LVII = new ListViewItem(items[0]);
                LVII.Tag = R;
                for (int j = 1; j < ncols; j++)
                {
                    LVII.SubItems.Add(items[j]);
                }
                L.Items.Add(LVII);
                //Dato che la lista checked ha senso solo per i nuovi aggiornamenti
                if (IsCheckList)
                {
                    LVII.Checked = false;
                }
                if (R["installato"].ToString().ToLower() == "si")
                {
                    LVII.ForeColor = Color.Green;
                }
                else
                {
                    LVII.ForeColor = Color.Blue;
                }
            }

            int ii = 0;

            foreach (DataColumn C in T.Columns)
            {
                if (C.Caption == "")
                {
                    continue;
                }
                L.Columns.Add(C.Caption, sizes[ii], HelpForm.GetAlignForColumn(C));
                ii++;
            }

            if (IsCheckList)
            {
                L.CheckBoxes = true;
            }
            L.FullRowSelect = true;
            L.View          = View.Details;
            L.GridLines     = true;
            L.EndUpdate();
            L.Refresh();
        }