|
Apart from typing it out manually? Just use a loop.
int[] index = new int[100];
for (int i = 0; i < index.Length; i++)
index[i] = i;
inb4 Enumerable.Range(0, 100).ToArray() - oh sure, but that has the same loop, and also does a bunch of array allocations and copies. Sweeping a loop under the rug doesn't make it go away.
|
|
|
|
|
|
A little Linq, perhaps:
int[] iary = new[] { 5, 4, 1, 3, 2 };
var sorted = iary.OrderBy(itm1 => itm1).ToArray();
var unsortedIndexes = sorted.Select(itm2 => Array.IndexOf(iary, itm2, 0)).ToArray(); Note that using 'OrderBy creates a copy of the Array.
>? sorted
{int[5]}
[0]: 1
[1]: 2
[2]: 3
[3]: 4
[4]: 5
> ? unsortedIndexes
{int[5]}
[0]: 2
[1]: 4
[2]: 3
[3]: 1
[4]: 0
> ? iary
{int[5]}
[0]: 5
[1]: 4
[2]: 1
[3]: 3
[4]: 2
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin
modified 15-Dec-15 11:23am.
|
|
|
|
|
hi, i have a question.
When i use chart1.invalidate() to refresh chart, it had 3 ms cost betten call chart_paint(), Then i called chart_paint() manully on other thread, it cost less than 1ms,it can reach my requirement. But chart has no refresh, it can not clean up history paint.
So i want to know how to invalidate chart control ,but not to call paint aotumatic?
|
|
|
|
|
Have you tried over-riding the Paint Event ?
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin
|
|
|
|
|
how can i overriding the paint event? please help me a example
|
|
|
|
|
I got problem with ComboBox in winforms c#. Comboboxes in main window works fine, but comboboxes in form that I open in panel on main window are broken. The wierd things starts to happen... I cant click it to type. I can only open list, select one and then type. Also i cant locate cursor in the middle of text because it highlight whole text. I post code with I open form in panel:
public void otworzOkno(Form _form)
{
if (Application.OpenForms[_form.Name] != null)
{
Application.OpenForms[_form.Name].WindowState = FormWindowState.Normal;
Application.OpenForms[_form.Name].BringToFront();
}
else
{
_form.TopLevel = false;
_form.AutoScroll = true;
this.panel.Controls.Add(_form);
_form.Show();
_form.BringToFront();
}
}
Video that will explain problem: https://youtu.be/PrVxFWvhPyc
|
|
|
|
|
how have you constructed the comboboxes?
do they have an assigned datasource?
do they share datasources?
how you are showing the way that you are opening the form that they are on doesn't show the problem it's on that form.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
The problem is that the form is opened in panel, because when i open the same form with the same settings in seperate window not in panel it works fine. I dont know why that happen
|
|
|
|
|
as a Test I would change your code to this, I do something similar but I use a splitter container.
public void otworzOkno(Form _form)
{
if (Application.OpenForms[_form.Name] != null)
{
Application.OpenForms[_form.Name].WindowState = FormWindowState.Normal;
Application.OpenForms[_form.Name].BringToFront();
}
else
{
_form.TopLevel = false;
_form.Parent = panel;
_form.Show();
_form.BringToFront();
}
}
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Still the same, even when I tried in SplitContainer ;/
|
|
|
|
|
you then need to show how the combo's are generated and populated.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I create it in visual studio (from toolbox) and even empty comboboxes with default settings, no code, just draged and droped has the same behaviour.
|
|
|
|
|
..which is tucked away in a method called "InitializeComponent". That method is called when the form is created. Hiding the form and showing it won't execute the method again. Yes, that may cause weird stuff.
I'd recommend showdialog a form and disposing it when done, preferably wrapped in a using -construct.
--edit
foxed fixed typo.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
Yeah exaclty. But when form is open in panel i can only click on blue site (http://postimg.org/image/lalx7hu9x/[^]) to write and cant edit text like in my movie. when i open the same form as new form i can click on blue and red site to start typing. In your solution is the same problem and its very annoying. Btw thank you for your help and involvement
|
|
|
|
|
Sorry stupid mistake, for this to work you have to change the border style of the form with the comboboxes to none.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Woow! Thank you so much I dont understand why it happens with borders but it works correctly. Again thank you so much
|
|
|
|
|
I added some code:
private void cbProducent_MouseClick(object sender, MouseEventArgs e)
{
if(cbProducent.Text == "")
{
cbProducent.Focus();
}
}
still cant click to writte in middle of text but it solves problem with blue and red sites ;D
|
|
|
|
|
Don't use Forms inside any other ContainerControl. Use UserControls, or Panels. Forms are "expensive" UI-components, and they do not play well used inside other Forms/Controls.
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin
|
|
|
|
|
Tanks for your reply The program that im actually writting is pretty small and its too late to make changes. But im sure I will consider your solution in my future applications 
|
|
|
|
|
Member 11822364 wrote: The program that im actually writting is pretty small and its too late to make changes. Nonsense.
«Tell me and I forget. Teach me and I remember. Involve me and I learn.» Benjamin Franklin
|
|
|
|
|
hi,
I need to explain a video about design algorithm
id3 ,please how can help me??
|
|
|
|
|
We can't.
We have no idea what your video is showing (and to be honest I have no desire to see it) - so how could we possibly help you explain it?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
There algorithm in C # called id3 I need to explain how it works and this algorithm
؟ 
|
|
|
|