New to Gambas.. seek some help
Posted
#1
(In Topic #1184)
Trainee
1. Which controls allow multi-column display of data (listbox / listview)?
2. How to make spinbox to accept decimal places?
3. How to configure valuebox to accept / not-accept decimal places?
4. How to set fixed (0, 2 or 3) decimal places in those controls?
5. Which database systems are supported?
Posted
Guru

Mudassir said
Hello, I am new to Gambas.. recently switched to Linux and trying to switch to some native platform for coding. Please assist a little. Thank you!
1. Which controls allow multi-column display of data (listbox / listview)?
2. How to make spinbox to accept decimal places?
3. How to configure valuebox to accept / not-accept decimal places?
4. How to set fixed (0, 2 or 3) decimal places in those controls?
5. Which database systems are supported?
1. Probably GridView is what you want.
/comp/gb.qt4/gridview - Gambas Documentation
2. you cannot , spinbox is integer not float.
/comp/gb.qt4/spinbox - Gambas Documentation
3. With valuebox set it's Type property to the format you want then setting the Value property should be automatic displayed.
/comp/gb.form/valuebox - Gambas Documentation
4. no idea
5. gb.db info is specified here /comp/gb.db - Gambas Documentation
Please have a good read of the gambas wiki / - Gambas Documentation
Most of the questions you have asked (except maybe number 4) have answers there in much more detail.
Posted
Regular

The "usual" way of doing a decimal spinbox is to multiply the value by 10^number of decimal points. This is a visual pain for the user but it's the best I could ever come up with.
b
Posted
Regular

Posted
Regular

…:?…probably by using Format() function:Mudassir said
4. How to set fixed (0, 2 or 3) decimal places in those controls?
/lang/format - Gambas Documentation
/cat/userformat - Gambas Documentation
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Guru

I agree with vuott regarding the number formatting, use Format. Run the following code in a Graphical application:-4. How to set fixed (0, 2 or 3) decimal places in those controls?
Code (gambas)
- Spring1 As Spring
- .Arrangement = Arrange.Vertical
- .Padding = 5
- .W = 250
- .H = 100
- .H = 28
- .Placeholder = "Enter any number below"
- .H = 28
- .Alignment = Align.Center
Here I agree with BruceSteers try GridView. Have a look at BarcodeCreator that's on the Gambas Software Farm.1. Which controls allow multi-column display of data (listbox / listview)?
<IMG src="https://www.cogier.com/gambas/Gridview3.png">
</IMG>
Posted
Trainee
About the queries:
1. Using Round() Function is a trick, not a solution.
2. Spin Box can accept decimal places (just a bit of work is required).
3. I seek support for largely used database systems (in the past too), not just SQLite. See, dBase,FoxPro, Visual FoxPro tables are still in use and people want to port them.
4. A Value Box is what I like most in GAMBAS controls but it need be capable to accept float values.
5. ListView control must also support multi-column data, I am sure (though I have not checked yet), there must be some confusion.
Posted
Trainee
Sorry vuott, that's just a trick. It's about numeric input not formatted text.vuott said
probably by using Format() function:
Posted
Trainee
Well, IDK anything about GAMBAS and my VB skills are rusted as I'm primarily working with VFP for dekstop apps but still this may do the trick after setting type to number:BruceSteers said
Q. How to configure valuebox to accept / not-accept decimal places?
3. With valuebox set it's Type property to the format you want then setting the Value property should be automatic displayed.
Code (gambas)
- ' Frac will return the number in digits like 0.xxxx
- ' Assuming to accept only 2 decimal places we would add 4 here two digits for 0. and two digits for decimal places
- ' Using round would round off the value like 2.256 would be 2.26
1. Add property decimal_places as Integer
2. control.decimal_places=2
and call control.decimal_places from above procedure, replacing 4 with 2+control.decimal_places
Also if only integer is required in Value Box input then:
Posted
Guru

You will find all the gambas controls have their "default" behavior , to make them go beyond that you will need to employ some kind of "trick" or other.
With gambas there are many many tricks you can do to modify controls to work as you require.
Seems you have your own ideas on how it "should" be done so i do not think I have any advice except have fun experimenting
Posted
Trainee
BruceSteers said
I only know good tricks
Would love to see those good tricks please.
That was just a quick solution I could think of with anything I could remember about 'basic'.
Posted
Regular

No… I didn't understand.Mudassir said
that's just a trick. It's about numeric input not formatted text.
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Trainee
Sorry, let me explain… Suppose, I want to use Value Box to get user input for:vuott said
No… I didn't understand.Mudassir said
that's just a trick. It's about numeric input not formatted text.
1. Rate of unit, there user should only enter value with 2 decimal places, not 3 or 4. like.. 2.25, not 2.258
2. Quantity (Decimal places depends on unit, like for units sold in pieces there would be no decimal places, for unit sold in meters there should be 2 decimal places and for units sold in kgs will have 3 decimal places. And we must not let user enter decimal value for pieces… there should not be 3 decimal places for units sold in meters. and likewise not 4 decimal places for units sold in kgs.
How to control user input when he/she is typing.. not on lost focus.
Posted
Guru

There is a ValueBox_KeyPress() event
Processing can be done there.
Change happens after a user types something and if needs be you can modify the Value and change it.
KeyPress happens before the key is accepted by the control and if you Stop Event it will not enter the press.
Stop Event will stop an event working normally and override it's behaviour.
For example..
I'm not exactly sure what you're doing but you can intercept and stop many internal control events
Right click a control in the IDE and see the available events listed in the events menu.
It's not too hard to make your own valuebox with a textbox and use the KeyPress event to completely control it's display manually.
That's essentially all a ValueBox is.
Posted
Enthusiast

1 guest and 0 members have just viewed this.


