Grid control how-to

Started by honkinberry, June 23, 2010, 10:25:16 AM

Previous topic - Next topic

honkinberry

I'm struggling through getting my first Grid control working.
I was hoping to find a simple Tutorial.

I've got a Grid on a form, intended to be only a single row.
My form OnInitialize is firing, now I just need to know what else is required.

Should I use AddRow to pad the grid data?  AddString?  SetCellText?
When are the LabelEdit functions required?

Is there way to DataSource a grid to an AutoLISP list?

All my questions for now.  Thanks for any assistance!

--J

owenwengerd

The main steps are adding columns (which you can do either at design time in studio or at runtime), then adding row(s). There are different ways to do both, so use whatever works for you.

honkinberry

Is the first column always read-only?
As a workaround, I have set column 0 to 0px wide.

I've got my columns added with addcolumns, then addrow to throw in the data, finally SetCellStyle for each cell (gotta be sure to do that *after* the addrow call).

I have all cells as ComboDropDowns, which brings additional challenges.
Users have requested a sort of auto-complete, so they can just start typing a few of the characters from the list.  *shaking first at Google for making everything so easy*

--J

owenwengerd

Change the Row Header property to false if you want column 0 cells to be editable. The auto-complete should kinda sorta work if the combo list contains the items, but you're certainly limited in how you can change that behavior since there are no further events fired until editing is complete.

honkinberry

I'm not having any luck with that first column.
Row Header is set to False in the Editor.  Yet when I add rows and columns at runtime, even if I reset the property to False, column 0 is still read-only.  Note that all cells are combo-boxes.
Other issues with editing values in a grid of all Comboboxes:  Tab doesn't move to the next cell; when entering a new value into the cell, user must click on another cell on the grid, which then fires EndLabelEdit -- if user just clicks the form's OK button, or anywhere else on form, EndLabelEdit does not fire, and the new value is not saved.  So it seems the code that checks cell value against dropdown list, adding as necessary, should be moved to KeyUp?

Should I repost in Runtime with sample code, or add it here?

thanks for any help!

--J

owenwengerd

Yes, please post sample code in Runtime.