PC Review


Reply
Thread Tools Rate Thread

Custom control is inserting its own code?

 
 
Fred Flintstone
Guest
Posts: n/a
 
      6th Jul 2004
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!

 
Reply With Quote
 
 
 
 
Samuel L Matzen
Guest
Posts: n/a
 
      6th Jul 2004
Fred,

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

-Sam Matzen


"Fred Flintstone" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!
>



 
Reply With Quote
 
Fred Flintstone
Guest
Posts: n/a
 
      6th Jul 2004
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" <(E-Mail Removed)>
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" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>> 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!
>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
More control over moving and inserting OLE Objects via code Andrew Microsoft Excel Programming 0 5th Oct 2009 04:55 PM
Re: Code for setting Forms to open with custom tool bar, menubar and control custom short Rick Brandt Microsoft Access 0 5th Feb 2006 01:06 PM
creating custom control in code Sergey Poberezovskiy Microsoft Access 0 30th Dec 2004 10:45 PM
How to address control within templated custom control from code behind Earl Teigrob Microsoft ASP .NET 2 8th Jun 2004 08:18 PM
Create Custom Control thru Code? Greg Bloom Microsoft Excel Programming 1 13th Oct 2003 09:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:55 AM.