Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I am newbie to programming, this is my code
int c = 0;
 
       private void button1_Click_1(object sender, EventArgs e)
       {
   ComboBox txtRun = new ComboBox();
   txtRun.Name = "txtDynamic" + c++;
   txtRun.Location = new System.Drawing.Point(30, 18+(30*c));
   this.Controls.Add(txtRun);
   panel1.Controls.Add(txtRun);
   }
 
i am making a combobox which is added dynamically on a windows form, it places the combobox one after the other, and i used panel so that the other control cannot be effected by the adding of runtime control, here the problem is when i click the button and add new combobox to the panel, it adds successfully and my panel size is
Quote:
260, 181
so when i add 5 combobox then i have to scroll to see the 5th combobox.(scroll the panel not the form), and the main problem persist here, when i scroll and the focus is on 5th combobox and then when click on button for adding new combobox then the location of the new combobox is double the location of combobox which i have made earlier so, it looks odd, that five of combobox are in sequence and the 6th one is at the larger distance below that, how to solve this problem, plz help
sorry for my bad english
Posted 10-Dec-12 4:09am
Edited 10-Dec-12 4:13am
v2
Comments
sariqkhan at 10-Dec-12 9:12am
   
+5
shaikh-adil at 10-Dec-12 9:14am
   
thanks bro.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Firstly I'll show you what I did to understand what was going on ...
I added using System.Diagnostics; to the form and then put in the following
private void panel1_Scroll(object sender, ScrollEventArgs e)
{
	Debug.Print(panel1.Controls[panel1.Controls.Count - 1].Location.ToString());
}
I was then able to observe that the location of the final combo box was "changing" as I moved the scrollbar. Also if you just keep adding controls without scrolling to the last one then you don't get the problem you describe. It must be to do with relative locations then.
 
So I then added this at the start of button1_Click
panel1.VerticalScroll.Value = VerticalScroll.Minimum;

and the problem went away
  Permalink  
v2
Comments
shaikh-adil at 10-Dec-12 10:41am
   
+5 thanks to you also sir.
:)
shaikh-adil at 10-Dec-12 10:44am
   
panel1.VerticalScroll.Value = VerticalScroll.Minimum;
what does this means sir?
it is adding the vertical scroll value which is minimum?? what is this?
CHill60 at 10-Dec-12 11:10am
   
I could have probably used "panel1.VerticalScroll.Value = 0;" but using VerticalScroll.Minimum is better ... basically it means "scroll right to the top of this panel control before adding another combobox". See also Griff's comments below
shaikh-adil at 10-Dec-12 11:33am
   
:)
got you.
thanks for explaning and if i want to implement your method and if i want to focus on the last combobox then what can i do?
CHill60 at 10-Dec-12 12:11pm
   
You could use "panel1.Controls[panel1.Controls.Count - 1].Focus();".
Note however, I thoroughly recommend OriginalGriff's approach in preference to mine
sariqkhan at 10-Dec-12 13:33pm
   
panel1.Controls.Count - 1
this means that focus on the focus on the last control of the panel?
but what does - 1 mean here?
CHill60 at 11-Dec-12 4:18am
   
The controls collection is base zero ... i.e. the first control is index [0], 2nd is [1] etc. So if there are 8 controls in the collection (panel1.Controls.Count ==8) the last one is [7] or [count - 1]
sariqkhan at 11-Dec-12 4:22am
   
thank you for explaining
shaikh-adil at 10-Dec-12 13:54pm
   
yess i have both the option. You too are awsome coders.
:)
thanks to you two.
sariqkhan at 10-Dec-12 23:09pm
   
if i generate labels and combobox then how to focus on the last generated combobox?
CHill60 at 11-Dec-12 4:45am
   
There a few ways you could achieve that - easiest is to put txtRun.Focus() in your function after you've finished adding the controls :-)
Or you can work out what the name of the last combo-box would be and use
Control[] ctrls = panel1.Controls.find(lastComboName, true);
if (ctrls.Length > 0)
ctrls[ctrls.Length - 1].Focus();
sariqkhan at 11-Dec-12 5:27am
   
thank you
:)
i think this discussion will be continue till midnight
:laugh
shaikh-adil at 11-Dec-12 5:17am
   
private void txtRun3_Leave(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
if (cb != null)
{
Label lb = cb.Tag as Label;
if (cb.Text == string.Empty)
{
lb.Visible = true;
}
}
}
 
int c = 0;
int p = 0;
private void button1_Click(object sender, EventArgs e)
{
 

panel1.VerticalScroll.Value = VerticalScroll.Minimum;
panel1.HorizontalScroll.Value = HorizontalScroll.Minimum;
Label label = new Label();
label.Name = "dynamiclabel" + p++ ;
label.Location = new Point(160, 18 + (35 * p));
ComboBox txtRun3 = new ComboBox();
txtRun3.Name = "txtDynamic" + c++ ;
txtRun3.Location = new Point(30, 18 + (35 * c));
txtRun3.Tag = label;
label.Visible = false;
label.Text = "labelname";
txtRun3.Leave += new EventHandler(txtRun3_Leave);
panel1.Controls.Add(label);
panel1.Controls.Add(txtRun3);
}
 
sir i have done this but the problem is the 4th labels which should be by the side of the combobox is below many pixels can you tell me now what is the problem when i have implemented
panel1.VerticalScroll.Value = VerticalScroll.Minimum;
CHill60 at 11-Dec-12 5:56am
   
I can't reproduce that problem now even after I removed label.Visible = false; but you could try
txtRun3.Location = new Point(30, label.Top);
rather than recalculating the height
shaikh-adil at 11-Dec-12 6:05am
   
sir if i have added a button and i textbox in one line and i want that a button should delete the aside textbox which is the same line so how can i do that? i want only the textbox which is aside that should be delete all the other control should not be effected with the delete option? is it possible to delete a component in runtime means dynamically?
CHill60 at 11-Dec-12 6:50am
   
It is indeed possible ... just as you can use Controls.Add there is a .Remove facility. You can even remove the button itself.
Hints 1: You will need to know or to be able to work out the name(s) of the controls you want to delete with each button
Hint 2: You will need to "Find" the controls as I showed you earlier
Hint 3: Button b = (Button)sender; in the btn_Click that you will write will enable you to access properties you may need
 
Give it a go and let me know if you get stuck
shaikh-adil at 11-Dec-12 7:06am
   
sir i have written this code
private void btn_Click(object sender, EventArgs e)
{
ComboBox cb1 = sender as ComboBox;
panel1.Controls.Remove(cb1);
 
}
and for ADDING cumbobox and button in the button click
ComboBox txtRun3 = new ComboBox();
txtRun3.Name = "txtDynamic" + c++ ;
txtRun3.Location = new Point(30, 18 + (30 * c));
 
Button btn = new Button();
btn.Name = "btn" + p++;
btn.Location = new Point(200, 18 + (30 * c));
there isnt any error coming how to solve that
shaikh-adil at 11-Dec-12 7:19am
   
thank you i have done that thing it was very easy
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

The only way I could duplicate this was to scroll the panel - which makes sense, because the coordinates are relative to the top of the control, not the top of it's scrolled position.
Try including the scroll position in your location:
            ComboBox txtRun = new ComboBox();
            txtRun.Name = "txtDynamic" + c++;
            txtRun.Location = new Point(30, 18 + (30 * c) + panel1.AutoScrollPosition.Y); ;
            panel1.Controls.Add(txtRun);
 

"can you explain sir what this will do
panel1.AutoScrollPosition.Y);
i am confused a little bit"

 

The Location of a control on any container is relative to the top left hand corner of that container - be it a form, or a panel, or a splitter. Otherwise it you would have to refer to the containing control TLHC when you set position, and all control locations would have to be updated when you moved the container.
 
A panel is an example of a ScrollableControl (i.e. it derives from that rather tna from the vanilla Control)
 
When you scroll it, the amount of pixels difference between the unscrolled position of a contained control and the amount it has moved relative to the TLHC of the container is given to you as the AutoScrollPosition - it is the offset between the on-screen position of the TLHC of the container, and the logical position. If you scroll it five pixels down, the Y coordinate of the AutoScrollPosition goes to -5.
 
The more you scroll the control down, the move negative the value in the relevant
All the code does is include the amount of the scroll, to make the offset relative to the real TLHC rather than the displayed TLHC.
 
Try it for yourself, and it will probably make more sense. Handle the Panel.Scroll event and add the following code:
        private void panel1_Scroll(object sender, ScrollEventArgs e)
            {
            Console.WriteLine(panel1.AutoScrollPosition);
            }
As you scroll it, you will see the number change, and it should be clearer.
 

"sir can you tell me one more thing relating to dynamic validation
if i am using this code for validation

public bool valun()
        {
            if (combobox.Text == string.Empty)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
public void validation_username()
        {
            bool stat = valun();
            if (stat == true)
            {
		label1.visible =true 
            }
            else
            {
               label1.visible =true 
            }
        }
then how can i validate dynamic controlwhich i have added?"
 

You could add an event handler, and use the sender parameter to identify which comboBox it was. If you handle the Leave Event you can do it immediately the user exits the control for any reason:
            txtRun.Leave += new EventHandler(txtRun_Leave);
            panel1.Controls.Add(txtRun);
            }
        ...
        private void txtRun_Leave(object sender, EventArgs e)
            {
            ComboBox cb = sender as ComboBox;
            if (cb != null)
                {
                //...
                }
            }
 
Or you can do it on a button press, and iterate through the panels Controls in a similar way:
            foreach (Control c in panel1.Controls)
                {
                ComboBox cb = c as ComboBox;
                if (cb != null)
                    {
                    //...
                    }
                }
 

"sir but the first method of validation is not working in mine.
i have written this in the button click event

txtRun.Leave += new EventHandler(txtRun_Leave);
            panel1.Controls.Add(txtRun);
and this
private void txtRun_Leave(object sender, EventArgs e)
        {
            ComboBox cb = sender as ComboBox;
            if (cb != null)
            {
                label1.Visible = false;
            }
            else
            {
                label1.Visible = true;
            }
        }
as outside.. whats the problem there is no error coming"
 

No, no, no...
You need to learn what "as" does: it is a conditional cast operator. If the object being cast is of the appropriate type, then it is cast, and the reference is set into the variable. If it isn't, then null is assigned instead.
 
So, if the object sender is a ComboBox (or a control derived from ComboBox), then the reference to sender is assigned to cb. If it isn't, then null is assigned. The first test in the method is to make sure that the method has not been called from a button, or a DataGridView, or some other control.
 
Your code will always assign false to the label.Visible property if the handler is only ever added to a ComboBox control. You still need to check the ComboBox content!
 

 
"And stop adding controls to two different Controls lists ???
what does this means?
and i will clear my problem, lets start from start. i am making a combobox and label dynamically, label is set to visible = false. and just as same what you have done validation, when user dosent enter enything and leaves the combobox then the label is set to true. i just want to do that but the label will be dynamically generated, i have done this

 
 	  Label label = new Label();
            label.Name = "dynamiclabel" + c++;
            label.Location = new Point(160, -5 + (20 * c));
           label.Visible = false;
           label.Text = "labelname";
 
            ComboBox txtRun3 = new ComboBox();
            txtRun3.Name = "txtDynamic" + c++;
            txtRun3.Location = new Point(30, 18 + (20 * c));
 		
 
            this.Controls.Add(txtRun3);
            this.Controls.Add(label);
            txtRun3.Leave += new EventHandler(txtRun_Leave);
 
            panel1.Controls.Add(label);
            panel1.Controls.Add(txtRun3);
this code in the button click event and
  private void txtRun_Leave(object sender, EventArgs e)
        {
            ComboBox cb = sender as ComboBox;
            Label lb = sender as Label;
            if (cb != null)
            {
                if (cb.Text == string.Empty)
                {
                    lb.Visible = true;
                    
                }
                else
                {
                    lb.Visible = false;
                }
            }
        }
but the error which is coming is this
"Object reference not set to an instance of an object."
where i am wrong."
 

 
"stop adding controls to two different Controls lists ???
what does this means?"

 
Look at your code:
   this.Controls.Add(txtRun);
   panel1.Controls.Add(txtRun);
And
   this.Controls.Add(label);
   panel1.Controls.Add(label);
In both cases you are adding the same control to two different Controls Lists - this.Controls (the form) and panel1.Controls (the panel). You only want to add it to the panel, not the form.
 
"where i am wrong."
 
If a Control is a ComboBox, then it can't also be a Label! So when you execute
            ComboBox cb = sender as ComboBox;
            Label lb = sender as Label;
You are guaranteed that one of the two variables will be null - so when you try to use both, you are certain to get the error.
 
A suggestion:
 
Did you know that every control has a Tag property? No? It's really handy when you want to relate two controls, because it can contain any object. If you set the Tag property of the ComboBox to the relevant Label, you could access exactly that one in your Leave event...
 
            Label label = new Label();
            label.Name = "dynamiclabel" + c++;
            label.Location = new Point(160, -5 + (20 * c));
            label.Visible = false;
            label.Text = "labelname";
 
            ComboBox txtRun3 = new ComboBox();
            txtRun3.Name = "txtDynamic" + c++;
            txtRun3.Location = new Point(30, 18 + (20 * c));
            txtRun3.Tag = label;
 
        private void txtRun_Leave(object sender, EventArgs e)
        {
            ComboBox cb = sender as ComboBox;
            if (cb != null)
            {
                Label lb = cb.Tag as Label;
                if (lb != null)
                {
                    ...
  Permalink  
v5
Comments
CHill60 at 10-Dec-12 10:35am
   
Far better solution than mine! +5
shaikh-adil at 10-Dec-12 10:40am
   
+5
:)
thanks sir
shaikh-adil at 10-Dec-12 10:43am
   
can you explain sir what this will do
panel1.AutoScrollPosition.Y);
i am confused a little bit
OriginalGriff at 10-Dec-12 10:55am
   
Answer updated
shaikh-adil at 10-Dec-12 11:27am
   
thank you sir
:)
very thanks for helping us
OriginalGriff at 10-Dec-12 11:31am
   
You're welcome!
shaikh-adil at 10-Dec-12 11:34am
   
sir can you tell me one more thing relating to dynamic validation
if i am using this code for validation
public bool valun()
{
if (combobox.Text == string.Empty)
{
return true;
}
else
{
return false;
}
}
public void validation_username()
{
bool stat = valun();
if (stat == true)
{
label1.visible =true
}
else
{
label1.visible =true
}
}
then how can i validate dynamic control which i have added?
OriginalGriff at 10-Dec-12 11:45am
   
Answer updated
Simon_Whale at 10-Dec-12 11:58am
   
Nice answer +5
sariqkhan at 10-Dec-12 13:52pm
   
:)
sir but the first method of validation is not working in mine.
i have written this in the button click event
txtRun.Leave += new EventHandler(txtRun_Leave);
panel1.Controls.Add(txtRun);
and this
private void txtRun_Leave(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
if (cb != null)
{
label1.Visible = false;
}
else
{
label1.Visible = true;
}
}
as outside.. whats the problem there is no error coming
OriginalGriff at 10-Dec-12 14:11pm
   
Answer updated
shaikh-adil at 10-Dec-12 22:56pm
   
that was a really simple mistake
:)
thank you again for helping and solving my doubt sir
sariqkhan at 10-Dec-12 22:48pm
   
+5
sariqkhan at 10-Dec-12 22:52pm
   
one more question sir,
this label visible true or false is simple one, but if i generate a dynamic label like by adding this
Label label = new Label();
label.Text = "labelname";
label.Name = "dynamiclabel" + c++;
label.Visible = false;
label.Location = new Point(160, -5 + (20 * c));
this.Controls.Add(label);
panel1.Controls.Add(label);
so how to set it true or false if the user leaves the combobox whithout entering anything, this will be good enough
can you help me
OriginalGriff at 11-Dec-12 2:51am
   
Sorry, but I don't understand what you are trying to do - How is the label related to the combobox?
(And stop adding controls to two different Controls lists - it doesn't work, because a Control can only have one Parent and be displayed once per form! :laugh:)
sariqkhan at 11-Dec-12 4:15am
   
And stop adding controls to two different Controls lists ???
what does this means?
and i will clear my problem, lets start from start. i am making a combobox and label dynamically, label is set to visible = false. and just as same what you have done validation, when user dosent enter enything and leaves the combobox then the label is set to true. i just want to do that but the label will be dynamically generated, i have done this
 
Label label = new Label();
label.Name = "dynamiclabel" + c++;
label.Location = new Point(160, -5 + (20 * c));
label.Visible = false;
label.Text = "labelname";
 
ComboBox txtRun3 = new ComboBox();
txtRun3.Name = "txtDynamic" + c++;
txtRun3.Location = new Point(30, 18 + (20 * c));

 
this.Controls.Add(txtRun3);
this.Controls.Add(label);
txtRun3.Leave += new EventHandler(txtRun_Leave);
 
panel1.Controls.Add(label);
panel1.Controls.Add(txtRun3);
this code in the button click event and
 

private void txtRun_Leave(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
Label lb = sender as Label;
if (cb != null)
{
if (cb.Text == string.Empty)
{
lb.Visible = true;

}
else
{
lb.Visible = false;
}
}
}
but the error which is coming is this
"Object reference not set to an instance of an object."
where i am wrong.
 
OriginalGriff at 11-Dec-12 4:32am
   
Answer updated
shaikh-adil at 11-Dec-12 5:18am
   
sir can thank you once again
can i ask one more question related to this topic?
OriginalGriff at 11-Dec-12 5:19am
   
Sure!
shaikh-adil at 11-Dec-12 5:22am
   
private void txtRun3_Leave(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
if (cb != null)
{
Label lb = cb.Tag as Label;
if (cb.Text == string.Empty)
{
lb.Visible = true;
}
}
}
 
int c = 0;
int p = 0;
private void button1_Click(object sender, EventArgs e)
{
 

panel1.VerticalScroll.Value = VerticalScroll.Minimum;
panel1.HorizontalScroll.Value = HorizontalScroll.Minimum;
Label label = new Label();
label.Name = "dynamiclabel" + p++ ;
label.Location = new Point(160, 18 + (35 * p) + panel1.AutoScrollPosition.Y); ;
ComboBox txtRun3 = new ComboBox();
txtRun3.Name = "txtDynamic" + c++ ;
txtRun3.Location = new Point(30, 18 + (30 * c) + panel1.AutoScrollPosition.Y); ;
txtRun3.Tag = label;
label.Visible = false;
label.Text = "labelname";
txtRun3.Leave += new EventHandler(txtRun3_Leave);
panel1.Controls.Add(label);
panel1.Controls.Add(txtRun3);
}
 
sir i have done this but the problem is the 4th labels which should be by the side of the combobox is below many pixels can you tell me now what is the problem when i have implemented
OriginalGriff at 11-Dec-12 5:31am
   
Um...
label.Location = new Point(160, 18 + (35 * p) + panel1.AutoScrollPosition.Y); ;
txtRun3.Location = new Point(30, 18 + (30 * c) + panel1.AutoScrollPosition.Y); ;
---------------------------------------------------^
 
BTW: You don't need two semicolons, and why are you using p and c anyway - they will always contain the same value...
sariqkhan at 11-Dec-12 5:40am
   
griff sir,
the same problem, check out. after 4 or 5fifth combobox, the labels change the orignal position to the lower than what expected
OriginalGriff at 11-Dec-12 6:11am
   
I just pasted your code into my app, and changed the "35" to "30". If I also change the Visible to true so I can see them, they are all lined up perfectly, even when scrolled. So what are you doing differently?
BTW: It would make sense for you to calculate "18 + (35 * p) + panel1.AutoScrollPosition.Y" once, and store it in a variable (called yPosn) - then use it for both Points. That way a minor typo can't get them out of synch - and it can be a bit more efficient because the calculation does not need to be done twice.
sariqkhan at 11-Dec-12 6:18am
   
you are right
really you should be term father of coder
i never seen such coder in my life. as i am a student from mumbai i didint experience such a teacher
OriginalGriff at 11-Dec-12 6:20am
   
I'd rather you didn't - I feel old enough when I look in the mirror... :laugh:
sariqkhan at 11-Dec-12 6:23am
   
:)
whats your age?
35?
OriginalGriff at 11-Dec-12 6:33am
   
OW! That was a low blow - try swapping the digits!
OriginalGriff at 11-Dec-12 5:35am
   
:sigh: That worked in the preview...
Look at the Y coord - you multiply one by 30 and the other by 35 (in the preview they lined up, and it was obvious what I meant - forgot the actual post would use a proportional font :doh:)
shaikh-adil at 11-Dec-12 6:06am
   
sir if i have added a button and i textbox in one line and i want that a button should delete the aside textbox which is the same line so how can i do that?
i want only the textbox which is aside that should be delete all the other control should not be effected with the delete option?
is it possible to delete a component in runtime means dynamically?
OriginalGriff at 11-Dec-12 6:14am
   
Remember - all Controls have a Tag property - you could use that to tie the Button and the Label together.
 
BTW: Sorry about the last post - I think there are two of you asking related questions on the same thread and I'm getting confused! :laugh:
sariqkhan at 11-Dec-12 6:20am
   
tag property for deleting? how sir?
can you give us code snippet please
BTW
we are bro, styding in same university, and even shares one another 's computers
OriginalGriff at 11-Dec-12 6:33am
   
Ok...in the same way as you tied the ComboBox and it's Label together with the Tag property, the Button can use it's Tag to identify the TextBox. It is then just a matter of using the relevant Controls list, and calling it's Remove method. So if you want to remove the textBox on the Button Click event, the code is very similar to the Leave event code you already have - all you need to do is call panel1.Controls.Remove on the TextBox and set the Button.Tag property to null so you won't try again!
shaikh-adil at 11-Dec-12 6:59am
   
l panel1.Controls.Remove on the TextBox ??
what does this means?
can you write and explain sir
please
OriginalGriff at 11-Dec-12 7:06am
   
Let's see if you can work this out yourself a bit - you have all the bits you should need.
You can tie the TextBox to the Button via the Tag - yes?
You can write a Click event handler for the Button - yes?
You can identify the TextBox associated with the Button from the Tag - yes?
You know which Panel (or other container) the Button is in - yes? Or you can find out using the Parent property...
So you know what you need to do - don't you? :laugh:
(Have a try - you will learn better by doing than by getting the code handed to you.)
I'll wait while you have a go... ;)
shaikh-adil at 11-Dec-12 7:11am
   
i have generated this one
private void btn_Click(object sender, EventArgs e)
{
ComboBox cb1 = sender as ComboBox; panel1.Controls.Remove(cb1);
} and for ADDING cumbobox and button in the button click
 
ComboBox txtRun3 = new ComboBox();
txtRun3.Name = "txtDynamic" + c++ ;
txtRun3.Location = new Point(30, 18 + (30 * c));
Button btn = new Button();
btn.Name = "btn" + p++; btn.Location = new Point(200, 18 + (30 * c));
there isnt any error coming how to solve that
You can identify the TextBox associated with the Button from the Tag - No
OriginalGriff at 11-Dec-12 7:20am
   
So why not set the Tag property of the button?
shaikh-adil at 11-Dec-12 7:26am
   
sir can you tell me if i have a combobox in a one form which is dynamically generated and i want to transfer the text value of that to the next form's combobox which is not dynamically generated so what can i do?
OriginalGriff at 11-Dec-12 8:04am
   
At this point you need to ask a new question!
(Partly because this is unrelated to the original query, but mostly because this is getting to be a very large thread! :laugh:)
shaikh-adil at 11-Dec-12 8:19am
   
ohkay
:laugh
shaikh-adil at 11-Dec-12 7:19am
   
i have done that
yesssssss
thank you
OriginalGriff at 11-Dec-12 8:05am
   
You're welcome!
sariqkhan at 11-Dec-12 5:31am
   
ohh i heard this first time about the tag property
thank you once once again for helping us
:)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

your problem is where you are setting the location as when you hit the 6th Combobox you are saying that the location show be
 
x = 30
y = 18+(30*6) = 198
 
personally I would attempt it as follows
 
 private int ComboTopPosition = 20;
 private int ComboNumber = 0;
 
 private void button1_Click_1(object sender, EventArgs e)
 {
   ComboBox txtRun = new ComboBox();
   txtRun.Name = "txtDynamic" + ComboNumber.ToString();
   txtRun.Location = new System.Drawing.Point(30, ComboTopPosition);
   panel1.Controls.Add(txtRun);
 
   ComboTopPosition += 30;
   ComboNumber += 1;
 }
 
naturally you can adjust the TopPosition to suit your needs.
  Permalink  
Comments
CHill60 at 10-Dec-12 10:34am
   
I can get the same problem as the poster if I try this
Simon_Whale at 10-Dec-12 10:44am
   
Thanks learnt something new :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 290
1 Jochen Arndt 150
2 Kornfeld Eliyahu Peter 149
3 PIEBALDconsult 110
4 Richard MacCutchan 105
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100