whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

31 Visitors Online


 
...detect/handle a click on a TListView Checkbox?
Autor: Jailbird
Homepage: http://jail.tip.nu
[ Print tip ]  

Tip Rating (11):  
     


procedure TForm1.ListView1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  
Item: TListItem;
  HitTest: THitTests;
begin
  
// Welchem Item gehört die CheckBox
  // Which item belongs to the checkbox
  
Item := ListView1.GetItemAt(x, y);

  // Was wurde vom Item genau angeklickt
  // What kind of thing was hit on the item
  
HitTest := ListView1.GetHitTestInfoAt(x, y);

  // Falls ein Item angeklickt wurde und davon die Checkbox
  // If an Item was hit and exactly his checkbox
  
if (Item <> niland (HitTest = [htOnStateIcon]) then
  begin
    
////////////////////////////////
    // Hier das OnCheck behandeln //
    // Handle OnCheck here        //
    ////////////////////////////////
    // Beispiel
    // Example
    //
    //  if Item.Checked = False then
    //  begin
    //    if (Item.Index = 0) or (ListView1.Items.Item[Item.Index - 1].Checked = True) then
    //      Item.Checked := True else Item.Checked := False;
    //  end else
    //    begin
    //    if (Item.Index = ListView1.Items.Count - 1) or (ListView1.Items.Item[Item.Index + 1].Checked = False) then Item.Checked := False else
    //      Item.Checked := True;
    //  end;
  
end;
end;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners