473,830 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# .NET adding user defined controls to a form

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

Dim controlInfo As MainTemplate
controlInfo = New Details
controlInfo.Doc k = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Control s.Count > 0 Then
pnlMain.Control s.RemoveAt(0)
pnlMain.Control s.Add(controlIn fo)
End If

pnlMain.Visible = True

How do I do the same in C# .NET?
Liz
Nov 15 '05 #1
6 3548
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.Doc k = DockStyle.Fill;
// remove the old one if one already on display
if (pnlMain.Contro ls.Count > 0)
{
pnlMain.Control s.RemoveAt(0);
pnlMain.Control s.Add(controlIn fo);
}
pnlMain.Visible = true;

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Liz" <ec******@cornw all.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.Doc k = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Control s.Count > 0 Then
pnlMain.Control s.RemoveAt(0)
pnlMain.Control s.Add(controlIn fo)
End If

pnlMain.Visible = True

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

Nov 15 '05 #2
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.Doc k = DockStyle.Fill;
If ( pnlMain.Control s.Count > 0 )
{
pnlMain.Control s.RemoveAt(0);
pnlMain.Control s.Add(controlIn fo);
}
pnlMain.Visible = true;

Hope this help,

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

"Liz" <ec******@cornw all.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.Doc k = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Control s.Count > 0 Then
pnlMain.Control s.RemoveAt(0)
pnlMain.Control s.Add(controlIn fo)
End If

pnlMain.Visible = True

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

Nov 15 '05 #3
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.Do ck = DockStyle.Fill;
If ( pnlMain.Control s.Count > 0 )
{
pnlMain.Control s.RemoveAt(0);
pnlMain.Control s.Add(controlIn fo);
}
pnlMain.Visibl e = true;

Hope this help,

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

"Liz" <ec******@cornw all.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.Doc k = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Control s.Count > 0 Then
pnlMain.Control s.RemoveAt(0)
pnlMain.Control s.Add(controlIn fo)
End If

pnlMain.Visible = True

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

.

Nov 15 '05 #4
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.Do ck = DockStyle.Fill;
// remove the old one if one already on display
if (pnlMain.Contro ls.Count > 0)
{
pnlMain.Control s.RemoveAt(0);
pnlMain.Control s.Add(controlIn fo);
}
pnlMain.Visibl e = true;

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Liz" <ec******@cornw all.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.Doc k = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Control s.Count > 0 Then
pnlMain.Control s.RemoveAt(0)
pnlMain.Control s.Add(controlIn fo)
End If

pnlMain.Visible = True

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

.

Nov 15 '05 #5
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******@cornw all.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.Do ck = DockStyle.Fill;
// remove the old one if one already on display
if (pnlMain.Contro ls.Count > 0)
{
pnlMain.Control s.RemoveAt(0);
pnlMain.Control s.Add(controlIn fo);
}
pnlMain.Visibl e = true;

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Liz" <ec******@cornw all.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.Doc k = DockStyle.Fill
' remove the old one if one already on display
If pnlMain.Control s.Count > 0 Then
pnlMain.Control s.RemoveAt(0)
pnlMain.Control s.Add(controlIn fo)
End If

pnlMain.Visible = True

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

.

Nov 15 '05 #6
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******@cornw all.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.Do ck = DockStyle.Fill;
>// remove the old one if one already on display
>if (pnlMain.Contro ls.Count > 0)
>{
> pnlMain.Control s.RemoveAt(0);
> pnlMain.Control s.Add(controlIn fo);
>}
>pnlMain.Visibl e = true;
>
>--
>Rob Windsor
>G6 Consulting
>Toronto, Canada
>
>
>"Liz" <ec******@cornw all.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.Doc k = DockStyle.Fill
>> ' remove the old one if one already on display
>> If pnlMain.Control s.Count > 0 Then
>> pnlMain.Control s.RemoveAt(0)
>> pnlMain.Control s.Add(controlIn fo)
>> End If
>>
>> pnlMain.Visible = True
>>
>> How do I do the same in C# .NET?
>>
>>
>> Liz
>>
>>
>
>
>.
>

.

Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3736
by: avivgur | last post by:
Hello, I am writing a program in Visual C# and I have encountered a problem. In my program I want to dynamically create a multitude of controls (thousands) on a form. The problem is that calling the Controls.Add() method several times or even calling the Controls.AddRange() method once can take a huge amount of time. Therefore, I would like to be able to run the loop that creates the controls on a different thread and meanwhile give the user...
2
6809
by: Chien Lau | last post by:
I frequently define internal UserControl-derived classes in my WinForms apps: internal class MyUserControl:UserControl{ ... } I'll often need to embed these controls in a Form, whose class is contained in the same assembly as the control. As far as I know, the only way to do this using the designer is to add the UserControl-derived object
3
4889
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
4
2504
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in the table. I know that I can dynamically add controls (eg a textbox) to the page controls collection of a web form in a server event which will then be rendered onto the form, as in the following snippet: System.Web.UI.WebControls.TextBox...
3
5172
by: John Hughes | last post by:
I'm trying to add a user control to a form via the pages render method and I get the following error : "Control 'Button1' of type 'Button' must be placed inside a form tag with runat=server" The user control has this button on its page. I am outputing the <form runat="server"> inside the render method and have also tried adding it to the page and to the control without any luck. Any help appreciated.
5
1552
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That is, a user goes to the web page, which draws the current content out of the db and inserts into a "preview" area as well as the form itself. User makes changes, hits submit button. The page *should* refresh, with the changes saved to the db, and...
3
1886
by: Jonathan Wood | last post by:
I could really use some help on this. First of all, I want to create a Web control where I render the control completely from scratch based on information from a database. In the book "Beginning ASP.NET 2.0 in C# 2005", it provides an example of doing this, which is declared as: public class ConfigurableRepeater : WebControl.
2
15080
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have been able to find the cause of the problem, and will describe it here first textually and then through a code example. The purpose of what I am trying to do is to create a postback-free web application through the use of ASP.net AJAX UpdatePanels...
5
3188
by: rajdevramasamy | last post by:
Hi, In my webpage, i am adding my user control using rendercontrol() using the following code: Dim NumericEditControl As New Control NumericEditControl = LoadControl("Controls\NumericEdit.ascx") Dim sb As New StringBuilder() Dim sw As New StringWriter(sb) Dim htw As New HtmlTextWriter(sw)
0
9793
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10489
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5617
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.