hi
ok. but is there any other component like listbox in which individual rows can be made disabled
Main Topics
Browse All Topicshi all
i am facing a problem in list box
my listbox contains 100 rows. once one row is selected its text is moved to some other box.
now i want this selected row to become disabled.
can anyone plz help me out.
thanks in advance
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
only one I know of is TVirtualTree (http://www.delphi-gems.co
Would it not be better to use the standard Dual Listbox form idea?
Instead of just copying the item to the second listbox and disabling the first, move it to the second listbox.
This would be a much better way of handling it.
If you REALLY want to be able to move it back to its previous location in the first list, you might be better loading all the items to go into the first listbox into an objectlist, with each object holding its position and visible text.
This way you always know where to put the item back if you decide not to include it in the second list, and can just pass the objects from one list to the other.
Just my 2 cents.
This is from a post by Jacco. It was origianlly for a ComboBox but I modified it to work with
a ListBox:
procedure SetDisabledItem(AListBox: TListBox; AIndex: Integer; AValue: Boolean);
begin
if not Assigned(AListBox) then
Exit;
if AIndex < AListBox.Items.Count then
begin
if AValue then
begin
if Integer(AListBox.Items.Obj
begin
if AIndex = AListBox.ItemIndex then
AListBox.Tag := -1;
AListBox.Items.Objects[AIn
AListBox.Items[AIndex] := '['+AListBox.Items[AIndex]
end;
end
else
begin
if Integer(AListBox.Items.Obj
begin
AListBox.Items.Objects[AIn
AListBox.Items[AIndex] := Copy(AListBox.Items[AIndex
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender
begin
SetDisabledItem(ListBox1,1
end;
procedure TForm1.Button2Click(Sender
begin
SetDisabledItem(ListBox1,1
end;
procedure TForm1.ListBox1Click(Sende
begin
with TListBox(Sender) do
begin
if Integer(Items.Objects[Item
begin
ItemIndex := Tag;
end
else
begin
Tag := ItemIndex;
end;
end;
end;
Set the Style to lbOwnerDrawnFixed and this code will make it draw in a different color:
procedure SetDisabledItem(AListBox: TListBox; AIndex: Integer; AValue: Boolean);
begin
if not Assigned(AListBox) then
Exit;
if AIndex < AListBox.Items.Count then
begin
if AValue then
begin
if Integer(AListBox.Items.Obj
begin
if AIndex = AListBox.ItemIndex then
AListBox.Tag := -1;
AListBox.Items.Objects[AIn
end;
end
else
begin
if Integer(AListBox.Items.Obj
begin
AListBox.Items.Objects[AIn
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender
begin
SetDisabledItem(ListBox1,1
ListBox1.Invalidate;
end;
procedure TForm1.Button2Click(Sender
begin
SetDisabledItem(ListBox1,1
ListBox1.Invalidate;
end;
procedure TForm1.ListBox1Click(Sende
begin
with TListBox(Sender) do
begin
if Integer(Items.Objects[Item
begin
ItemIndex := Tag;
end
else
begin
Tag := ItemIndex;
end;
end;
end;
procedure TForm1.ListBox1DrawItem(Co
Rect: TRect; State: TOwnerDrawState);
var
LB: TListBox;
ItemText: String;
begin
LB := TListBox(Control);
ItemText := LB.Items[Index];
if odSelected in State then
LB.Canvas.Brush.Color := clHighLight
else
if Integer(LB.Items.Objects[I
begin
LB.Canvas.Brush.Color := clInactiveCaption;
LB.Canvas.Font.Color := clInactiveCaptionText;
end
else
LB.Canvas.Brush.Color := clWindow;
LB.Canvas.FillRect(Rect);
LB.Canvas.TextOut(Rect.Lef
end;
Hi,
Add a listbox on your form and compile.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure ListBox1Click(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
i: integer;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
j: integer;
begin
ListBox1.Style:= lbOwnerDrawFixed;
for j:=0 to 3 do listbox1.Items.Add('Item ' + inttostr(j));
for j:=4 to 6 do ListBox1.Items.AddObject('
for j:=7 to 10 do ListBox1.Items.AddObject('
end;
procedure TForm1.ListBox1DrawItem(Co
Rect: TRect; State: TOwnerDrawState);
begin
with Control as TListBox do
begin
Canvas.FillRect(Rect);
Canvas.Font.Color := TColor(Items.Objects[Index
Canvas.TextOut(Rect.Left + 2, Rect.Top, Items[Index]);
end;
end;
procedure TForm1.ListBox1Click(Sende
begin
if colortostring(TColor(Listb
end;
procedure TForm1.ListBox1DblClick(Se
begin
i:= Listbox1.itemindex;
ListBox1.Items.InsertObjec
ListBox1.Items.Delete(i+1)
end;
end.
And this one with 2 listbox (double click to move the items)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
ListBox2: TListBox;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure ListBox1Click(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
i: integer;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
j: integer;
begin
ListBox1.Style:= lbOwnerDrawFixed;
// 100 items
for j:=0 to 100 do listbox1.Items.Add('Item ' + inttostr(j));
end;
procedure TForm1.ListBox1DrawItem(Co
Rect: TRect; State: TOwnerDrawState);
begin
with Control as TListBox do
begin
Canvas.FillRect(Rect);
Canvas.Font.Color := TColor(Items.Objects[Index
Canvas.TextOut(Rect.Left + 2, Rect.Top, Items[Index]);
end;
end;
procedure TForm1.ListBox1Click(Sende
begin
if colortostring(TColor(Listb
end;
procedure TForm1.ListBox1DblClick(Se
begin
i:= Listbox1.itemindex;
ListBox2.Items.Add(Listbox
ListBox1.Items.InsertObjec
ListBox1.Items.Delete(i+1)
end;
end.
Business Accounts
Answer for Membership
by: AmigoJackPosted on 2006-12-08 at 03:09:05ID: 18100441
listbox entries cant be "disabled". you have to delete the corresponding line (and memorize its content and its position if you want to insert it back later)