Possible ? Edit or Start Data from MSStringGrid by clicking?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
olllllliii
Pro Scripter
Posts: 60
Joined: Tue Dec 22, 2009 9:51 am
Location: Mannheim ( Germany )
Contact:

Possible ? Edit or Start Data from MSStringGrid by clicking?

Post by olllllliii » Mon Feb 18, 2013 9:23 am

Is it possible to edit the Data from a Stringgrid...or to
start a specified programm if row number x is clicked.

I want to show a list of logfiles ...and if u click the row the logfile
gets opend.. so i also want to add an comment to the logfile..


Code: Select all

ReadFile>C:\Users\olllllliii\Desktop\Abr\ERP\testlogfile.log,CSVData

Dialog>Dialog3
object Dialog3: TForm
  Left = 247
  Top = 96
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'EB'#220' SHOP Vorgangshilfe'
  ClientHeight = 924
  ClientWidth = 1499
  Color = 12320725
  Font.Charset = ANSI_CHARSET
  Font.Color = clWindowText
  Font.Height = -16
  Font.Name = 'Times New Roman'
  Font.Style = [fsBold]
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 19
  object MSStringGrid1: tMSStringGrid
    Left = 0
    Top = 72
    Width = 1497
    Height = 825
    BevelKind = bkSoft
    BevelOuter = bvRaised
    BevelWidth = 3
    Color = 12910532
    ColCount = 10
    DefaultColWidth = 140
    FixedColor = 13041601
    RowCount = 1
    FixedRows = 0
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -13
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
    TabOrder = 0
  end
  object TEdit
    Left = 8
    Top = 32
    Width = 433
    Height = 27
    TabOrder = 1
  end
  object MSButton1: tMSButton
    Left = 448
    Top = 32
    Width = 108
    Height = 27
    Caption = 'Suchen'
    TabOrder = 2
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 1400
    Top = 5
    Width = 97
    Height = 60
    Caption = 'Beenden'
    TabOrder = 11
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog3

// Add Handler for editing ?
AddDialogHandler>Dialog3,MSStringGrid1,OnClick,editgrid
AddDialogHandler>Dialog3,MSStringGrid1,OnClickROW,startexecute

// Set Dialog
SetDialogProperty>Dialog3,MSStringGrid1,LoadFromCSV,CSVData

// Edit Dialog

Show>Dialog3,dlgResult


SRT>editgrid
    // how can i get the information where the mstringgrid has been 
    // clicked  
END>editgrid

SRT>startexeute
 IF>ROW=40
 
 executefile>........
 ENDIF

END>startexeute

Please help me to get a solution...
Oliver Hilger Mannheim
alias Olllllliii

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 18, 2013 12:35 pm

Look at the OnSetEditText event:

Code: Select all

AddDialogHandler>Dialog1,MSStringGrid1,OnSetEditText,doEdit
Show>Dialog1,r

SRT>doEdit
**BREAKPOINT**  

END>doEdit
Note the doEdit_ACOL and doEdit_AROW values which tell you which cell is being edited.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

olllllliii
Pro Scripter
Posts: 60
Joined: Tue Dec 22, 2009 9:51 am
Location: Mannheim ( Germany )
Contact:

Possible ? Edit or Start Data from MSStringGrid by clicking?

Post by olllllliii » Mon Feb 18, 2013 8:01 pm

Sorry Macrus ,

can u tell me how to get the values or put them to a field
update them ....

i dont know what to do ..



//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1


Dialog>Dialog1
object Dialog1: TForm
Left = -1154
Top = 135
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'CustomDialog'
ClientHeight = 212
ClientWidth = 476
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = True
ShowHint = True
OnTaskBar = False
PixelsPerInch = 96
TextHeight = 13
object MSStringGrid1: tMSStringGrid
Left = 16
Top = 14
Width = 320
Height = 120
ColCount = 3
RowCount = 1
FixedRows = 0
TabOrder = 8
end
end
EndDialog>Dialog1


/*
CSVDataLabel:
Shape,Colour,Size
Triangle,Red,Large
Square,Blue,Small
Oval,Yellow,Medium
*/

LabelToVar>CSVDataLabel,CSVData

SetDialogProperty>Dialog1,MSStringGrid1,LoadFromCSV,CSVData

AddDialogHandler>Dialog1,MSStringGrid1,OnSetEditText,doEdit

Show>Dialog1,r

SRT>doEdit
// i really dont know how to set a value or
// get the grid able to edit can u make an example please :-)

// doEdit_ACOL and doEdit_AROW values ( how did i get them ? how can i // put them )

Let>reihe=doedit_ACOL ??
GetDialogProperty>Dialog1,MSStringGrid1,??,??

SetDialogProperty>Dialog1,MSStringGrid1,??,??

END>doEdit
Oliver Hilger Mannheim
alias Olllllliii

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Feb 19, 2013 5:30 am

This was a fun learning experience.
olllllliii wrote:Is it possible to edit the Data from a Stringgrid
To be able to edit a cell you must add "goEditing" to the StringGrid "Options" property.
olllllliii wrote:or to start a specified programm if row number x is clicked.
If you use the "OnSelectCell" StringGrid event, you will get the row and column values for the cell picked in the "DoEdit_Arow" and "DoEdit_Acol" variables. Note these locations are zero based.

If you click a cell the OnSelectCell event will be invoked. If you double click a cell you can edit that cell.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 649
  Top = 249
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 212
  ClientWidth = 476
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 72
    Top = 152
    Width = 32
    Height = 13
    Caption = 'Cell Data'
  end
  object MSStringGrid1: tMSStringGrid
    Left = 16
    Top = 14
    Width = 320
    Height = 120
    ColCount = 3
    FixedCols = 0
    RowCount = 3
    FixedRows = 0
    Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing]
    TabOrder = 0
  end
end
EndDialog>Dialog1
/*
CSVDataLabel:
Shape,Colour,Size
Triangle,Red,Large
Square,Blue,Small
Oval,Yellow,Medium
*/
LabelToVar>CSVDataLabel,CSVData
SetDialogProperty>Dialog1,MSStringGrid1,LoadFromCSV,CSVData
AddDialogHandler>Dialog1,MSStringGrid1,OnSelectCell,doEdit
Let>CellVal=
Let>comma=,
Show>Dialog1,r
SRT>doEdit

//**BREAKPOINT**
GetDialogProperty>Dialog1,MSStringGrid1,SaveToCSV,CSVSave
Separate>CSVSave,crlf,vRow
Let>ChosenRow=%DoEdit_Arow%+1
Let>CsvRow=vRow_%ChosenRow%
Separate>CSVRow,comma,vCell
Let>ChosenCol=%DoEdit_Acol%+1
Let>CellVal=vCell_%ChosenCol%

SetDialogProperty>Dialog1,Label1,Caption,Row = %DoEdit_Arow%, Column = %DoEdit_Acol%, Value = %CellVal%
END>doEdit


olllllliii
Pro Scripter
Posts: 60
Joined: Tue Dec 22, 2009 9:51 am
Location: Mannheim ( Germany )
Contact:

Post by olllllliii » Tue Feb 19, 2013 7:04 am

Super !! Thank you JRL...now i know how to use a gridmask...!!!

Thank you JRL !
Oliver Hilger Mannheim
alias Olllllliii

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts