|
Your code would work if you cleaned up the many obvious syntax errors in it so it would compile without error !
«I'm asked why doesn't C# implement feature X all the time. The answer's always the same: because no one ever designed, specified, implemented, tested, documented, shipped that feature. All six of those things are necessary to make a feature happen. They all cost huge amounts of time, effort and money.» Eric Lippert, Microsoft, 2009
|
|
|
|
|
As Bill says: if you fix the syntax errors by removing the spurious semicolons:
comboBoxLSKFontSize.Items.Add("10");
comboBoxLSKFontSize.Items.Add("11");
comboBoxLSKFontSize.Items.Add("12");
comboBoxLSKFontSize.Items.Add("13");
comboBoxLSKFontSize.Items.Add("14");
comboBoxLSKFontSize.Items.Add("15");
comboBoxLSKFontSize.Items.Add("16");
stringLSKFontSize = "14";
i = 0;
foreach (string str in comboBoxLSKFontSize.Items)
{
if (stringLSKFontSize == str)
{
comboBoxLSKFontSize.SelectedIndex = i;
break;
}
i++;
}
Then that code should work, assuming that stringLSKFontSize and i have been declared. But with the errors, it won't compile, which means that it doesn't produce an executable file, so you will be running the last version that did compile correctly and your changes do not have effect.
If once it compiles you still have the problem, then use the debugger by putting a breakpoint on the line:
stringLSKFontSize = "14";
And step though your code to find out exactly what it is doing.
And you do realise that you don't have to do that at all, right?
comboBoxLSKFontSize.Items.Add("10");
comboBoxLSKFontSize.Items.Add("11");
comboBoxLSKFontSize.Items.Add("12");
comboBoxLSKFontSize.Items.Add("13");
comboBoxLSKFontSize.Items.Add("14");
comboBoxLSKFontSize.Items.Add("15");
comboBoxLSKFontSize.Items.Add("16");
comboBoxLSKFontSize.SelectedItem = "14";
Will do exactly the same thing...
BTW: It's not considered good practice to put the type of the variable as part of the variable name: you should consider using just LSKFontSize and LSKSelectedFontSize instead. Visual Studio will tell you the type of a variable if you just wave your mouse over the variable name.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thanks for taking the time to detail your response Griff...!!!
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
hi guys ;
how to add a image to header of exportinf pdf in devexpress gridview
|
|
|
|
|
Could someone please explain to me what´s going on in this conversion. I dont understand the result.
byte[] arr = new byte[6] { 68, 65, 84, 65, 13, 10 };
string str = Encoding.ASCII.GetString(arr);
According to the ASCII table the bytes mean DATA\n\t. (13=CR='\n', 10=LF='\r') But the string receives DATA\t\n !?!
If I change their places { 68, 65, 84, 65, 10, 13 } the string receives DATA\n\t.
Why does the CR and LF change place? Im really confused here.
|
|
|
|
|
You have the nomenclature a little mixed up:
CR = 13 = '\r'
LF = 10 = '\n'
TAB = 9 = '\t'
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thankyou! Thought I was getting insane.
|
|
|
|
|
I use C dll functions in C#. It works fine except I have a memory leak.
The first C function I use allocates memory (with malloc) and returns an array of string (char***) and the second one frees the memory (using free).
When I test those functions in a C program everything is ok - there are no memory leaks. However when I use those functions in a simple C# program using just thos functions I have a memory leak.
I 'm sure I'm doing something bad but I can't figure out what.
My code :
[DllImport("TestERP.dll", CallingConvention = CallingConvention.StdCall)]
private static extern int GetArray(string baseval,ref int nb,ref IntPtr array,IntPtr msg);
[DllImport("TestERP.dll", CallingConvention = CallingConvention.StdCall)]
private static extern int freeMemory( int nb, ref IntPtr array);
public static void GetManagedArray()
{
string[] tmp = new string[12];
int nb = 0;
IntPtr msg = Marshal.AllocHGlobal(256);
string tmp2 = "";
IntPtr intArr = IntPtr.Zero;
GetArray("val",ref nb, ref intArr,msg);
for (int i = 0; i < nb; i++)
tmp[i] = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(intArr, i * IntPtr.Size));
tmp2 = Marshal.PtrToStringAnsi(msg);
Marshal.FreeHGlobal(msg);
freeMemory(nb, ref intArr);
intArr = IntPtr.Zero;
GC.Collect();
}
I add the code of C functions :
int __stdcall GetArray(char base[],int* nb,char*** array,char* outmsg)
{
int i =0;
(*array) = (char**)calloc(12, sizeof(char*));
for (i = 0; i < 12; i++)
{
(*array)[i] = calloc(256,sizeof(char));
sprintf((*array)[i],"%s %d",base,i) ;
}
*nb= 12;
strcpy(outmsg,"message erreur");
return 0;
}
int __stdcall freeMemory(int nb,char*** array)
{
int i =0;
for (i = 0; i < nb; i++)
{
free((*array)[i]);
(*array)[i] = NULL;
}
free((*array));
*array = NULL;
return 0;
}
|
|
|
|
|
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.
|
|
|
|
|