Bonjours, peut etre que la question a deja �t� pos� mais je n'ai pas trouv�.
je veut remplir un StringGrid par des choix de ComboBox .et ces ComboBox existe dans le StringGrid.merci
Bonjours, peut etre que la question a deja �t� pos� mais je n'ai pas trouv�.
je veut remplir un StringGrid par des choix de ComboBox .et ces ComboBox existe dans le StringGrid.merci
Bonjour
c'est bon j'ai resolu mon souci a l'aide ce lien http://www.developpez.net/forums/showthread.php?t=85126
mon code que j'ai utilis� est
Code : S�lectionner tout - Visualiser dans une fen�tre � part
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 void __fastcall TForm1::ComboBox(TObject *Sender, int ACol, int ARow, TRect &Rect, TGridDrawState State) { int curr_row,curr_col; { if (ComboBox3 == NULL) return; // sécurité : si pas de combo fin {TRect Rect =StringGrid1->CellRect(StringGrid1->Col,StringGrid1->Row); // les coordonnées de la cellule ComboBox3->Visible = false; // combo non visible ComboBox3->Top = StringGrid1->Top + Rect.Top + StringGrid1->GridLineWidth; // la combo s'affiche dessus la cellule ComboBox3->Left = StringGrid1->Left + Rect.Left + StringGrid1->GridLineWidth; ComboBox3->Height = (Rect.Bottom - Rect.Top) + 1; ComboBox3->Width = (Rect.Right - Rect.Left) + 1; int min = ComboBox3->Canvas->TextWidth("XXX") + GetSystemMetrics(SM_CXVSCROLL); // mini = 3lettres + la flèche if (ComboBox3->Width < min) ComboBox3->Width = min; // largeur mini pour la combo ComboBox3->Tag =MAKELONG (StringGrid1->Col, StringGrid1->Row); // pour conserver la ligne cliquée (et la colonne) ComboBox3->ItemIndex = ComboBox3->Items->IndexOf(StringGrid1->Cells[StringGrid1->Col][StringGrid1->Row]); // je sélectionne le texte de la cellule ComboBox3->Visible = true; // la rendre visible ComboBox3->BringToFront(); } // au 1er } }
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7 void __fastcall TForm1::ComboBox3Change(TObject *Sender) { TComboBox * Cbx = (TComboBox*)Sender; int curCol = LOWORD((DWORD)Cbx->Tag); int curRow = HIWORD((DWORD)Cbx->Tag); StringGrid1->Cells[curCol][curRow] = Cbx ->Items->Strings[Cbx ->ItemIndex]; }
mon probleme maintenant est que je veut remplir que la colonne 1 et 2
de StringGrid par ComboBox3 et la colonne 3 et 4 par un autre ComboBox.
merci d'avance.
et donc?
sachant que tu sais positionner la premi�re pourquoi tu pourrais pas positionner les autres?
j'ai r�ussimerci
Partager