IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++Builder Discussion :

[Tlistview]Editer une cellule?


Sujet :

C++Builder

  1. #1
    Membre éprouvé Avatar de cfdev
    Homme Profil pro
    Passionné
    Inscrit en
    Octobre 2004
    Messages
    220
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Passionné

    Informations forums :
    Inscription : Octobre 2004
    Messages : 220
    Par défaut [Tlistview]Editer une cellule?
    Bonjours à tous,

    une petite question sur le TListview en mode : vsReport.

    Est-il possible de pouvoir éditer le contenu d'une cellule directement en double cliquant dessus par exemple ?

    car actuellement je passe pas un Tedit juste en dessous qui me sert à recopier la cellule sélectionnée puis à la modifier....un peu lourd qd meme.

  2. #2
    Membre Expert
    Avatar de Crayon
    Inscrit en
    Avril 2005
    Messages
    1 811
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 811
    Par défaut
    Il y a moyen de le faire, j'ai trouver le code sur le net, mais présentement je ne suis pas chez moi! Donc, si personne ne l'a, il va falloir faire une recherche toi même

    Si tu trouves rien, dans 8-9h je vais pouvoir t'aidé

  3. #3
    Membre éprouvé Avatar de cfdev
    Homme Profil pro
    Passionné
    Inscrit en
    Octobre 2004
    Messages
    220
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Passionné

    Informations forums :
    Inscription : Octobre 2004
    Messages : 220
    Par défaut
    lol,
    Il y a pas de soucis je vais attendre alors...
    Les recherches me sortes des yeux

    Merci
    ++

  4. #4
    Membre chevronné
    Avatar de Altau
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    296
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 296
    Par défaut
    Le composant TAdvListView de www.tmssoftware.com (gratuit) permet de faire pas mal de choses dans ce genre.

  5. #5
    Membre éprouvé Avatar de cfdev
    Homme Profil pro
    Passionné
    Inscrit en
    Octobre 2004
    Messages
    220
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Passionné

    Informations forums :
    Inscription : Octobre 2004
    Messages : 220
    Par défaut
    je te remercis altau mais je n'aime pas trop utiliser ce genre de composant moitié payant et gratuit...mais bon je vais qd meme jeter un coup d'oeil.

    A fait Crayon pendant que j'y pense j'aime bien ton jeux de carte Horloge le principe est sympa

    ++

  6. #6
    Membre éprouvé Avatar de Flow_75
    Femme Profil pro
    Ingénieure
    Inscrit en
    Mai 2005
    Messages
    1 100
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Ingénieure
    Secteur : Transports

    Informations forums :
    Inscription : Mai 2005
    Messages : 1 100
    Par défaut
    J'ai essayer d'installer le composant TadListView de TMS dans borland C++builder 6
    mais quand j'essaye de l'installer comme ils le disent, je fais ouvrir, je selectionne le fichier : alvpkgc6.bpk
    mais quand je fais compiler, ca me fait qu'il manque une librairie : alvpkgc6.bpi


    Merci de votre aide....

  7. #7
    Membre Expert
    Avatar de Crayon
    Inscrit en
    Avril 2005
    Messages
    1 811
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 811
    Par défaut
    virtuA je suis désolé, hier je me suis coucher très top et j'ai pas été sur le forum, là je suis au boulot et j'ai pas mon code

    Si tu me trouves incohérent au niveau des heures, c'est que je suis Québec. Donc 6 heure de décalage avec le France.

  8. #8
    Membre Expert
    Avatar de Crayon
    Inscrit en
    Avril 2005
    Messages
    1 811
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 811
    Par défaut
    Salut, je ne trouve plus le site où j'ai trouvé les fichiers, alors les voici pour faire un copier/coller.

    Voici le fichier .h
    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    //---------------------------------------------------------------------------
     
    #ifndef ListViewEditSubFormH
    #define ListViewEditSubFormH
    //---------------------------------------------------------------------------
    #include <Classes.hpp>
    #include <Controls.hpp>
    #include <StdCtrls.hpp>
    #include <Forms.hpp>
    #include <ComCtrls.hpp>
    #include <ExtCtrls.hpp>
    //---------------------------------------------------------------------------
    #ifdef STRICT
    #define MYWNDPROC	WNDPROC
    #else
    #define MYWNDPROC	FARPROC
    #endif
    //---------------------------------------------------------------------------
    class TForm1 : public TForm
    {
    __published:	// IDE-managed Components
    	TListView *ListView1;
    	void __fastcall ListView1Editing(TObject *Sender, TListItem *Item,
              bool &AllowEdit);
    	void __fastcall ListView1Edited(TObject *Sender, TListItem *Item,
              AnsiString &S);
    	void __fastcall ListView1MouseDown(TObject *Sender, TMouseButton Button,
              TShiftState Shift, int X, int Y);
    	void __fastcall ListView1DrawItem(TCustomListView *Sender,
              TListItem *Item, TRect &Rect, TOwnerDrawState State);
    private:	// User declarations
    	int ColumnToEdit;
    	MYWNDPROC OldListViewEditProc;
    	HWND hListViewEditWnd;
    	void *ListViewEditWndProcPtr;
    	void __fastcall ListViewEditWndProc(TMessage &Message);
    public:		// User declarations
    	__fastcall TForm1(TComponent* Owner);
    	__fastcall ~TForm1();
    };
    //---------------------------------------------------------------------------
    extern PACKAGE TForm1 *Form1;
    //---------------------------------------------------------------------------
    #endif
    Et le .cpp
    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    //---------------------------------------------------------------------------
     
    #include <vcl.h>
    #pragma hdrstop
     
    #include "ListViewEditSubForm.h"
    #include <shlwapi.h> // for DllGetVersion()
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
     
    TForm1 *Form1;
     
    struct TListViewCoord
    {
    	int Item;
    	int Column;
    };
     
    typedef int (__fastcall *TLVGetColumnAt)(TListItem *Item, const TPoint &Pt);
    typedef bool (__fastcall *TLVGetColumnRect)(TListItem *Item, int ColumnIndex, TRect &Rect);
    typedef bool (__fastcall *TLVGetIndexesAt)(TCustomListView *ListView, const TPoint &Pt, TListViewCoord &Coord);
     
    // these will be assigned according to the version of COMCTL32.DLL being used
    TLVGetColumnAt GetColumnAt = NULL;
    TLVGetColumnRect GetColumnRect = NULL;
    TLVGetIndexesAt GetIndexesAt = NULL;
     
    // TCustomListViewAccess is used with Manual_GetColumnAt() and Manual_GetColumnRect()
    class TCustomListViewAccess : public TCustomListView
    {
    public:
    	__property Columns;
    };
     
    //---------------------------------------------------------------------------
    //	GetComCtl32Version
    //
    //	Purpose: Helper function to determine the version of CommCtrl32.dll that is loaded.
    //---------------------------------------------------------------------------
     
    DWORD __fastcall GetComCtl32Version()
    {
    	static DWORD ComCtl32Version = 0;
     
    	if( ComCtl32Version == 0 )
    	{
    		HMODULE hComCtrl32 = ::GetModuleHandle("comctl32.dll");
    		if( hComCtrl32 )
    		{
    			DLLGETVERSIONPROC lpDllGetVersion = (DLLGETVERSIONPROC) ::GetProcAddress(hComCtrl32, "DllGetVersion");
    			if( lpDllGetVersion )
    			{
    				DLLVERSIONINFO dvi = {sizeof(DLLVERSIONINFO), 0};
    				if( lpDllGetVersion(&dvi) >= 0 )
    					ComCtl32Version = MAKELONG(dvi.dwMajorVersion, dvi.dwMinorVersion);
    			}
     
    			if( ComCtl32Version == 0 )
    			{
    				char FileName[MAX_PATH+1] = {0};
    				if( ::GetModuleFileName(hComCtrl32, FileName, MAX_PATH) )
    				{
    					DWORD dwHandle = 0;
    					DWORD dwSize = ::GetFileVersionInfoSize(FileName, &dwHandle);
    					if( dwSize )
    					{
    						void *pData = ::LocalAlloc(LPTR, dwSize);
    						if( pData )
    						{
    							if( ::GetFileVersionInfo(FileName, dwHandle, dwSize, pData) )
    							{
    								VS_FIXEDFILEINFO *pVersion = NULL;
    								UINT uiLen = 0;
     
    								if( ::VerQueryValue(pData, "\\", (LPVOID*)&pVersion, &uiLen) )
    									ComCtl32Version = MAKELONG(pVersion->dwFileVersionMS, pVersion->dwFileVersionLS);
    							}
     
    							::LocalFree(pData);
    						}
    					}
    				}
    			}
    		}
    	}
     
    	return ComCtl32Version;
    }
     
    //---------------------------------------------------------------------------
    //	Manual_GetColumnAt
    //
    //	Purpose: Returns the column index at the specified coordinates,
    //		relative to the specified item
    //---------------------------------------------------------------------------
     
    int __fastcall Manual_GetColumnAt(TListItem *Item, const TPoint &Pt)
    {
    	RECT R;
    	TCustomListViewAccess *LV = (TCustomListViewAccess*) Item->ListView;
     
    	// determine the dimensions of the current column value, and
    	// see if the coordinates are inside of the column value
     
    	// get the dimensions of the entire item
    	R = Item->DisplayRect(drBounds);
     
    	// loop through all of the columns looking for the value that was clicked on
    	for(int i = 0; i < LV->Columns->Count; ++i)
    	{
    		R.right = (R.left + LV->Column[i]->Width);
    		if( PtInRect(&R, Pt) )
    			return i;
    		R.left = R.right;
    	}
     
    	return -1;
    }
     
    //---------------------------------------------------------------------------
    //	Manual_GetColumnRect
    //
    //	Purpose: Calculate the dimensions of the specified column,
    //		relative to the specified item
    //---------------------------------------------------------------------------
     
    bool _fastcall Manual_GetColumnRect(TListItem *Item, int ColumnIndex, TRect &Rect)
    {
    	TCustomListViewAccess *LV = (TCustomListViewAccess*) Item->ListView;
     
    	// make sure the index is in the valid range
    	if( (ColumnIndex < 0) || (ColumnIndex >= LV->Columns->Count) )
    		return false;
     
    	// get the dimensions of the entire item
    	Rect = Item->DisplayRect(drBounds);
     
    	// loop through the columns calculating the desired offsets
    	for(int i = 0; i < ColumnIndex; ++i)
    		Rect.Left = (Rect.Left + LV->Column[i]->Width);
    	Rect.Right = (Rect.Left + LV->Column[ColumnIndex]->Width);
     
    	return true;
    }
     
    //---------------------------------------------------------------------------
    //	Manual_GetIndexesAt
    //
    //	Purpose: Returns the Item and Column indexes at the specified coordinates
    //---------------------------------------------------------------------------
     
    bool __fastcall Manual_GetIndexesAt(TCustomListView *ListView, const TPoint &Pt, TListViewCoord &Coord)
    {
    	TListItem *Item = ListView->GetItemAt(Pt.x, Pt.y);
    	if( Item )
    	{
    		Coord.Item = Item->Index;
    		Coord.Column = Manual_GetColumnAt(Item, Pt);
    		return true;
    	}
     
    	// none found
    	return false;
    }
     
    //---------------------------------------------------------------------------
    //	ComCtl_GetColumnAt
    //
    //	Purpose: Returns the column index at the specified coordinates, relative to the specified item
    //---------------------------------------------------------------------------
     
    int __fastcall ComCtl_GetColumnAt(TListItem *Item, const TPoint &Pt)
    {
    	LVHITTESTINFO HitTest = {0};
    	HitTest.pt = Pt;
     
    	if( ListView_SubItemHitTest(Item->ListView->Handle, &HitTest) > -1 )
    	{
    		if( HitTest.iItem == Item->Index )
    			return HitTest.iSubItem;
    	}
     
    	return -1;
    }
     
    //---------------------------------------------------------------------------
    //	ComCtl_GetColumnRect
    //
    //	Purpose: Calculate the dimensions of the specified column, relative to the specified item
    //---------------------------------------------------------------------------
     
    bool __fastcall ComCtl_GetColumnRect(TListItem *Item, int ColumnIndex, TRect &Rect)
    {
    	return ListView_GetSubItemRect(Item->ListView->Handle, Item->Index, ColumnIndex, LVIR_BOUNDS, (LPRECT)&Rect);
    }
     
    //---------------------------------------------------------------------------
    //	ComCtl_GetIndexesAt
    //
    //	Purpose: Returns the Item and Column indexes at the specified coordinates
    //---------------------------------------------------------------------------
     
    bool __fastcall ComCtl_GetIndexesAt(TCustomListView *ListView, const TPoint &Pt, TListViewCoord &Coord)
    {
    	LVHITTESTINFO HitTest = {0};
    	HitTest.pt = Pt;
     
    	if( ListView_SubItemHitTest(ListView->Handle, &HitTest) > -1 )
    	{
    		Coord.Item = HitTest.iItem;
    		Coord.Column = HitTest.iSubItem;
    		return true;
    	}
     
    	// none found
    	return false;
    }
     
    //---------------------------------------------------------------------------
    //	TForm1		Constructor
    //
    //	Purpose:	Form constructor
    //---------------------------------------------------------------------------
     
    __fastcall TForm1::TForm1(TComponent* Owner)
    	: TForm(Owner)
    {
    	// no editing yet
    	ColumnToEdit = -1;
    	OldListViewEditProc = NULL;
    	hListViewEditWnd = NULL;
     
    	ListViewEditWndProcPtr = MakeObjectInstance(ListViewEditWndProc);
    	if( !ListViewEditWndProcPtr )
    		throw Exception("Could not allocate memory for ListViewEditWndProc proxy");
     
    	if( GetComCtl32Version() >= MAKELONG(4, 70) )
    	{
    		GetColumnAt = ComCtl_GetColumnAt;
    		GetColumnRect = ComCtl_GetColumnRect;
    		GetIndexesAt = ComCtl_GetIndexesAt;
    	}
    	else
    	{
    		GetColumnAt = Manual_GetColumnAt;
    		GetColumnRect = Manual_GetColumnRect;
    		GetIndexesAt = Manual_GetIndexesAt;
    	}
    }
     
    //---------------------------------------------------------------------------
    //	TForm1		Destructor
    //
    //	Purpose:	Form destructor
    //---------------------------------------------------------------------------
     
    __fastcall TForm1::~TForm1()
    {
    	if( ListViewEditWndProcPtr )
    		FreeObjectInstance(ListViewEditWndProcPtr);
    }
     
    //---------------------------------------------------------------------------
    //	ListViewEditWndProc
    //
    //	Purpose:	Custom Window Procedure for TListView's editor window
    //---------------------------------------------------------------------------
     
    void __fastcall TForm1::ListViewEditWndProc(TMessage &Message)
    {
    	if( Message.Msg == WM_WINDOWPOSCHANGING )
    	{
    		// this inline editor has a bad habit of re-positioning itself
    		// back on top of the Caption after every key typed in,
    		// so let's stop it from moving
     
    		reinterpret_cast<LPWINDOWPOS>(Message.LParam)->flags |= SWP_NOMOVE;
    		Message.Result = 0;
    	}
    	else
    	{
    		// everything else
    		Message.Result = ::CallWindowProc(OldListViewEditProc, hListViewEditWnd,
    			Message.Msg, Message.WParam, Message.LParam);
    	}
    }
     
    //---------------------------------------------------------------------------
    //	ListView1Editing
    //
    //	Purpose:	Handler for the TListView::OnEditing event
    //---------------------------------------------------------------------------
     
    void __fastcall TForm1::ListView1Editing(TObject *Sender, TListItem *Item,
    		bool &AllowEdit)
    {
    	// ignore the Caption, let it do its default handling
    	if( ColumnToEdit > 0 )
    	{
    		// get the inline editor's handle
    		HWND hWnd = ListView_GetEditControl(ListView1->Handle);
    		if( hWnd )
    		{
    			// determine the dimensions of the subitem being edited
    			TRect R;
    			if( GetColumnRect(Item, ColumnToEdit, R) )
    			{
    				// move the inline editor over the subitem
    				::MoveWindow(hWnd, R.Left, R.Top - 2, R.Width(), R.Height() + 4, TRUE);
     
    				// update the inline editor's text with the subitem's text rather than the Caption
    				::SetWindowText(hWnd, Item->SubItems->Strings[ColumnToEdit-1].c_str());
     
    				// subclass the inline editor so we can catch its movements
    				hListViewEditWnd = hWnd;
     				OldListViewEditProc = (MYWNDPROC) ::GetWindowLong(hWnd, GWL_WNDPROC);
     				::SetWindowLong(hWnd, GWL_WNDPROC, reinterpret_cast<LONG>(ListViewEditWndProcPtr));
    			}
    		}
    	}
    }
     
    //---------------------------------------------------------------------------
    //	ListView1Edited
    //
    //	Purpose:	Handler for the TListView::OnEdited event
    //---------------------------------------------------------------------------
     
    void __fastcall TForm1::ListView1Edited(TObject *Sender, TListItem *Item,
    			AnsiString &S)
    {
    	// ignore the Caption, let it do its default handling
    	if( ColumnToEdit > 0 )
    	{
    		// restore the previous window procedure for the inline editor
    		if( hListViewEditWnd )
    		{
    			::SetWindowLong(hListViewEditWnd, GWL_WNDPROC, reinterpret_cast<LONG>(OldListViewEditProc));
    			hListViewEditWnd = NULL;
    		}
     
    		// assign the new text to the subitem being edited
    		Item->SubItems->Strings[ColumnToEdit-1] = S;
     
    		// prevent the default behavior from updating the Caption as well
    		S = Item->Caption;
    	}
    }
     
    //---------------------------------------------------------------------------
    //	ListView1MouseDown
    //
    //	Purpose:	Handler for the TListView::OnMouseDown event
    //---------------------------------------------------------------------------
     
    void __fastcall TForm1::ListView1MouseDown(TObject *Sender,
    		TMouseButton Button, TShiftState Shift, int X, int Y)
    {
     
    	TListViewCoord Coord;
     
    	if( GetIndexesAt(ListView1, Point(X, Y), Coord) )
    	{
    		if( Coord.Column != ColumnToEdit )
    		{
    			// update the marker
    			ColumnToEdit = Coord.Column;
     
    			// cancel the editing so that the listview won't go into
    			// its edit mode immediately upon clicking the new item
    			ListView1->Items->Item[Coord.Item]->CancelEdit();
     
    			// update the display with a new highlight selection
    			ListView1->Invalidate();
    		}
    	}
    	else
    		ColumnToEdit = -1;
    }
     
    //---------------------------------------------------------------------------
    //	ListView1DrawItem
    //
    //	Purpose:	Handler for the TListView::OnDrawItem event
    //---------------------------------------------------------------------------
     
    void __fastcall TForm1::ListView1DrawItem(TCustomListView *Sender,
    			TListItem *Item, TRect &Rect, TOwnerDrawState State)
    {
    	// erase the entire item to start fresh
    	TRect R = Item->DisplayRect(drBounds);
    	ListView1->Canvas->Brush->Color = ListView1->Color;
    	ListView1->Canvas->FillRect(R);
     
    	// see if the mouse is currently held down, and if so update the marker as needed
    	if( GetKeyState(VK_LBUTTON) & 0x8000 )
    	{
    		// find the mouse cursor onscreen, convert the coordinates to client
    		// coordinates on the list view
    		POINT p;
    		::GetCursorPos(&p);
    		ColumnToEdit = GetColumnAt(Item, ListView1->ScreenToClient(p));
    	}
     
    	// loop through all of the columns drawing each column
    	AnsiString S;
    	for(int i = 0; i < ListView1->Columns->Count; ++i)
    	{
    		// determine the dimensions of the current column value
    		if( !GetColumnRect(Item, i, R) )
    			continue;
     
    		// mimic the default behavior by only drawing a value as highlighted if
    		// the entire item is selected, the particular column matches the marker,
    		// and the ListView is not already editing
    		if( (Item->Selected) && (i == ColumnToEdit) && (!ListView1->IsEditing()) )
    		{
    			ListView1->Canvas->Brush->Color = clHighlight;
    			ListView1->Canvas->Font->Color = clHighlightText;
    		}
    		else
    		{
    			ListView1->Canvas->Brush->Color = ListView1->Color;
    			ListView1->Canvas->Font->Color = ListView1->Font->Color;
    		}
     
    		ListView1->Canvas->FillRect(R);
     
    		// draw the column's text
    		if( i == 0 )
    			S = Item->Caption;
    		else
    			S = Item->SubItems->Strings[i-1];
     
    		ListView1->Canvas->TextRect(R, R.Left + 2, R.Top, S);
    	}
    }
    //---------------------------------------------------------------------------
    Si c'est bien ce que tu voulais, mais pour que je sache que tout est OK!

  9. #9
    Membre éprouvé Avatar de cfdev
    Homme Profil pro
    Passionné
    Inscrit en
    Octobre 2004
    Messages
    220
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Passionné

    Informations forums :
    Inscription : Octobre 2004
    Messages : 220
    Par défaut
    Oula quelle usine !!

    je m'attendais pas à ca c'est un peu enorme...

    je l'ai tester qd meme mais apparement j'ai un soucis avec la fonction "GetComCtl32Version" il ne trouve pas la référence.

    merci crayon

    ++

  10. #10
    Membre Expert
    Avatar de Crayon
    Inscrit en
    Avril 2005
    Messages
    1 811
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 811
    Par défaut
    Oups j'avais pas remarquer, il manque la déclaration de certaine fonction. J'ai pas utiliser le code directement, j'ai fait des copier/coller de certain bout dans mon programme

    Va falloir les ajouter au fichier d'entête (.h).

  11. #11
    Membre Expert
    Avatar de kmaniche
    Inscrit en
    Janvier 2006
    Messages
    1 717
    Détails du profil
    Informations forums :
    Inscription : Janvier 2006
    Messages : 1 717
    Par défaut
    Bonjour,

    je reviens sur ce sujet, la suite m'interesse enormement. Pouvez vous présenter encore completer la solution de Crayon.

    merci

  12. #12
    Membre Expert
    Avatar de Crayon
    Inscrit en
    Avril 2005
    Messages
    1 811
    Détails du profil
    Informations personnelles :
    Localisation : Autre

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 811
    Par défaut Tout fonctionne
    Je viens de tester le code et tout fonctionne, le code est complet. Il suffit juste de faire comme le code plus haut et de mettre les fonctions (comme GetComCtl32Version) avant le constructeur de la classe Form1. Sinon vous pouvez déclarer les fonctions en haut du fichier CPP et ensuite mettre le code n'importe où dans le même fichier.

    Ex:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    DWORD __fastcall GetComCtl32Version();

  13. #13
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Par défaut
    Salut
    Voici un lien en Delphi tres complet je ne sais pas si c'est le lien dont parlait Crayon

  14. #14
    Membre Expert
    Avatar de kmaniche
    Inscrit en
    Janvier 2006
    Messages
    1 717
    Détails du profil
    Informations forums :
    Inscription : Janvier 2006
    Messages : 1 717
    Par défaut
    Bonjour

    Merci pour vos réponses.

    Est-il possible d'utiliser cette solution pour récupérer le contenu d'une cellule d'une DBGrid ?

Discussions similaires

  1. editer une cellule de tableViewController
    Par kathIphone dans le forum Développement iOS
    Réponses: 4
    Dernier message: 14/05/2014, 12h17
  2. [XL-2010] Editer une cellule dans une ListView
    Par FranPier dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 10/07/2013, 14h07
  3. Editer ou non une cellule dans une stringGrid ?
    Par jamah dans le forum Composants VCL
    Réponses: 3
    Dernier message: 31/03/2006, 17h52
  4. Edition d'une cellule d'un JTable
    Par teuteu62 dans le forum Composants
    Réponses: 3
    Dernier message: 05/01/2006, 15h16
  5. Editer une cellule de Jtable
    Par calypso dans le forum Composants
    Réponses: 3
    Dernier message: 22/04/2004, 10h45

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo