473,545 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

classes

hi all,

I have a usercontrol with a checked listbox

this usercontrol is placed on a form1

is there a way to get the checked items of the checkedlisbox in the
usercontrol with a command from form1?

i beleave i have to do this with "get" and "set in a class

i've never worked with classes before

the way to get the items from the listbox is the code below.

thanks Maarten.

public void getchecked()

{

for (int x = 0; x <= (lstChannels.It ems.Count-1); x++)

{

if (lstChannels.Ge tItemChecked(x) )

{

}
else

{

}

}
Nov 16 '05 #1
5 1264
Maarten wrote:
hi all,

I have a usercontrol with a checked listbox

this usercontrol is placed on a form1

is there a way to get the checked items of the checkedlisbox in the
usercontrol with a command from form1?

i beleave i have to do this with "get" and "set in a class

i've never worked with classes before

the way to get the items from the listbox is the code below.

thanks Maarten.

public void getchecked()

{

for (int x = 0; x <= (lstChannels.It ems.Count-1); x++)

Note: a usual way to write the mid-part is:
x < lstChannels.Ite ms.Count
("<" instead of "<=" and no "-1")
{

if (lstChannels.Ge tItemChecked(x) )
do you mean "lstChannels.It ems[x].Checked" ?

{

}
else

{

}

}


You want to access values from the UserControl from within the
containing aspx page (if I understand correctly).
Usually (meaning: the way I write them :-) ) an ascx is self-contained:
all processing is done internally, a surrounding control or page
does not need to know anything about it.

When you add a textbox to a page (or ascx), you get a declaration
in the codebehind. This is not done automatically for ascx'es,
so you have to add it yourself.
After that you can access any properties within that control,
IF the access modifiers are set correctly ("public").

--
Hans Kesting
Nov 16 '05 #2
Hi Hans,

thanks for the reply

i have some public functions in that usercontrole, and i have been able to
call them from the main form1
with:
usercontrol1.ge tchecked();

but this isn't realy the problem.

i was wondering if i can put this getcheched void in a class, so i can
rertieve the data (in this case the checked itmes) of that class with
something like "get" and "set" (ive seen some exaples with this code).

i'm asking this question rather because i'm trying to understand classes
more than actualy
let let this whole thing work.

i've been looking for a long time on the net trying to understand, but i
just wont get it.

Can you please post a simple example.

kind regards Maarten
"Hans Kesting" <ne***********@ spamgourmet.com > schreef in bericht
news:%2******** **********@TK2M SFTNGP15.phx.gb l...
Maarten wrote:
hi all,

I have a usercontrol with a checked listbox

this usercontrol is placed on a form1

is there a way to get the checked items of the checkedlisbox in the
usercontrol with a command from form1?

i beleave i have to do this with "get" and "set in a class

i've never worked with classes before

the way to get the items from the listbox is the code below.

thanks Maarten.

public void getchecked()

{

for (int x = 0; x <= (lstChannels.It ems.Count-1); x++)


Note: a usual way to write the mid-part is:
x < lstChannels.Ite ms.Count
("<" instead of "<=" and no "-1")
{

if (lstChannels.Ge tItemChecked(x) )


do you mean "lstChannels.It ems[x].Checked" ?

{

}
else

{

}

}


You want to access values from the UserControl from within the containing
aspx page (if I understand correctly).
Usually (meaning: the way I write them :-) ) an ascx is self-contained:
all processing is done internally, a surrounding control or page
does not need to know anything about it.

When you add a textbox to a page (or ascx), you get a declaration
in the codebehind. This is not done automatically for ascx'es,
so you have to add it yourself.
After that you can access any properties within that control,
IF the access modifiers are set correctly ("public").

--
Hans Kesting

Nov 16 '05 #3
I think what you want is to expose the Items property of the listbox. Inside
your usercontrol class you could do something like
public virtual ListItemCollect ion Items
{
get{ return listBox.Items; }
}
(I am not sure about the type of the items collection?)

If you want them to be editable in the designer, you could attributes like

[Description("Ge ts the collection of items displayed in the list."),
DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content),
Editor("System. Windows.Forms.D esign.StringCol lectionEditor,
System.Design", typeof(UITypeEd itor))]

If you don't want them to be seen in the designer, you could set
[Browsable(false )]

Hope this helps,
-Rachel

"Maarten" <gu******@hotma il.com> wrote in message
news:42******** *************** @news.skynet.be ...
hi all,

I have a usercontrol with a checked listbox

this usercontrol is placed on a form1

is there a way to get the checked items of the checkedlisbox in the
usercontrol with a command from form1?

i beleave i have to do this with "get" and "set in a class

i've never worked with classes before

the way to get the items from the listbox is the code below.

thanks Maarten.

public void getchecked()

{

for (int x = 0; x <= (lstChannels.It ems.Count-1); x++)

{

if (lstChannels.Ge tItemChecked(x) )

{

}
else

{

}

}

Nov 16 '05 #4
BTW...
You only need (can use) the "get" in this property because the collection
itself is readonly. However, you can add to the collection by using
Items.Add(), so you have all the functionality with only a get on the items.

"Rachel Suddeth" <ra****@bldhoun d.com> wrote in message
news:OV******** ******@TK2MSFTN GP12.phx.gbl...
I think what you want is to expose the Items property of the listbox. Inside your usercontrol class you could do something like
public virtual ListItemCollect ion Items
{
get{ return listBox.Items; }
}
(I am not sure about the type of the items collection?)

If you want them to be editable in the designer, you could attributes like

[Description("Ge ts the collection of items displayed in the list."),
DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content), Editor("System. Windows.Forms.D esign.StringCol lectionEditor,
System.Design", typeof(UITypeEd itor))]

If you don't want them to be seen in the designer, you could set
[Browsable(false )]

Hope this helps,
-Rachel

"Maarten" <gu******@hotma il.com> wrote in message
news:42******** *************** @news.skynet.be ...
hi all,

I have a usercontrol with a checked listbox

this usercontrol is placed on a form1

is there a way to get the checked items of the checkedlisbox in the
usercontrol with a command from form1?

i beleave i have to do this with "get" and "set in a class

i've never worked with classes before

the way to get the items from the listbox is the code below.

thanks Maarten.

public void getchecked()

{

for (int x = 0; x <= (lstChannels.It ems.Count-1); x++)

{

if (lstChannels.Ge tItemChecked(x) )

{

}
else

{

}

}


Nov 16 '05 #5
Thans for answering my question

I still didn't fugured it out yet, but thanks anyway

"Rachel Suddeth" <ra****@bldhoun d.com> schreef in bericht
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
BTW...
You only need (can use) the "get" in this property because the collection
itself is readonly. However, you can add to the collection by using
Items.Add(), so you have all the functionality with only a get on the
items.

"Rachel Suddeth" <ra****@bldhoun d.com> wrote in message
news:OV******** ******@TK2MSFTN GP12.phx.gbl...
I think what you want is to expose the Items property of the listbox.

Inside
your usercontrol class you could do something like
public virtual ListItemCollect ion Items
{
get{ return listBox.Items; }
}
(I am not sure about the type of the items collection?)

If you want them to be editable in the designer, you could attributes
like

[Description("Ge ts the collection of items displayed in the list."),

DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content),
Editor("System. Windows.Forms.D esign.StringCol lectionEditor,
System.Design", typeof(UITypeEd itor))]

If you don't want them to be seen in the designer, you could set
[Browsable(false )]

Hope this helps,
-Rachel

"Maarten" <gu******@hotma il.com> wrote in message
news:42******** *************** @news.skynet.be ...
> hi all,
>
> I have a usercontrol with a checked listbox
>
> this usercontrol is placed on a form1
>
> is there a way to get the checked items of the checkedlisbox in the
> usercontrol with a command from form1?
>
> i beleave i have to do this with "get" and "set in a class
>
> i've never worked with classes before
>
> the way to get the items from the listbox is the code below.
>
> thanks Maarten.
>
> public void getchecked()
>
> {
>
> for (int x = 0; x <= (lstChannels.It ems.Count-1); x++)
>
> {
>
> if (lstChannels.Ge tItemChecked(x) )
>
> {
>
> }
>
>
> else
>
> {
>
> }
>
> }
>
>



Nov 16 '05 #6

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

Similar topics

1
741
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method...
9
1630
by: Jack | last post by:
Hello I have a library of calculationally intensive classes that is used both by a GUI based authoring application and by a simpler non-interactive rendering application. Both of these applications need to serialise the classes to/from the same files but only the GUI app needs the full range of class methods. Now, the rendering app needs...
9
6629
by: Aguilar, James | last post by:
I know that one can define an essentially unlimited number of classes in a file. And one can declare just as many in a header file. However, the question I have is, should I? Suppose that, to use the common example, I have a situation where I am implementing many types of Shapes. My current way of thinking is, well, since they are all...
12
21205
by: Langy | last post by:
Hello I'm fairly new to C++ but have programmed several other languages and found most of c++ fairly easy (so far!). I've come to a tutorial on classes, could someone please tell me why you would need to use a class? Perhaps you could also give an example on when it might be used rather than an alternative method.
4
1801
by: john townsley | last post by:
do people prefer to design classes for the particular job or for a rangle of tasks they might encounter now and in the future. i am doing some simple win32 apps and picking classes is simple, but understanding others peoples logic isnt (that doesnt mean they are wrong). i prefer designing classes for the currect job and making tangible...
2
9483
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how to do that? Thanks. Tsung-Yu
18
2026
by: Edward Diener | last post by:
Is the packing alignment of __nogc classes stored as part of the assembly ? I think it must as the compiler, when referencing the assembly, could not know how the original data is packed otherwise. Yet, in my understanding, attributes are only __gc and __value class specific and do not apply to __nogc classes. Is this correct ? If so, how is...
6
2923
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by calling Mesh class functions. Let's say they point to each other like this: class Vertex { HalfEdge *edge; }; class HalfEdge { Vertex* vert;
0
2020
by: ivan.leben | last post by:
I am writing this in a new thread to alert that I found a solution to the problem mentioned here: http://groups.google.com/group/comp.lang.c++/browse_thread/thread/7970afaa089fd5b8 and to avoid this topic getting lost before people interested in the problem notice it. The important tricks to the solution are two: 1) make the custom classes...
2
1908
by: Amu | last post by:
i have a dll ( template class) ready which is written in VC++6. But presently i need to inherit its classes into my new C#.net project.so if there is some better solution with u then please give me the solution.
0
7502
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...
0
7434
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...
0
7692
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7946
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...
1
7457
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...
0
7791
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6026
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...
0
5078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.