|
Luc Pattyn wrote: you create a new random generator every time;
I totally missed that!
|
|
|
|
|
That makes total sense.
Figured it was something simple.
Thanks!!!
David Wilkes
|
|
|
|
|
Random generator = new Random();
for (int a = 0; a < 36; a++)
{
int randomValue;
randomValue = generator.Next(1, 20);
list3.Add(a, randomValue);
}
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hello all,
I am having 5 combo Boxes in my Form1.cs whose values are not selected.
I have set SelectedIndex = -1.
After this i am opening another form. Doing some operation and closing it.
When the Control returns to Form1.cs all the combo Boxs are having 1st value selected.
I have checked none of the events are getting fired. But by default all the combo boxes are set to SelectedIndex = 0.
Any help regarding this behaviour of ComboBox Values being selected on another form closing would be highly appreciated.
Thanks in Advance.
--Bhoomi
|
|
|
|
|
I am not sure but I think you will have to reset the SelectedIndex agin when the form becomes active. I think it has to do with how forms work ie STA threading model.
|
|
|
|
|
Hi bhoomi
I think you want to select values of combos on first form on the closing of second form....
is it???
Atul
|
|
|
|
|
What is the behaviour of STA Threading Model. Does it fill up 1st values of the attached Datasource on Activate?
Then it is a dangerours thing.
If any user has set out ComboBox to be blank and opens another form then those Blanks goes away. How is the user supposed to know which all values might have changed.
Is there any solution for this??
Any help would be highly appreciated.
Regards,
Bhoomi.
|
|
|
|
|
Hi Bhoomi
I think u want to change the index of combos of first form on closing of second form. If this is question then events and delegates are used int this scenario....
Atul Kumar
|
|
|
|
|
For knowing the exact problem, i have created another application as follows :
1. MDI Form with 2 menus : Form1.cs and Form2.cs
2. Form1.cs
2 Comboboxes filled through DataTable.
3. Form2.cs
Just a TextBox.
Behaviour is like this :
Open Form1.cs in MdiParent. ComboBoxes gets filled up. Remove the selected value manually. Open Form2. Close the Form2. Both the comboBoxes are filled up with 1st values.
I am unable to undertstand why the combo boxes are filled up with initial values on its own.
Any help would be highly appreciated.
Regards,
Bhoomi.
|
|
|
|
|
Not sure why exactely but this is not the only strange behavior I see.
I now that forms run on the STA threading model so a form that doesn't have the control is actually not "running". I think that when a form regains the control, it reinitilizes partly its controls, so behaviors like this are to be expected. I learned with time to be very carefull about this. There must be reading to do on this but I never took the time to do it. try to at least understand the difference between STA and MTA, it will answer many of your questions on forms.
Good luck
|
|
|
|
|
hi i want to get the index valu of the sorted array in some other array
can any 1 help me with this.......?
i need the sorted index to be in another arry....
Array index
0
1
2
3
4
5
6
Values
2
1
7
6
5
4
3
sorted index
2
3
4
5
6
0
1
sorted value
7
6
5
4
3
2
1
Arun Raj.K
|
|
|
|
|
I am trying to build a DataTable from a TList<t>, which is a collection of T business objects. I am using reflection to get all the properties of T, and then loop through them creating DataColumn objects. However, I get an error when I try and create a new column where a property of T is nullable. Is there a quick way around this? Looking at the type name for a nullable property of T is also pretty confusing, as the type name is "Nullable`1".
"A little learning is a dangerous thing; drink deep, or taste not the Pierian spring: there shallow draughts intoxicate the brain, and drinking largely sobers us again.", by Alexander Pope
My New Blog
|
|
|
|
|
You need to get the underlying type, e.g.:
foreach (PropertyInfo propInfo in properties)
{
Type propType = propInfo.PropertyType;
if (propType.IsGenericType &&
propType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
propType = Nullable.GetUnderlyingType(propType);
}
}
|
|
|
|
|
Thanks Lisa, I actually did discover that a while after posting.
I should have updated.
|
|
|
|
|
instead of your
if (propType.IsGenericType &&
propType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
propType = Nullable.GetUnderlyingType(propType);
}
you could also do
column.DataType = Nullable.GetUnderlyingType(PropertyType) ?? PropertyType;
depending on your knowledge about the ?? operator and your preferences it could improve the readability
|
|
|
|
|
Hi guys I've a form for cars search. There are different text boxes and check boxes on that form. User can even enter one field or all the field or no one field. If i use and operator then it doesen't give me any result. can anybody help me. How can i make a query that can give me result.
for example i want to search the cars which have cdplayer. now all the fields are empty only one check box is checked.
|
|
|
|
|
How are you performing your search? Are you using a stored procedure? If so you will need to allow your parameters to be null. Pass all of your fields on the form to your search proc. If one of the fields is blank pass a null value for that parameter. This way you can do a specific search on only the criteria that is selected by the user. I have also done a search page that will allow the user to select Any in a drop down list. The proc then replaces a parameter with the value Any with a * (to search all items in the drop down list).
Hope this helps.
Nathan
|
|
|
|
|
Hi there,
I have a problem. Here's the situation: I have a bunch of controls in a library. I'd like to build some forms using these controls, but I want all the controls to have 3 extra events that I have defined. Ideally, I don't want to have to write a new control class that derives from the existing control and adds the events, because there's a lot of control classes.
If it were possible, I'd like to write something like
<br />
public class ExtendedControl< T > : T { }<br />
<br />
ExtendedControl< TreeView > treeView1 = new ExtendedControl< TreeView >( );<br />
Sadly, naked generic parameters can't be inherited. Sometimes, I long for templates...
I was kind of hoping that I could create an IExtenderProvider-style class that can be added to the component tray of a form, and adds the 3 events to all controls added to the form. But IExtenderProvider only lets you add new properties, right?
Does anyone have any good ideas about how i can automagically add the 3 events? or am i going to have to bite the bullet and write a crapload of almost identical derived classes?
Many thanks in advance
|
|
|
|
|
how about:
foreach(Control c in myForm.Controls) {
if (isApplicableTo(c)) {
c.Event1+=...
c.Event2+=...
c.Event3+=...
}
}
|
|
|
|
|
lol if only it were so easy
perhaps I should have mentioned that I want the designer to support my events (so they appear in the events property control when I select the control in the form).
Thanks
|
|
|
|
|
Hello
And what about creating an base class where your allready existing controls derive from?
All the best,
Martin
|
|
|
|
|
that's possible in some cases, but not in others. For example, I want to be able to add the events to TreeView, or TextBox, or whatever. By including the events in a base class, I force everything that wants to support those events, to inherit from that base class, which isn't good design. Ideally, I need something like a C++ mixin (not possible in C#, i think), or something like the IExtenderProvider, for events.
Thanks for the feedback
|
|
|
|
|
Hello,
What about Control.Events.AddHandler method.
Have never used it myself!
Hope it helps!
Martin
|
|
|
|
|
hmmm interesting I'll take a look... I'm not sure, though, because I'd like the events to be visible in the forms designer, and i doubt they would be if i was adding delegates programmatically. Or have I got the wrong end of the stick?
Thanks for your help!
|
|
|
|
|
I'm also interested in that!
Please, let me know if it works for you.
All the best,
Martin
|
|
|
|