By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

C# .NET adding user defined controls to a form

P: n/a
Liz
In VB.NET I add user defined controls to the main panel
of a form :-

Dim controlInfo As MainTemplate
controlInfo = New Details
controlInfo.Dock = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Controls.Count > 0 Then
pnlMain.Controls.RemoveAt(0)
pnlMain.Controls.Add(controlInfo)
End If

pnlMain.Visible = True

How do I do the same in C# .NET?
Liz
Nov 15 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi Liz,

Here's the C# code. Note that there are lot's of tools out there that will
convert VB.NET code to C# and vice versa.

MainTemplate controlInfo;
controlInfo = new Details();
controlInfo.Dock = DockStyle.Fill;
// remove the old one if one already on display
if (pnlMain.Controls.Count > 0)
{
pnlMain.Controls.RemoveAt(0);
pnlMain.Controls.Add(controlInfo);
}
pnlMain.Visible = true;

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Liz" <ec******@cornwall.gov.uk> wrote in message
news:64****************************@phx.gbl...
In VB.NET I add user defined controls to the main panel
of a form :-

Dim controlInfo As MainTemplate
controlInfo = New Details
controlInfo.Dock = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Controls.Count > 0 Then
pnlMain.Controls.RemoveAt(0)
pnlMain.Controls.Add(controlInfo)
End If

pnlMain.Visible = True

How do I do the same in C# .NET?
Liz

Nov 15 '05 #2

P: n/a
Hi Liz,

In the same way :)

// Now I'm assuming that Details is a subclass of MainTemplate, otherwise
this give you error at compile time
MainTemplate controlInfo = new Details ();
controlInfo.Dock = DockStyle.Fill;
If ( pnlMain.Controls.Count > 0 )
{
pnlMain.Controls.RemoveAt(0);
pnlMain.Controls.Add(controlInfo);
}
pnlMain.Visible = true;

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Liz" <ec******@cornwall.gov.uk> wrote in message
news:64****************************@phx.gbl...
In VB.NET I add user defined controls to the main panel
of a form :-

Dim controlInfo As MainTemplate
controlInfo = New Details
controlInfo.Dock = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Controls.Count > 0 Then
pnlMain.Controls.RemoveAt(0)
pnlMain.Controls.Add(controlInfo)
End If

pnlMain.Visible = True

How do I do the same in C# .NET?
Liz

Nov 15 '05 #3

P: n/a
Liz
Many Thanks - Yes, Details is a subclass of MainTemplate -
It's easy when you know how. I'm having some
difficulties reorganising my thoughts from VB to C#. Liz
-----Original Message-----
Hi Liz,

In the same way :)

// Now I'm assuming that Details is a subclass of MainTemplate, otherwisethis give you error at compile time
MainTemplate controlInfo = new Details ();
controlInfo.Dock = DockStyle.Fill;
If ( pnlMain.Controls.Count > 0 )
{
pnlMain.Controls.RemoveAt(0);
pnlMain.Controls.Add(controlInfo);
}
pnlMain.Visible = true;

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Liz" <ec******@cornwall.gov.uk> wrote in message
news:64****************************@phx.gbl...
In VB.NET I add user defined controls to the main panel
of a form :-

Dim controlInfo As MainTemplate
controlInfo = New Details
controlInfo.Dock = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Controls.Count > 0 Then
pnlMain.Controls.RemoveAt(0)
pnlMain.Controls.Add(controlInfo)
End If

pnlMain.Visible = True

How do I do the same in C# .NET?
Liz

.

Nov 15 '05 #4

P: n/a
Liz
Many Thanks Rob - Can you point me in the direction of
any "free" VB to C# conversion tools? Liz
-----Original Message-----
Hi Liz,

Here's the C# code. Note that there are lot's of tools out there that willconvert VB.NET code to C# and vice versa.

MainTemplate controlInfo;
controlInfo = new Details();
controlInfo.Dock = DockStyle.Fill;
// remove the old one if one already on display
if (pnlMain.Controls.Count > 0)
{
pnlMain.Controls.RemoveAt(0);
pnlMain.Controls.Add(controlInfo);
}
pnlMain.Visible = true;

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Liz" <ec******@cornwall.gov.uk> wrote in message
news:64****************************@phx.gbl...
In VB.NET I add user defined controls to the main panel
of a form :-

Dim controlInfo As MainTemplate
controlInfo = New Details
controlInfo.Dock = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Controls.Count > 0 Then
pnlMain.Controls.RemoveAt(0)
pnlMain.Controls.Add(controlInfo)
End If

pnlMain.Visible = True

How do I do the same in C# .NET?
Liz

.

Nov 15 '05 #5

P: n/a
BH
A few links...

microsoft paper on VB.NET/C# differences:
http://support.microsoft.com/?kbid=308470

translator tools (I think some are free...)
http://www.ellkay.com/ConvertVB2CSharp.htm
http://www.remotesoft.com/octopus/
http://www.codeproject.com/csharp/GBVB.asp
http://www.immunicode.com/products.aspx (VB6 --> C#)

HTH,

BH
"Liz" <ec******@cornwall.gov.uk> wrote in message
news:02****************************@phx.gbl...
Many Thanks Rob - Can you point me in the direction of
any "free" VB to C# conversion tools? Liz
-----Original Message-----
Hi Liz,

Here's the C# code. Note that there are lot's of tools

out there that will
convert VB.NET code to C# and vice versa.

MainTemplate controlInfo;
controlInfo = new Details();
controlInfo.Dock = DockStyle.Fill;
// remove the old one if one already on display
if (pnlMain.Controls.Count > 0)
{
pnlMain.Controls.RemoveAt(0);
pnlMain.Controls.Add(controlInfo);
}
pnlMain.Visible = true;

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Liz" <ec******@cornwall.gov.uk> wrote in message
news:64****************************@phx.gbl...
In VB.NET I add user defined controls to the main panel
of a form :-

Dim controlInfo As MainTemplate
controlInfo = New Details
controlInfo.Dock = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Controls.Count > 0 Then
pnlMain.Controls.RemoveAt(0)
pnlMain.Controls.Add(controlInfo)
End If

pnlMain.Visible = True

How do I do the same in C# .NET?
Liz

.

Nov 15 '05 #6

P: n/a
Liz
Thanks for your patience. I did discover the ellkay link
yesterday and this is free and very useful for converting
small bits of code. I shall have a look at all the other
links now. Thanks again - Liz
-----Original Message-----
A few links...

microsoft paper on VB.NET/C# differences:
http://support.microsoft.com/?kbid=308470

translator tools (I think some are free...)
http://www.ellkay.com/ConvertVB2CSharp.htm
http://www.remotesoft.com/octopus/
http://www.codeproject.com/csharp/GBVB.asp
http://www.immunicode.com/products.aspx (VB6 --> C#)

HTH,

BH
"Liz" <ec******@cornwall.gov.uk> wrote in message
news:02****************************@phx.gbl...
Many Thanks Rob - Can you point me in the direction of
any "free" VB to C# conversion tools? Liz
>-----Original Message-----
>Hi Liz,
>
>Here's the C# code. Note that there are lot's of tools

out there that will
>convert VB.NET code to C# and vice versa.
>
>MainTemplate controlInfo;
>controlInfo = new Details();
>controlInfo.Dock = DockStyle.Fill;
>// remove the old one if one already on display
>if (pnlMain.Controls.Count > 0)
>{
> pnlMain.Controls.RemoveAt(0);
> pnlMain.Controls.Add(controlInfo);
>}
>pnlMain.Visible = true;
>
>--
>Rob Windsor
>G6 Consulting
>Toronto, Canada
>
>
>"Liz" <ec******@cornwall.gov.uk> wrote in message
>news:64****************************@phx.gbl...
>> In VB.NET I add user defined controls to the main panel >> of a form :-
>>
>> Dim controlInfo As MainTemplate
>> controlInfo = New Details
>> controlInfo.Dock = DockStyle.Fill
>> ' remove the old one if one already on display
>> If pnlMain.Controls.Count > 0 Then
>> pnlMain.Controls.RemoveAt(0)
>> pnlMain.Controls.Add(controlInfo)
>> End If
>>
>> pnlMain.Visible = True
>>
>> How do I do the same in C# .NET?
>>
>>
>> Liz
>>
>>
>
>
>.
>

.

Nov 15 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.