Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
hi....
I am stuck while making a "wire like custom control" which can join two radio button (on a form), And able to send the value of first radio button to the next radio button which is joint by that control....
plzz help....
Posted
Comments
Karthik Harve 29-Nov-11 6:24am    
can you give some more explanation about the functionality..??
TNJS82 29-Nov-11 8:10am    
I know it is complicated..
Control that i m taking about is just like a wire or line control in "cisco packet tracer".....
but here it will join two radio button .....
some what like this...

()-------------------()

or

(0)-----------------------(0)
where () represents radio button on form...

in other words...
i have two radio button on my form.. now when i select my custom control from Toolbox..... and click my first radio button and then second....it draw a line from my first radio button to second and make both in same state (on or off).
Oludayo Alli 29-Nov-11 6:53am    
Your question is not clear enough, provide more information so that you can get the needed help
TNJS82 29-Nov-11 8:10am    
I know it is complicated..
Control that i m taking about is just like a wire or line control in "cisco packet tracer".....
but here it will join two radio button .....
some what like this...

()-------------------()

or

(0)-----------------------(0)
where () represents radio button on form...

in other words...
i have two radio button on my form.. now when i select my custom control from Toolbox..... and click my first radio button and then second....it draw a line from my first radio button to second and make both in same state (on or off).

Use this code which I design for you :
VB
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Data
Imports System.Text
Imports System.Windows.Forms
Public Class RadioButtonPair
    Inherits UserControl
    Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
    Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    
    Private Sub InitializeComponent()
        Me.RadioButton1 = New System.Windows.Forms.RadioButton
        Me.RadioButton2 = New System.Windows.Forms.RadioButton
        Me.Label1 = New System.Windows.Forms.Label
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.SuspendLayout()
        '
        'RadioButton1
        '
        Me.RadioButton1.AutoSize = True
        Me.RadioButton1.Location = New System.Drawing.Point(5, 10)
        Me.RadioButton1.Name = "RadioButton1"
        Me.RadioButton1.Size = New System.Drawing.Size(14, 13)
        Me.RadioButton1.TabIndex = 0
        Me.RadioButton1.TabStop = True
        Me.RadioButton1.UseVisualStyleBackColor = True
        '
        'RadioButton2
        '
        Me.RadioButton2.AutoSize = True
        Me.RadioButton2.Location = New System.Drawing.Point(5, 11)
        Me.RadioButton2.Name = "RadioButton2"
        Me.RadioButton2.Size = New System.Drawing.Size(14, 13)
        Me.RadioButton2.TabIndex = 1
        Me.RadioButton2.TabStop = True
        Me.RadioButton2.UseVisualStyleBackColor = True
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(23, 11)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(64, 13)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "-------------------"
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.RadioButton1)
        Me.GroupBox1.Location = New System.Drawing.Point(4, 2)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(22, 27)
        Me.GroupBox1.TabIndex = 3
        Me.GroupBox1.TabStop = False
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.RadioButton2)
        Me.GroupBox2.Location = New System.Drawing.Point(80, 2)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(22, 29)
        Me.GroupBox2.TabIndex = 4
        Me.GroupBox2.TabStop = False
        '
        'RadioButtonPair
        '
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.Label1)
        Me.Name = "RadioButtonPair"
        Me.Size = New System.Drawing.Size(115, 35)
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        Me.GroupBox2.ResumeLayout(False)
        Me.GroupBox2.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

    Public Sub New()
        InitializeComponent()
        AddHandler Me.Click, AddressOf RadioButton_Cecked
        AddHandler Me.Label1.Click, AddressOf RadioButton_Cecked
    End Sub

    Private Sub RadioButton_Cecked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If RadioButton1.Checked = True Then
            RadioButton1.Checked = False
            RadioButton2.Checked = False
        Else
            RadioButton1.Checked = True
            RadioButton2.Checked = True
        End If
    End Sub
End Class

I hope it will help you.If so then give 5Points.
 
Share this answer
 
Comments
TNJS82 29-Nov-11 10:53am    
@Manoj... this is great but limited to only those two radio button what if I add Third and want same functionality for this one too...***
TNJS82 29-Nov-11 10:55am    
Please...... before answering this one...take a look on "cisco packet tracer" Wire Control..... i want my control to Look And Stretch Like That.....but in my Application it Join Two Radio Button.....;-)
Manoj K Bhoir 29-Nov-11 11:03am    
can you give me the link of cisco packet tracer control image?
TNJS82 30-Nov-11 2:09am    
http://aio-rapidshare.info/ebooks/tutorials/3197-packet-tracer-tutorial-916mb.html
there is image... and setup for packet tracer. I want those wire like connection to be made as custom control in .net to connect my two Radio controls...
Manoj K Bhoir 30-Nov-11 5:37am    
It's quite complicated! but i will try for you.
Is this what you mean perhaps?

C#
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
    {
        RadioButton2.Checked = true;
        changeCustomControl();
    }
    protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
    {
        RadioButton1.Checked = true;
        changeCustomControl();
    }

    protected void changeCustomControl()
    {
        //Put code to change the custom control here
    }


Also remember that the GroupName property of the radio buttons has to differ or else they cannot both be checked at the same time.

Hope this helps!
-Erlend
 
Share this answer
 
Comments
TNJS82 29-Nov-11 9:14am    
Thanku 4 sol.....Erlend..
but i want that "Custom control" to be coded.....
Erlend neergaard 29-Nov-11 9:26am    
I see. Not sure if I can help you. If the line does now have to be drawn you could put a hidden label with the text "---------" between the two boxes and make it visible when the radiobutton is pressed:

protected void changeCustomControl()
{
DashLabel.Visible = true;
}
TNJS82 29-Nov-11 10:49am    
sure..Erl.. but what about this.. if I add another radio button in that form......?????
I have to take another label then huhh..!!!
Manoj K Bhoir 29-Nov-11 11:00am    
can you give me the link of cisco packet tracer control image?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900