Re: Grid Control: getting original checkbox state
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Feb 10, 2003
- 491 views
Hi Phil, Well, that's close but not exactly what I meant; refer to the demo following this (& if it's a poor way to do what I'm trying to do, by all means make corrections!). Consider when a Grid Control is created: it shows up as a rectangle of x-y dimensions, even though it could be *empty* to begin with. Then add *one* row of data: the row shows up, but inside an otherwise *empty* rectangle. If you then add additional rows of data, eventually it will have to vertically scroll, which it does. What I am suggesting is that when it *originally* shows, if it has no data, just the top legends should (optionally) show; then, if *one* row is added, *just that row* would show under the legends, *not* the whole empty grid rectangle. And then, as now, when enough rows are added so there's not enough space for them, scroll bars obtain. Dan Moyer <code follows:> -- code generated by Win32Lib IDE v0.14.2 include Win32lib.ew without warning ---------------------------------------------------------------------------- ---- -- Window Window1 constant Window1 = createEx( Window, "Grid Control with CheckBoxes", 0, Default, Default, 600, 300, 0, 0 ) constant PushButton2 = createEx( PushButton, "Select File", Window1, 484, 20, 88, 28, 0, 0 ) constant PushButton3 = createEx( PushButton, "Process Data", Window1, 484, 72, 88, 28, 0, 0 ) --------------------------------------------------------- ---------------------------------------------------------------------------- ---- include eugrid.ew atom void integer aGrid, colFileName, colCB1, colCB2, colFileDir -- Create grid, create parms=(parent, x, y, width, height, show_window) aGrid = EGW_CreateGrid( Window1, 10, 15, 450, 200, True ) -- no row header void = EGW_SetGridProperty( aGrid, EGW_ROW_HEADER_WIDTH, 0) -- Filename column - static text, left-aligned by default colFileName = EGW_AddColumn( aGrid, "FileName", 200, EGW_LAST, EGW_STATIC, 1 ) void = EGW_SetColumnProperty(aGrid, colFileName, EGW_COL_ALIGN, EGW_CENTER) --void = EGW_SetColumnProperty( aGrid, colFileName, EGW_COL_WIDTH, 75 ) -- checkbox columns: colCB1 = EGW_AddColumn(aGrid, "Action1", 100, EGW_LAST, EGW_CHECKBOX, 2 ) void = EGW_SetColumnProperty(aGrid, colCB1, EGW_COL_ALIGN, EGW_CENTER) colCB2 = EGW_AddColumn(aGrid, "Action2", 100, EGW_LAST, EGW_CHECKBOX, 3 ) void = EGW_SetColumnProperty(aGrid, colCB2, EGW_COL_ALIGN, EGW_CENTER) -- file directory column: colFileDir = EGW_AddColumn( aGrid, "FileDirectory", 400, EGW_LAST, EGW_STATIC, 4 ) void = EGW_SetColumnProperty(aGrid, colFileDir, EGW_COL_ALIGN, EGW_CENTER) ---------------------------------------------------------------------------- ---- procedure PushButton2_onClick (integer self, integer event, sequence params)--params is () seq fName, dirName, fullPathName, temp seq newRow int row, posBS -- posBS is position of back-slash in file name temp = {} -- get a file name fName = getOpenFileName( Window1, current_dir() & "\\", "" ) -- entered a file name? if length( fName ) = 0 then return end if -- separate filename from dirName: if find('\\',fName) then -- found back-slash -- work from end, remove chars after last back-slash: for n = length(fName) to 1 by -1do if not equal('\\',fName[n]) then temp = prepend(temp,fName[n]) else posBS = n exit end if end for fullPathName = fName dirName = fName[1..posBS -1] fName = temp else dirName = "" end if newRow = {fName,1,1,dirName } -- example relating to adding new row: --global constant EmptyGridRow = {"", 2, "", "", 0, True} -- Add new row to grid: row = EGW_AddDataRow(aGrid, newRow, EGW_LAST) void = EGW_SetDataRowFlag(aGrid, row, EGW_ROW_NEW, True) -- Go to it? -- void = EGW_ScrollToCell(aGrid, EGW_LAST, colFileName) repaintWindow(Window1) end procedure setHandler( PushButton2, w32HClick, routine_id("PushButton2_onClick")) ---------------------------------------------------------------------------- ---- procedure PushButton3_onClick (integer self, integer event, sequence params)--params is () object result atom numOfRows numOfRows = EGW_GetRowCount ( aGrid ) for n = 1 to numOfRows do result = EGW_GetDataCellValue ( aGrid, n, 2 ) puts(1, sprint(result)) result = EGW_GetDataCellValue ( aGrid, n, 3 ) puts(1, sprint(result)) puts(1, "\n") end for end procedure setHandler( PushButton3, w32HClick, routine_id("PushButton3_onClick")) WinMain( Window1,Normal ) ----- Original Message ----- From: "Phil Russell" <pg_russell at lineone.net> To: "EUforum" <EUforum at topica.com> Sent: Monday, February 10, 2003 7:20 AM Subject: RE: Grid Control: getting original checkbox state > > Hi Dan, > > The scrollbars in EuGrid only appear when the number of rows or width of > visible columns exceed the size of the window. In that sense the > vertical scrollbar should act in a similar way to a listbox. If you > size the columns so that they all fit in the window size then you won't > get a horizontal scrollbar either. > > To make it look even more like a listbox you would need to: > > - hide the row header > - make the grid background colour the same as the row background colour > - make the grid line colour the same as the grid background colour. > > Is that what you meant? I can send you an example if you like... > > Regards, > > Phil > Dan Moyer wrote: > > Phil, > > > > It does take some getting used to, but it's a very nice looking & > > functioning control! > > > > Here's a suggestion: > > Since I'm trying to use it essentially like a ListView with checkboxes, > > I > > wonder if it could be made to have an option to behave even more like a > > list, such that instead of initially showing its whole innate height, it > > would only show however many rows it has been given, up to its innate > > height, and then begin to scroll when the number (or space) of rows > > exceeds > > the space provided by its height? > > > > Dan Moyer > > > > > > ----- Original Message ----- > > From: "Phil Russell" <pg_russell at lineone.net> > > To: "EUforum" <EUforum at topica.com> > > Sent: Monday, February 10, 2003 2:10 AM > > Subject: RE: Grid Control: getting original checkbox state > > > > > > > Hi Dan, > > > > > > Sorry to be so long in getting back to you, but at least Jonas replied > > > and he probably knows as much about using EuGrid as anybody! > > > > > > Just to confirm what you have discovered through (painful?) experience: > > > > > > - If you allocate more than one visible column to the same column in the > > > underlying dataset then if the data in one of the visible columns is > > > changed then they will all be updated at the same time. > > > > > > - At the moment, checkbox values are only able to cope with values of > > > True or False. Any data value that is not 'False' is assumed to be True > > > - this includes a null sequence "". If you modify a checkbox by > > > clicking on it then the underlying data will always be converted to a > > > True/False value i.e. you will lose the original underlying data if it > > > was not a boolean value. > > > > > > - As Jonas and others have found, occasionally the grid does not > > > automatically repaint itself and it is necessary to issue a > > > repaintWindow call. This was actually deliberate so that it would be > > > possible to change lots of screen elements in one go without causing a > > > load of repaints and screen flicker. However I have been toying with > > > the idea of having a grid property of 'automatic redraw' which would > > > make sure that the grid was always repainted - this could be useful for > > > small grids & during development. > > > > > > Please keep posting your questions & comments. For one thing it is the > > > only feedback that I get & for another it is nice to know that the > > > control is actually being used! I am still developing it (albeit slowl y > > > at the moment) and any suggestions and/or bug reports are very welcome. > > > > > > Regards, > > > > > > Phil > > > > > > Dan Moyer wrote: > > > > Double sigh & nevermind! I gotta think first before I ask questions! > > > > Seems > > > > if I put a "1" in my newRow sequence where checkboxes go, it then allows > > > > correct interrogation of original checkbox state: > > > > newRow = {fName,1,1,dirName } > > > > > > > > Should'a tried *something* before asking, since I *did* have a clue. > > > > > > > > Dan Moyer > > > > > > > > > > > TOPICA - Start your own email discussion group. FREE! > > > > > > > > TOPICA - Start your own email discussion group. FREE! >