Gambas Forge BETA

Espace Membres Connexion Inscription
Vous devez être connecté pour accéder au chat.

Donner le meme aspect a des gridview dans le meme form

Ce sujet est résolu.

1
AuteurMessages
spheris#Posté le 25/01 à 17:41
Gambas Forever !Bonsoir,

Dans une form j'ai 5 gridview, et je souhaite remplir des cellules avec les meme textes, les memes couleurs d'arriere plan , les memes font, etc... genre ça :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
GridView1[1, 1].Text = "Maison :"
GridView1[1, 1].Alignment = 2
GridView1[1, 2].Text = "2,1%"
GridView1[1, 2].Background = &H000000&
GridView1[1, 2].Foreground = &HFFFFFF&
GridView1[1, 2].Alignment = 3
GridView1[2, 1].Text = "voiture :"
GridView1[2, 1].Alignment = 2
GridView1[2, 2].Text = "2,1%"
GridView1[2, 2].Background = &H000000&
GridView1[2, 2].Foreground = &HFFFFFF&
GridView1[2, 2].Alignment = 3
GridView1[4, 1].Text = "camion :"
GridView1[4, 1].Alignment = 2
GridView1[4, 2].Text = "2,1%"
GridView1[4, 2].Background = &H000000&
GridView1[4, 2].Foreground = &HFFFFFF&
GridView1[4, 2].Alignment = 3
GridView1[5, 1].Text = "Velo:"
GridView1[5, 1].Alignment = 2
GridView1[5, 2].Text = "2,1%"
GridView1[5, 2].Background = &H000000&
GridView1[5, 2].Foreground = &HFFFFFF&
GridView1[5, 2].Alignment = 3
GridView1[7, 1].Text = "cabanon:"
GridView1[7, 1].Alignment = 2
GridView1[7, 2].Text = "2,1%"
GridView1[7, 2].Background = &H000000&
GridView1[7, 2].Foreground = &HFFFFFF&
GridView1[7, 2].Alignment = 3
GridView1[9, 1].Text = "utilitaire:"
GridView1[9, 1].Alignment = 2
GridView1[9, 2].Text = "2,1%"
GridView1[9, 2].Background = &H000000&
GridView1[9, 2].Foreground = &HFFFFFF&
GridView1[9, 2].Alignment = 3
GridView1[11, 1].Text = "moto:"
GridView1[11, 1].Alignment = 2
GridView1[11, 2].Text = "2,1%"
GridView1[11, 2].Background = &H000000&
GridView1[11, 2].Foreground = &HFFFFFF&
GridView1[11, 2].Alignment = 3


et ca ce n'est que pour la gridview1 alors imaginez le monstre lourd code.
existe t il un moyen ? je suppose par les groupe et les tag mais je n'y arrive pas...
Merci pour votre aide.
;)
Prokopy#Posté le 25/01 à 20:07
Kinder PinguiSalut spheris,

Je pense que tu peux utiliser une fonction et une boucle For pour raccourcir un peu tout ça :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Private Sub InitGridView(grille As GridView)
Dim Legendes As String[] = ["Maison : ", "Voiture : ", "Camion : ", "Velo : "]
Dim i As Integer

For i = 1 To Legendes.Max
GridView1[i, 1].Text = Legendes[i]
GridView1[i, 1].Alignment = 2
GridView1[i, 2].Text = "2,1%"
GridView1[i, 2].Background = &H000000&
GridView1[i, 2].Foreground = &HFFFFFF&
GridView1[i, 2].Alignment = 3
Next
End

Public Sub Form_Open()
InitGridView(GridView1)
InitGridView(GridView2)
InitGridView(GridView3)
InitGridView(GridView4)
End


Et voilà. :)
linuxos#Posté le 26/01 à 00:20
Un peu de sel, de poivre et la crevette sera... Bonsoir,

Je me permets un petit correctif du a une erreur d'inattention:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Private Sub InitGridView(grille As GridView)
Dim Legendes As String[] = ["Maison : ", "Voiture : ", "Camion : ", "Velo : "]
Dim i As Integer

For i = 1 To Legendes.Max
grille[i, 1].Text = Legendes[i] <--- 'grille' a la place de 'GridView1'
grille[i, 1].Alignment = 2
grille[i, 2].Text = "2,1%"
grille[i, 2].Background = &H000000&
grille[i, 2].Foreground = &HFFFFFF&
grille[i, 2].Alignment = 3
Next
End

Public Sub Form_Open()
InitGridView(GridView1)
InitGridView(GridView2)
InitGridView(GridView3)
InitGridView(GridView4)
End


Olivier
Prokopy#Posté le 26/01 à 18:04
Kinder PinguiAh oui mince, merci. ;)
gambix#Posté le 26/01 à 23:10
Faire simple !on peut aussi passer par _data
spheris#Posté le 26/01 à 23:40
Gambas Forever !Ah bon ? Crois-tu que l'on gagne en ligne de code ?
gambix#Posté le 30/01 à 11:17
Faire simple !ça dépend de ce que tu veux faire
spheris#Posté le 30/01 à 18:53
Gambas Forever !...???

Ben pour résumer :
http://gambaslinux.eg2.fr/articles.php?lng=fr&pg=1989
gambix#Posté le 30/01 à 22:01
Faire simple !ça ne repond pas a ma question ... ce que tu veut faire avec tes tables
spheris#Posté le 30/01 à 22:32
Gambas Forever !Oui tu as raison, en fait je voulais faire ceci (recréer une interface virtuelle qui ressemble à ça):



mais multiplié par le nombre de capteurs d'un systeme d'acquisition analogique/digital.
pour chaque appareil virtuel, il me faut 4 lcd, 4 dial, 3 sliders.
J'ai donc pensé à utiliser une gridview dans laquelle en jouant sur les couleurs, je donne l'impression d'un appareil.
L'idée est tombé à l'eau, j'ai tout le matos pour le fabriquer en hard. avec liaison série sur GB.

Merci quand même pour ton aide.
;)
gambix#Posté le 02/02 à 13:56
Faire simple !je n'aurait de toute les façon pas utilisé un gridview mais des containers.
1

Connexion