|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Dynamic Controls / Grid?Hello,
I would like to be able to create a Label, a Textbox and a Checkbox for a variable number of records. I'm not dealing with a database, I'm dealing with search results. So, if I find 3 search results, I would like to create a Label, a Textbox and a Checkbox for each search result like so: Search Results: Result Change To: Change? ----------------------------------- Foo FOOFOO X Bar BARBAR X Baz Go! What is a good way of creating these dynamic controls, as well as arranging them so that they appear like in the example above? I'm playing around with the HPanel, VPanel, HBox and VBox, and will post my results if I find something that works. I would use a grid, except that I want to have a Checkbox in the 3rd column. Is there any way to place a checkbox in a Grid? Thanks, --Nate |
|
|
Re: Dynamic Controls / Grid?Here's an update:
I can only get one new dynamic control to show up when I add controls to a VPanel in my code. Here's my code (Inside a button_Click event), and I have a VPanel called "vpResults" DIM cb AS NEW CheckBox(vpResults) cb.Show The first checkbox shows up, but new checkboxes are just piled on top of the old one. I suppose I need to call some sort of "Refresh" or "Resize" on the VPanel, but nothing I've tried works. Thanks, --Nate
|
|
|
Re: Dynamic Controls / Grid?Do you really mean (3) objects for each search result?
In case you do, You can do it like this. Put the results in an array then run trhough the array creating the stuff like this PUBLIC SUB DYNAMIC_OBJECTS() DIM sResults as string '(this is the raw list of results) DIM sRes as string[] DIM i as integer DIM sResult as string '(Single result) in the array DIM txtBox as textbox DIM tTextLabel as TextLabel dim cbCheck as Checkbox 'We will assume you are separating your l ist with a space sRes = split(sResults, " ") FOR i = 0 to sRes.count - 1 txtBox = new textbox(YourParentHere) tTextlabel = new textlabel(YourParentHere) cbCheck = new checkbox(YourParentHere) NEXT END Of couse, you'll have to set the properties for each of these objects after you create them... This code may not work out of the box, but it should give you an idea of how to do this On 6/26/08, Nate-37 <Nathan.Neff@...> wrote: > > Hello, > > I would like to be able to create a Label, a Textbox and a Checkbox for a > variable number of records. > > I'm not dealing with a database, I'm dealing with search results. > > So, if I find 3 search results, I would like to create a Label, a Textbox > and a Checkbox for each search result like so: > > > Search Results: > > Result Change To: Change? > ----------------------------------- > Foo FOOFOO X > Bar BARBAR X > Baz > > > Go! > > What is a good way of creating these dynamic controls, as well as arranging > them so that they appear like in the example above? > > I'm playing around with the HPanel, VPanel, HBox and VBox, and will post my > results if I find something that works. I would use a grid, except that I > want to have a Checkbox in the 3rd column. Is there any way to place a > checkbox in a Grid? > > Thanks, > --Nate > -- > View this message in context: http://www.nabble.com/Dynamic-Controls---Grid--tp18140539p18140539.html > Sent from the gambas-user mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > Gambas-user mailing list > Gambas-user@... > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Dynamic Controls / Grid?> Do you really mean (3) objects for each search result?
Yes, I need 3 objects for each result. My problem is not with creating the objects, it's being able to view them. I would like an easy way to make the objects visible. Currently I can only see the first checkbox that's created. The others then pile up on top of the first one. I can dabble with their top, bottom, left right properties, but that sounds like more work than what's needed. I found a demo in the "Beginner's Guide to Gambas" where it shows how the VPanel, HPanel, HBox and VBox will **automatically** arrange their child controls when the application starts. The beginner's guide is here: http://vectorlinux.osuosl.org/Uelsk8s/gambas-beginner-guide.pdf Is there some method that I can call, like VPanel.Arrange() that would do the same thing? I've tried several of the methods already, and can't get them to reveal the other checkboxes. Thanks, --Nate
|
|
|
Re: Dynamic Controls / Grid?Ah!... then whad you need my friend is a way to determine each
components width and move the rest of them accordingly Take a look at this function that I have written and use a lot. PUBLIC SUB get_object_width(sText AS String) AS Integer DIM iRetVal AS Integer DIM fvirtfrm AS Form DIM datemp AS DrawingArea fvirtfrm = NEW Form WITH fvirtfrm .Width = 300 .Height = 200 END WITH datemp = NEW DrawingArea(fvirtfrm) Draw.Begin(datemp) iRetVal = Draw.RichTextWidth(sText) Draw.End RETURN iRetVal END This will draw (but not display) an object, and give necessary .width property to display the .text property on the object. If you can figure out exactly how wide each object needs to be, then you can set the right .X property for each object and keep them from overlaping you use it like this Textbox1.Width = get_object_width(Textbox1.text) Textlabel1.Width = get_object_width(Textlabel1.text) Checkbox1.Width = get_object_width(checkbox1.text) + 24 ' Add extra space for your square box on this one Then, you arrange your objects like this textlabel1.move(textbox1.left + (textbox1.width + 4), textbox1.top) ' leave a 4 pixel space between them checkbox1.move(textlabel1.left + (textlabel1.width + 4), textlabel1.top) On 6/26/08, Nate-37 <Nathan.Neff@...> wrote: > > > Do you really mean (3) objects for each search result? > > > Yes, I need 3 objects for each result. My problem is not with creating the > objects, it's being able to view them. > > I would like an easy way to make the objects visible. Currently I can only > see the first checkbox that's created. The others then pile up on top of > the first one. I can dabble with their top, bottom, left right properties, > but that sounds like more work than what's needed. > > I found a demo in the "Beginner's Guide to Gambas" where it shows how the > VPanel, HPanel, HBox and VBox will **automatically** arrange their child > controls when the application starts. The beginner's guide is here: > http://vectorlinux.osuosl.org/Uelsk8s/gambas-beginner-guide.pdf > > Is there some method that I can call, like VPanel.Arrange() that would do > the same thing? I've tried several of the methods already, and can't get > them to reveal the other checkboxes. > > Thanks, > > --Nate > > > > M0E Lnx wrote: > > > > Do you really mean (3) objects for each search result? > > > > In case you do, You can do it like this. > > Put the results in an array > > then run trhough the array creating the stuff > > > > like this > > PUBLIC SUB DYNAMIC_OBJECTS() > > DIM sResults as string '(this is the raw list of results) > > DIM sRes as string[] > > DIM i as integer > > DIM sResult as string '(Single result) in the array > > > > DIM txtBox as textbox > > DIM tTextLabel as TextLabel > > dim cbCheck as Checkbox > > > > > > > > 'We will assume you are separating your l ist with a space > > > > sRes = split(sResults, " ") > > FOR i = 0 to sRes.count - 1 > > txtBox = new textbox(YourParentHere) > > tTextlabel = new textlabel(YourParentHere) > > cbCheck = new checkbox(YourParentHere) > > > > NEXT > > > > END > > > > Of couse, you'll have to set the properties for each of these objects > > after you create them... > > This code may not work out of the box, but it should give you an idea > > of how to do this > > > > > > > > > > On 6/26/08, Nate-37 <Nathan.Neff@...> wrote: > >> > >> Hello, > >> > >> I would like to be able to create a Label, a Textbox and a Checkbox for > >> a > >> variable number of records. > >> > >> I'm not dealing with a database, I'm dealing with search results. > >> > >> So, if I find 3 search results, I would like to create a Label, a > >> Textbox > >> and a Checkbox for each search result like so: > >> > >> > >> Search Results: > >> > >> Result Change To: Change? > >> ----------------------------------- > >> Foo FOOFOO X > >> Bar BARBAR X > >> Baz > >> > >> > >> Go! > >> > >> What is a good way of creating these dynamic controls, as well as > >> arranging > >> them so that they appear like in the example above? > >> > >> I'm playing around with the HPanel, VPanel, HBox and VBox, and will post > >> my > >> results if I find something that works. I would use a grid, except that > >> I > >> want to have a Checkbox in the 3rd column. Is there any way to place a > >> checkbox in a Grid? > >> > >> Thanks, > >> --Nate > >> -- > >> View this message in context: > >> http://www.nabble.com/Dynamic-Controls---Grid--tp18140539p18140539.html > >> Sent from the gambas-user mailing list archive at Nabble.com. > >> > >> > >> > >> ------------------------------------------------------------------------- > >> Check out the new SourceForge.net Marketplace. > >> It's the best place to buy or sell services for > >> just about anything Open Source. > >> http://sourceforge.net/services/buy/index.php > >> _______________________________________________ > >> Gambas-user mailing list > >> Gambas-user@... > >> https://lists.sourceforge.net/lists/listinfo/gambas-user > >> > > > > ------------------------------------------------------------------------- > > Check out the new SourceForge.net Marketplace. > > It's the best place to buy or sell services for > > just about anything Open Source. > > http://sourceforge.net/services/buy/index.php > > _______________________________________________ > > Gambas-user mailing list > > Gambas-user@... > > https://lists.sourceforge.net/lists/listinfo/gambas-user > > > > > > > -- > View this message in context: http://www.nabble.com/Dynamic-Controls---Grid--tp18140539p18142380.html > > Sent from the gambas-user mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > Gambas-user mailing list > Gambas-user@... > https://lists.sourceforge.net/lists/listinfo/gambas-user > ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Dynamic Controls / Grid?Thanks Moe, I'll definitely take a look at the function you listed below.
I still wonder what function/code is called for VPanels, HPanels, etc. when they arrange their controls auto-magically. I would like to see if there's anyone else that knows what magical code is called when a form starts up that will line up controls. In the Gambas beginner's guide, there's a tutorial that sets up controls like this in a VPanel: VPanel text1 text2 text3 And when you start the program, the controls are like this: text1 text2 text3 I would like to try calling the same code that lines up those controls on my own VPanels, after I've added some more controls to them. But in the meantime, I will definitely try your suggestions. Thank you very much, --Nate
|
| Free Forum Powered by Nabble | Forum Help |