|
|
|
 |
 |
Исходник |
 |
|
 |
 |
|
Автор:
|
|
|
Название:
|
Создание стиля для грида (русские header, цвет и прочее) |
|
Дата:
|
14 January 2003 |
|
Описание: |
Cоздается свой стиль. Навешиваются(создаются) там свои колонки. Указать им хедер (хоть на китайском), подключить их к стилю. Стиль подключить к гриду. Не забыть поставить для стиля DataMember, иначе не будет работать.
В хедере подравнять тест по центру не знаю (за ненадобностью). Мож кто добавит :) Лень искать. |
| |
Разместить ссылку на этот исходник в форуме вы можете вставив в текст сообщения
следующую строку:
[CODEPOST ID=32]Создание стиля для грида (русские header, цвет и прочее) [/CODEPOST] |
| Оценка: |
Проголосовало 3 посетителей, средняя оценка 1.67 |
| Оценить: |
|
1 // dgListReturns это DataGrid
2
3 dgListReturns.DataSource = ds; //DataSet
4 dgListReturns.DataMember = "Table"; //имя таблицы
5
6 DataGridTableStyle ts = new DataGridTableStyle();
7 ts.AllowSorting = true;
8 ts.ReadOnly = true;
9 ts.AlternatingBackColor = Color.White;
10 ts.BackColor = Color.GhostWhite;
11 ts.ColumnHeadersVisible = true;
12 ts.MappingName = "Table";
13 ts.RowHeadersVisible = false;
14 //
15 DataGridTextBoxColumn col0 = new DataGridTextBoxColumn();
16 col0.Alignment = HorizontalAlignment.Center;
17 col0.ReadOnly = true;
18 col0.HeaderText = "№";
19 col0.Width = 20;
20 col0.MappingName = "ReturnID";
21 ts.GridColumnStyles.Add(col0);
22 //
23 DataGridTextBoxColumn col1 = new DataGridTextBoxColumn();
24 col1.Alignment = HorizontalAlignment.Left;
25 col1.ReadOnly = true;
26 col1.HeaderText = "Группа";
27 col1.Width = 60;
28 col1.MappingName = "GroupName";
29 ts.GridColumnStyles.Add(col1);
30 //
31 DataGridTextBoxColumn col2 = new DataGridTextBoxColumn();
32 col2.Alignment = HorizontalAlignment.Left;
33 col2.ReadOnly = true;
34 col2.HeaderText = "Категория";
35 col2.Width = 75;
36 col2.MappingName = "CategoryName";
37 ts.GridColumnStyles.Add(col2);
38 //
39 DataGridTextBoxColumn col3 = new DataGridTextBoxColumn();
40 col3.Alignment = HorizontalAlignment.Left;
41 col3.ReadOnly = true;
42 col3.HeaderText = "Наименование";
43 col3.Width = 85;
44 col3.MappingName = "ProductName";
45 ts.GridColumnStyles.Add(col3);
46 //
47 DataGridTextBoxColumn col4 = new DataGridTextBoxColumn();
48 col4.Alignment = HorizontalAlignment.Center;
49 col4.ReadOnly = true;
50 col4.HeaderText = "Кол-во";
51 col4.Width = 45;
52 col4.MappingName = "Quantity";
53 ts.GridColumnStyles.Add(col4);
54 //
55 DataGridTextBoxColumn col5 = new DataGridTextBoxColumn();
56 col5.Alignment = HorizontalAlignment.Left;
57 col5.ReadOnly = true;
58 col5.HeaderText = "Дата возврата";
59 col5.Width = 68;
60 col5.MappingName = "ReturnDate";
61 ts.GridColumnStyles.Add(col5);
62 //
63 DataGridTextBoxColumn col6 = new DataGridTextBoxColumn();
64 col6.Alignment = HorizontalAlignment.Left;
65 col6.ReadOnly = true;
66 col6.HeaderText = "Причина";
67 col6.Width = 95;
68 col6.MappingName = "Description";
69 ts.GridColumnStyles.Add(col6);
70 //
71 DataGridTextBoxColumn col7 = new DataGridTextBoxColumn();
72 col7.Alignment = HorizontalAlignment.Left;
73 col7.ReadOnly = true;
74 col7.HeaderText = "Продавец";
75 col7.Width = 170;
76 col7.MappingName = "SellerName";
77 ts.GridColumnStyles.Add(col7);
78 //
79 dgListReturns.TableStyles.Clear(); // это не обязательно. Там свой нюанс был.
80 dgListReturns.TableStyles.Add(ts);
81 |
| Вернуться к списку исходников в категории Winforms |
|
|
 |
 |
 |
 |
|
|