Subhajit Mahato
Subhajit Mahato

Reputation: 33

Switch between three radio buttons using keyboard shortcuts in vb.net project

I have three radio buttons in my vb.net windows forms application project. Now I want to switch (or toggle) between these three buttons using keyboard shortcuts like Alt+S. Please help.

Upvotes: -2

Views: 336

Answers (1)

OctaCode
OctaCode

Reputation: 645

tested and works, next time please make a bit more effort with your research

on load:

Me.KeyPreview = True

on keydown:

If e.Alt AndAlso e.KeyCode = Keys.S Then
    if RB1.checked = true then
        RB2.checked = true
    elseif RB2.checked = true
        RB3.checked = true
    elseif RB3.checked = true
        RB1.checked = true
    end if
end if

Avoiding RBs check:

on load:

Me.KeyPreview = True
dim vall as integer = 1

on keydown:

If e.Alt AndAlso e.KeyCode = Keys.S Then
    select case vall
        case 1
            RB2.checked = true
            vall = 2
        case 2
            RB3.checked = true
            vall = 3
        case 3
            RB1.checked = true
            vall = 1
    end select
end if

Upvotes: 0

Related Questions