Search Results

Search found 5 results on 1 pages for 'tstringgrid'.

Page 1/1 | 1 

  • TStringGrid with BOTH editing AND range selection?

    - by Kevin Killion
    Question: Can anyone point to an article or code samples anywhere on how to provide BOTH editing AND range selection in a TStringGrid? Yes, I KNOW there are third-party grids that do this, but it's frustrating that the built-in grid lacks this basic capability. Background: It's pretty normal to expect to be able to both edit a cell in a grid, and also to select a range of cells such as for a Copy operation. As delivered, TStringGrid doesn't do that. It's either/or. In fact, the docs tell us about the grid Options, "When goEditing is included in Options, goRangeSelect has no effect". However, it looks like it may be possible to do editing and rangeselects in a TStringGrid anyway!!! Through careful use of the mousedown, mouseup, selectcell and exit events, you can get dang close by switching editing elements on and off at the right times. But I still don't have it perfect, and that only covers mouse use, not keyboard changes.

    Read the article

  • Delphi - OnKeyPress occurs before TStringGrid updates cell with new character

    - by JMTyler
    Coding in Delphi, attaching an OnKeyPress event handler to a TStringGrid: The OnKeyPress event fires before the grid cell that the user is typing into has actually updated its value with the key that has been pressed. This is obviously a problem, when I want to know what the contents of that cell are at this moment, as in, as the user modifies it. The "hacked" solution is simple, if you're not considering every detail: just grab the value from the cell and, since the OnKeyPress event comes along with a Key parameter, append that value to the end - now you have the current value of the cell! False. What if the user has selected all the text in the cell (ie: "foo") and they are now typing 'b'. Since they selected the text, it will be erased and replaced with the letter 'b'. However, the value of the cell will still display as "foo" in OnKeyPress, and the value of Key will be 'b', so the above logic would lead the application to conclude that the cell now contains "foob", which we know is not true. So. Does anybody know how to get around this problem? Is there a way to make OnKeyPress react after the grid's contents have been updated, or perhaps a way to force an update at the start of the handler? I am desperately avoiding the use of the OnKeyUp event here, so any suggestions aside from that would be greatly appreciated.

    Read the article

  • Provide an OnChange event for an internal property which is controlled externally?

    - by NGLN
    For fun and by request I am updating this ImageGrid component, a kind of listbox for images that has a FileNames property of type TStrings. For ease of writing, I have been misusing its FileNames.Objects property for bitmap storage. But since the TStrings type suggests that users of the component could or would want to use the Objects property for custom data, e.g. like TListBox.Items, I am rewriting the component to store the bitmaps elsewhere and leave FileNames.Objects untouched for unknown future usage. Now I am wondering whether to provide an OnChange event. And if so, whether to fire it when one or more FileNames.Objects changes. Trying to answer it myself, I dove in Delphi's own VCL and stumbled on: TMemo: has an OnChange event, but ignores Lines.Objects TListBox: has no OnChange event, but is capable of storing Items.Objects TStringGrid: has no OnChange event, but is capable of storing Objects, Rows.Objects, Cols.Objects So now I am somewhat puzzeled, because I cannot imagine Borland's developers didn't add events for several Objects properties out of ease. Sure, when a user changes a FileNames.Object in my component, he knows he does and could implement appropriate interaction himself. But wouldn't it be convenient when the component does automatically? What would you expect from this component in this regard?

    Read the article

  • How make a control that look like the "download" dialog of firefox

    - by mamcx
    I have a aplication that like firefox, can be enchanced from plugins available from internet. Now, I want to provide in Delphi (2010) a dialog similar to the download from firefox. I have no skills in build graphical controls. Using the standard controls of Delphi, what could be the best way... using a TListView/TStringGrid with custom draw or... The idea is show a icon in the left, a title with subtitle with 1-3 lines on the middle and date/version on the rigth. That row must be selectable and that is all.

    Read the article

  • Delphi 2010 differs in Canvas transparency compared to Delphi 7?

    - by Tom1952
    I'm porting some very old code from Delph7 to Delphi2010 with a few changes as possible to the existing code base for the usual reasons. First: the good news for anyone who hasn't jumped yet: it's not as daunting as it may look! I'm actually pleased (& surprised) at how easy 1,000,000+ lines of code have moved across. And what a relief to be back on the leading edge! Delphi 2010 has so many great enhancements. However, I'm having a cosmetic problem with some TStringGrids and TDbGrids descendants. In the last century (literally!) someone wrote the two methods below. The first method is used to justify text. When run in Delphi 2010, the new text and the unjustified text to both appear in the cells written to. Of course it's a mess visually, almost illegible. Sometimes, as a result of the second method is use, the grid cells are actually semi-transparent, with text from the window below showing through. (Again, not pretty!) It appears to me that Delphi 2010's TDbGrid and TStringGrid have some differences in the way they handle transparency? I haven't much experience in this area of Delphi (in fact, I have no idea what the 2nd method is actually doing!) and was hoping someone could give me some pointers on what's going on and how to fix it. TIA! Method 1 procedure TForm1.gridDrawCell(Sender: TObject; Col, Row: Integer; Rect: TRect; State: TGridDrawState); {Used to align text in cells.} var x: integer; begin if (Row > 0) AND (Col > 0) then begin SetTextAlign(grdTotals.Canvas.Handle, TA_RIGHT); x := Rect.Right - 2; end else begin SetTextAlign(grdTotals.Canvas.Handle, TA_CENTER); x := (Rect.Left + Rect.Right) div 2; end; grdTotals.Canvas.TextRect(Rect, x, Rect.Top+2, grdTotals.Cells[Col,Row]); end; Method 2 procedure WriteText(ACanvas: TCanvas; ARect: TRect; DX, DY: Integer; const Text: string; TitleBreak: TTitleBreak; Alignment: TAlignment); const AlignFlags: array [TAlignment] of Integer = (DT_LEFT or { DT_WORDBREAK or } DT_EXPANDTABS or DT_NOPREFIX, DT_RIGHT or { DT_WORDBREAK or } DT_EXPANDTABS or DT_NOPREFIX, DT_CENTER or { DT_WORDBREAK or } DT_EXPANDTABS or DT_NOPREFIX); var ABitmap: TBitmap; AdjustBy: Integer; B, R: TRect; WordBreak: Integer; begin WordBreak := 0; if (TitleBreak = tbAlways) or ((TitleBreak = tbDetect) and (Pos(Chr(13) + Chr(10), Text) = 0)) then WordBreak := DT_WORDBREAK; ABitmap := TBitmap.Create; try ABitmap.Canvas.Lock; try AdjustBy := 1; if (Alignment = taRightJustify) then Inc(AdjustBy); with ABitmap, ARect do begin Width := Max(Width, Right - Left); Height := Max(Height, Bottom - Top); R := Rect(DX, DY, Right - Left - AdjustBy, Bottom - Top - 1); { @@@ } B := Rect(0, 0, Right - Left, Bottom - Top); end; with ABitmap.Canvas do begin Font := ACanvas.Font; Brush := ACanvas.Brush; Brush.Style := bsSolid; FillRect(B); SetBkMode(Handle, TRANSPARENT); DrawText(Handle, PChar(Text), Length(Text), R, AlignFlags[Alignment] or WordBreak); end; ACanvas.CopyRect(ARect, ABitmap.Canvas, B); finally ABitmap.Canvas.Unlock; end; finally ABitmap.Free; end; end;

    Read the article

1