VB.Net noob

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

VB.Net noob

Post by agibsonsw »

Hello.
I have extensive experience with VBA and need to get to grips with VB.Net. I've a couple of huge books(!) but to get me started with Windows Forms I just need to re-produce (or find the alternative(s) for) features that I'm familiar with from VBA and Access forms. Brief pointers on the following questions would help me a lot:

1) With a 'CheckedListBox' it requires two ticks to select a checkbox. Is this the expected behaviour or is their a piece of code I can add to make it check the box immediately?
2) Is there a way to associate a label with a textbox? That is, to add a label at the same time as a textbox, and move them together? (I can temporarily group them by lasso-ing them but I can't see an option to "group" them more permanently.)
3) How can I programmatically add items to a combo-box? A form has a load event, which I assume is equivalent to the former VBA/Form 'Initialize' event(?), but the combo-box doesn't have an 'AddItem' method, or similar, that I can see?

Andy.

Edited: For question 3) I've just discovered that I can use 'Items.Add("Something")' :cheers: . Is the form-load event the recommended/correct event to do this?
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VB.Net noob

Post by HansV »

The On Load event of a form is indeed the way to populate controls that aren't bound to a data source.
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: VB.Net noob

Post by agibsonsw »

HansV wrote:The On Load event of a form is indeed the way to populate controls that aren't bound to a data source.
Thank you Hans. I'm applying some 'MIcrosoft logic' to my questions:

1) I'm figuring that having to click the 'CheckedListBox' twice is the default/peculiar behaviour - otherwise we would always have to add code to alter its behaviour. I'm gathering that there a quite a number of such odd behaviours :laugh: in VB.Net.
2) I see that there is a 'Panel' control that I could use to group controls: not quite as simple as lasso-ing them and choosing a 'Group' option, but no biggie.
3) List and combo-box controls have both SelectedIndexChanged and SelectedValueChanged events which, as far as I can see, serve the same purpose. I'll just use the default 'Index' version (even though it happens after the 'value' version).

BTW Bit of a monster this VB.Net! In particular, there are far too many events. Think I'm going to ignore 90% of what's available :laugh: and continue to reproduce features/behaviour from VBA. But I've studied Classes/OOP (a bit) with C# and other languages, so this should ease my path a bit for this topic. It will take getting used to strings and dates "as objects" though..
The most complicated topics seem to be Generics, ADO.Net and (of course) the .Net Framework - but I don't need to know too much about these just yet! (Well, WPF and XAML are also huge topics but, again, I don't need these yet.)

Sorry to bore - just thinking out loud! Wish me luck. Regards, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.