|
What you haven't mentioned is what makes you think you have a memory leak?
If you're using TaskManager to tell you this, it's lying to you.
Use PerfMon instead.
|
|
|
|
|
|
i have been trying to use fileupload control By Razor html fileupload control,it works solo but with combination of textboxfor,lable and its are all placed inside the table while its not working icant sync the control with httppostedfile variable
|
|
|
|
|
how to change the background color of cell when I click on ? of Devexpress Grid. I have a devexpress xtragrid with 7 columns. I want to change the cell background color when i click select. I try with GridViewInfo but it only takes the columns that are visible on the screen.But I want to do for all the columns.(Not with RowCellStyle) Do you have a solution for that? Thank you!
private static DataTable CreateTable(int RowCount)
{
DataTable tbl = new DataTable();
tbl.Columns.Add("Question", typeof(string));
tbl.Columns.Add("A", typeof(string));
tbl.Columns.Add("B", typeof(string));
tbl.Columns.Add("C", typeof(string));
tbl.Columns.Add("D", typeof(string));
tbl.Columns.Add("E", typeof(string));
for (int i = 0; i < RowCount; i++)
tbl.Rows.Add(new object[] { String.Format("Question: {0}", i), "", "", "", "", "" });
return tbl;
}
public Form1()
{
InitializeComponent();
gridControl1.DataSource = CreateTable(5);
}
private void gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
{
GridView View = sender as GridView;
if (e.Column.FieldName == "A" || e.Column.FieldName == "B" || e.Column.FieldName == "C" || e.Column.FieldName == "D" || e.Column.FieldName == "E")
{
if (e.RowHandle >= 0)
{
e.Appearance.BackColor = Color.Green;
}
}
}
[IMG]http://imagizer.imageshack.com/img540/4282/ZM1KU0.jpg[/IMG]
|
|
|
|
|
Hi,
EveryBody,
Thanks for ur answers,it's really very helpful...
But my confusion is that:-
Just like array store the values of same data type, in the same way loop is also used to store value of same data type.That means i know that loop is used to avoid repetition of the code .But my question is that loop is also used to store Values???
Thanks...
In Advance...
|
|
|
|
|
Look at this example: Code: Iterating Through an Array (Visual C#)[^]
Unlike single-value variable, array is a multi-value variable that stores multiple values of like nature each of which is identified by a unique index number starting from zero, you may liken it to an apartment block with a unique name (variable name) comprising many units each with a different unit number (index number). Another example, is array name 'month' that stores the names of the 12 months as its elements.
This is an array of integer numbers. The first element of this array which is 1 is identified by numbers[0], the second number[1] and so on.
int[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9};
This is a loop which cycles through the same set of code (action) with different input at each cycle and thus produces different outputs for each cycle.
foreach (int element in numbers)
{
System.Console.WriteLine(element);
}
Read more:
1. https://msdn.microsoft.com/en-us/library/9b9dty7d.aspx[^]
2. http://www.tutorialspoint.com/csharp/csharp_arrays.htm[^]
3. http://www.tutorialspoint.com/csharp/csharp_loops.htm[^]
|
|
|
|
|
Member 11161625 wrote: loop is also used to store Values
No.
|
|
|
|
|
An Array is a block of memory that holds a set of data. It is where information is stored.
A Loop is a set of instructions which may act upon that (or any other) data.
There is no similarity between the two, they are totally different in every way.
|
|
|
|
|
Forget values, forget types. In fact forget C# and programming in general. They have nothing to do with loops.
This is a loop:
1. eat a cupcake
2. if there are more cupcakes, go to step 1 Values? Types? Nope, just a list of instructions where there is a back-reference that can cause some instructions to be performed multiple times. That is the nature of a loop.
|
|
|
|
|
Hi,
Loops does not store values... They can retrieve values from arrays, but it is only one use.
Think about this problem: call a function 10 times. For example: write on the console 10 asterisks..
So you'll have to use the Console.WriteLine("*");
And you'll write it ten times in your code, but if I ask you to do it 1000000 times, what do you do? You'll write the same instruction 1000000 times, and if I ask you to change the * to €, you will, surely shoot me becuase you'll have to change 1000000 lines of code. Instead, if you use a loop, changements are immediate:
for (int i=0; i<how_many_asterisks_you_want; i++)
Console.WriteLine("*");
Just a little curiosity: even if it is not adviced to do it,you van omit curly brackets if you construct (if, any loops, using, etc.) has only one line inside it as the example above.
Do you Understand it now ? Loops does not store anything, they can retrieve stored values, but they are really powerful and this isn't their only purpose as demonstrated above.
Hope this helps.
Ps: you should not post the same question twice, just reply to your own question to say that you need more information
Lusvardi Gianmarco
|
|
|
|
|
Array is a variable (in fact collection of same type of variables) to store value.
while loop is process (set code) to do something.
array store data but loop works on data.
you can use array in loop but vise verse is not feasible (doesn't make any seance).
|
|
|
|
|
hi how Fill dataGrid from MySQL database in C# WPF.
|
|
|
|
|
|
In your ViewModel or codebehind get the collection from the database.
Assign the collection to an observable object property (implementing INotifyPropertyChanged)
In your view assign the ItemSource of the grid to the observable collection property
Add column definitions for the columns you want to display.
Seriously, get a book and work through the examples or work through some articles here on CP
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Asalam Alaikum friends;
I need a help of ERD of fee management system which keep the record of whole year and print for a single students that record
|
|
|
|
|
You have to spell out what you need help with instead of the just saying "I need help" and leaving it at that.
|
|
|
|
|
Hi
I am developing a c# Winforms application using VS 2008 and DevExpress.
In one form, I need the some data to be added both in English and Chinese Language. So I placed separate textboxes for both Chinese and English and two buttons on form. one Button click shows Chinese language section and changes Inputlanguage . Second button hides Chinese language section, Changes InputLanguage .
When I run the application, First time when I change to Chinese Language, I am getting Chinese language selection option on typing English letter combination. But after returning to English, if I again go to Chinese data entry, I am not getting Chinese Language support on typing English.
But I am seeing the Language change on Taskbar.
Language Change Code
1st method
foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
{
CName = lang.Culture.EnglishName.ToString();
if (CName.StartsWith("Chinese"))
{
InputLanguage.CurrentInputLanguage = lang;
break;
}
}
2nd Method
Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-CN");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
I tried this with normal windows forms project and controls( Not Devexpress form) still the issue not solved. If we change input language manually at Taskbar, I am getting Language selection option. The Issue is only with language change from code.
Please give me a immediate advice
Thanks
Johnson
|
|
|
|
|
Hi,
I want to know what is difference between Array and
Loop.Is any one Knows,please tell me because i am little bit confuse???
Thanks...
In Advance...
|
|
|
|
|
Arrays are used to store data. A single array can contain multiple items for for example numbers. Loop then again is used for example to iterate through an array (or anything "countable").
An example :
int[] someArray = new int[5];
for (int counter = 0; counter < 5; counter++) {
someArray[counter] = counter;
}
Have a look at Arrays (C# Programming Guide)[^] and for[^] or while[^]
|
|
|
|
|
Two totally different things, but often used together.
An array could be the floors in a building, while a loop could be like an elevator that you can use to visit those floors.
|
|
|
|
|
Nice example
|
|
|
|
|
Hi,
they are two completely different things:
Array:
An array is a set of homogeneous variables (I.E. they share the same type). it is declared in this way:
YourType[] yourArray = new YourType[noitems]
where noitems is the number of variables in the array.
To access a single variable you need to use an index. This index starts from 0, not from 1, so the array indicies will go from 0 to noitems-1 !!
YourType yourArrayVariable = yourArray[yourIndex];
Please keep in mind that if yourIndex points to a variable which does not exists in the array, a IndexOutOfRangeException will be thrown.
Arrays can also have multiple dimensions:
YourType[,] yourTable = new YourType[6,2];
it is a declaration of a table with 6 rows and 2 columns. You can imagine a single-dimension array as a single row, a two-dimensional array as a table and a three dimensional array as a cube.
There are also jagged arrays. While if you decalre your multi-dimensional array just like the code above you'll get a rectuagular table, with jagged arrays (or array of arrays), you can define your personal dimension for each element.
YourType[][] jaggedArray = new YourType[3][];
jaggedArray[0] = new YourType[3];
jaggedArray[0][2]
Loops are a completely different thing.
A loop enables you to do something repeatedly while a condition is true.
While loops will do the instructions inside their body while a condition is true. The condition is evaluated before the loop starts and, if it is false, the loop does not start.
<pre lang="c#">
while (condition){
}
There is another version of while which is the do...while loop. The only difference is that the condition is evaluated after the loop is executed. I.E. it is evaluated at the end, so the loop is executed at least once before evaluating the condition.
do{
}while(condition);
There is the for loop which is controlled by a variable which is usually an integer or, generally, a number:
for (declaration;condition;instruction){
}
for(int i = 0;i<5;i++){
}
The for loop has 3 different parts: the declaration of the control variable (actually, whatever instruction which has to be called before executing the first iteration of the loop), the condition (which is the condition to execute the loop as the other loops) and then the instruction, which is an instruction which is called at the end of each iteration. Usually, the for loop is used to increment a variable to access array elements.
string[] lines = new string[10];
for(int i = 0;i<10;i++){
Console.WriteLine(lines[i]);
}
Please keep in mind that the variable declared inside the decalration block of the for is valid for the for loop only and it is not available outside it.
If you want to make it available do this:
string[] lines = new string[10];
int i;
for(i = 0;i<10;i++){
Console.WriteLine(lines[i]);
}
And notice that the maximum value for i is 9 and not 10 as 10<10 = false.
The last loop is the best to deal with arrays. This is the foreach loop. This loop enables you to iterate over all the items in an array and store the current value in a variable.
This code will print all the numbers inside the array integers :
int[] integers = new int[20];
foreach(int i in integers){
Console.WriteLine(i);
}
Unfortunately, the foreach loop has not an index variable and, if you want it, you'll have to declare it explicitely.
Hope this helps.
Lusvardi Gianmarco
|
|
|
|
|
Could someone please explain to me why the callback method of an EventHandler<t> has to be static? According to the .NET documentation the delegate looks like this:
[SerializableAttribute]
public delegate void EventHandler<TEventArgs>(
Object sender,
TEventArgs e
)
No hint of static there. So, my second question would be;
If I want to declare a delegate which should take a static callback method, how to do that?
|
|
|
|
|
What makes you think that the method needs to be static ?
public class Foo
{
public event EventHandler<EventArgs> MyEvent;
public void Test()
{
var handler = MyEvent;
if (handler != null) handler(this, EventArgs.Empty);
}
}
public class Bar
{
private readonly Foo _foo;
public Bar()
{
_foo = new Foo();
_foo.MyEvent += MyEventHandler;
}
public void Test()
{
_foo.Test();
}
private void MyEventHandler(object sender, EventArgs e)
{
Console.WriteLine("Bacon.");
}
}
|
|
|
|
|
Well, Im not sure...
I tried to use the EventHandler<t> earlier, got error, and was under the impression that the non-static nature of the callback-method was the cause. So I changed the code declaring an explicit delegate and it worked. But now when I changed back it actually still works. So Im a little confused right now why it didnt work earlier.
Anyway. I can clearly see it works with a non-static method now. Just forget I asked
Thanks anyway.
|
|
|
|
|