Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
how to movr rows and columns of a StringGrid by code Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
29-Nov-02
Category
VCL-General
Language
Delphi 5.x
Views
143
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Ernesto De Spirito

The user can move rows and columns of a StringGrid with the mouse. Can it also be 
done by code? In the help for TCustomGrid you can see the methods MoveColumn and 
MoveRow, but they are hidden in TStringGrid

Answer:

The user can move rows and columns of a StringGrid with the mouse. Can it also be 
done by code? In the help for TCustomGrid you can see the methods MoveColumn and 
MoveRow, but they are hidden in TStringGrid. We can make them accessible again by 
subclassing TStringGrid and declaring these methods as public: 

1   type
2     TStringGridX = class(TStringGrid)
3     public
4       procedure MoveColumn(FromIndex, ToIndex: Longint);
5       procedure MoveRow(FromIndex, ToIndex: Longint);
6     end;


The implementation of these methods simply consists of invoking the corresponding 
method of the ancestor: 
7   
8   procedure TStringGridX.MoveColumn(FromIndex, ToIndex: Integer);
9   begin
10    inherited;
11  end;
12  
13  procedure TStringGridX.MoveRow(FromIndex, ToIndex: Integer);
14  begin
15    inherited;
16  end;


You don't have to register this component in the Components Palette. Use a 
TStringGrid or any TCustomGrid descendant, and when you need to call these methods 
simply cast the object to the new class. For example: 
17  
18  procedure TForm1.Button1Click(Sender: TObject);
19  begin
20    TStringGridX(StringGrid1).MoveColumn(1, 3);
21  end;


Copyright (c) 2001 Ernesto De Spiritomailto:edspirito@latiumsoftware.com
Visit: http://www.latiumsoftware.com/delphi-newsletter.php

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC