473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Custom control is inserting its own code?

I'm creating a multi-column dropdown since there isn't one. My idea
is to override an Infragistics Combo and add the dropdown as a grid
object. So I create a basic override of the control. The first thing
I want the control to do is kill the default button and add a new one.
So in the initialization (New) area of the control I add the code to
do that:

Me.DropDownButtonDisplayStyle =
Infragistics.Win.ButtonDisplayStyle.Never
Dim Button As New
Infragistics.Win.UltraWinEditors.EditorButton
Button.Key = "Drop"
Button.Visible = True
Button.Enabled = True
Button.Text = "..."
Me.ButtonsRight.Add(Button)

Fairly simple. I build that and load up a new project. I add the new
control in design view and run. I get an error saying "Key already
exists" (each button requires a unique key).

When I look at the "Form Designer Generated Code", it contains this:

EditorButton1.Key = "Drop"
EditorButton1.Text = "..."
Me.DropCombo2.ButtonsRight.Add(EditorButton1)

Why is this in my sample application? I added it to the new control's
initialization but it's added to the sample app code when the control
is dropped on the form. Why is the sample application trying to add
the button again? I would have thought the button would be created
ONCE when the control is created (which it is), not again when the
program is run. How do I stop it from adding this control code to the
sample app?

Thanks!

Nov 20 '05 #1
2 2738
Fred,

If you have the Infragistics controls why not just use the UltraCombo? It
is exactly what you have described.

-Sam Matzen
"Fred Flintstone" <id**********@nospam.com> wrote in message
news:5v********************************@4ax.com...
I'm creating a multi-column dropdown since there isn't one. My idea
is to override an Infragistics Combo and add the dropdown as a grid
object. So I create a basic override of the control. The first thing
I want the control to do is kill the default button and add a new one.
So in the initialization (New) area of the control I add the code to
do that:

Me.DropDownButtonDisplayStyle =
Infragistics.Win.ButtonDisplayStyle.Never
Dim Button As New
Infragistics.Win.UltraWinEditors.EditorButton
Button.Key = "Drop"
Button.Visible = True
Button.Enabled = True
Button.Text = "..."
Me.ButtonsRight.Add(Button)

Fairly simple. I build that and load up a new project. I add the new
control in design view and run. I get an error saying "Key already
exists" (each button requires a unique key).

When I look at the "Form Designer Generated Code", it contains this:

EditorButton1.Key = "Drop"
EditorButton1.Text = "..."
Me.DropCombo2.ButtonsRight.Add(EditorButton1)

Why is this in my sample application? I added it to the new control's
initialization but it's added to the sample app code when the control
is dropped on the form. Why is the sample application trying to add
the button again? I would have thought the button would be created
ONCE when the control is created (which it is), not again when the
program is run. How do I stop it from adding this control code to the
sample app?

Thanks!

Nov 20 '05 #2
Because the UltraCombo and UltraComboEditor require data binding.
I've been through this with Infragistics, they don't have AddItem
controls so I'm forced to butcher my own. ComponentOne has one but
they took our money, offered no support and ignored us. (Stay clear
of C1)

I'd like to know why a custom control copies, exactly, the code from
the control class's New function into the code of the application it's
being used in.

What if you wanted a combo control that was dropped pre-populated
with say, US states? You'd override a combo, add the population code
to the New function of the control class and build to get a DLL. When
you drop the combo on a sample application's form in design view,
it'll be populated with 50 states. Cool. But little do you know,
dropping that control copied the population code from the New method
of the control class to the 'do not modify' section of the sample app.
So when you RUN the sample with that combo on the form, you get 100
states. Once when the control is dropped (we want that) and then
again when the program is run (we don't). If the combo won't accept
duplicates (like unique button keys) you get an error.

Why is the literal code I've placed in control's New function, added
to the application it's being used in? The New code runs twice.

On Tue, 6 Jul 2004 09:58:05 -0500, "Samuel L Matzen" <sm*****@slm.com>
wrote:
Fred,

If you have the Infragistics controls why not just use the UltraCombo? It
is exactly what you have described.

-Sam Matzen
"Fred Flintstone" <id**********@nospam.com> wrote in message
news:5v********************************@4ax.com.. .
I'm creating a multi-column dropdown since there isn't one. My idea
is to override an Infragistics Combo and add the dropdown as a grid
object. So I create a basic override of the control. The first thing
I want the control to do is kill the default button and add a new one.
So in the initialization (New) area of the control I add the code to
do that:

Me.DropDownButtonDisplayStyle =
Infragistics.Win.ButtonDisplayStyle.Never
Dim Button As New
Infragistics.Win.UltraWinEditors.EditorButton
Button.Key = "Drop"
Button.Visible = True
Button.Enabled = True
Button.Text = "..."
Me.ButtonsRight.Add(Button)

Fairly simple. I build that and load up a new project. I add the new
control in design view and run. I get an error saying "Key already
exists" (each button requires a unique key).

When I look at the "Form Designer Generated Code", it contains this:

EditorButton1.Key = "Drop"
EditorButton1.Text = "..."
Me.DropCombo2.ButtonsRight.Add(EditorButton1)

Why is this in my sample application? I added it to the new control's
initialization but it's added to the sample app code when the control
is dropped on the form. Why is the sample application trying to add
the button again? I would have thought the button would be created
ONCE when the control is created (which it is), not again when the
program is run. How do I stop it from adding this control code to the
sample app?

Thanks!


Nov 20 '05 #3

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

Similar topics

19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
21
by: One Handed Man \( OHM - Terry Burns \) | last post by:
When using a custom control. In order to check and see if values have changed one has to implement the IPostBackDataCollection interface. The values returned for the control seem to be simply a...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
2
by: Leeor Chernov | last post by:
Hi I am using a <asp:Table> in a user control I created and in the loop of inserting another user control( a custom Calendar) to the TableCell by the code:...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
8
by: Lee | last post by:
Hi all, I'm trying to programatically change the background color of lines of text and running into a few difficulties, anyone got any suggestions? my relevant code is as follows: public void...
12
by: raghav | last post by:
Hi I am working on ASP.NET 2.0. I am developing a website using Wizard control. Based on number of steps added, next, previous, finish buttons generate automatically. After running the...
1
by: WebMatrix | last post by:
Hi, I started a new web application which so far has several grdiviews displaying data. I find myself reimplementing the same logic (copy/pasting really) in grid's event ItemDataBound and...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.