|
Hi,
I believe changing a CONST type in the runtime is merely impossible... because its a compile-time constanst...
If you want to assign a value at runtime only for once and after if you want to deny any changes then you can use readonly.
However all this concepts are valid only when the assembly is loaded in to the memory.. means only while the application is running.... Once the application is stopped then, all the variables and objects in the program is lost whatever the type(CONST or ReadOnly doesnt matter).
If you want to retain the changes even after the application is closed, then saving the data in a separate file and accessing it, as and when required is the possible solution.
Have a Happy Coding.....
|
|
|
|
|
You can distribute the source file with the application, include some code to parse the source, find the text where the const variable is defined and change it. Then your program merely has to rebuild itself, exit and start the new version.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
Hi guys,
I've got a windows form with a datagridview linked to an access database. The third column in the datagridview is a list of numeric values. On load up I would like a textbox to display the average of all the values in this column. Can't quite figure it out.
Here's the code I have written:
<br />
int Counter = 0;<br />
double AverageCalc = 0;<br />
<br />
while (Counter < datagridview.Rows.Count)<br />
{<br />
string Average = null;<br />
Average = datagridview.SelectedRows[Counter].Cells[2].Value.ToString();<br />
AverageCalc = AverageCalc + Convert.ToDouble(Average);<br />
Counter++;<br />
}<br />
<br />
AverageCalc = AverageCalc / datagridview.Rows.Count;<br />
txtAverage.Text = AverageCalc.ToString();<br />
It loops through once, and then fails at:
Average = datagridview.SelectedRows[Counter].Cells[2].Value.ToString();
When Counter = 1
I'm not really sure what else to try, any advise would be greatly appreciated.
Thanks
Martin
modified on Wednesday, April 8, 2009 9:24 AM
|
|
|
|
|
its because you have only one row SELECTED and you are looping through all rows in datagridview
try
Average = datagridview.Rows[Counter].Cells[2].Value.ToString();
to loop through all rows
or
while (Counter < datagridview.SelectedRows.Count)
to loop only through selected rows
|
|
|
|
|
Oops I missed that out
|
|
|
|
|
Thanks alot, I knew it would be something simple like that.
|
|
|
|
|
It fails because ?
What is the exception ?
|
|
|
|
|
Hi,
I have a combo box which I am populating dynamically using Datatables.
The combobox acts as a selection point from where a user selects a value and accordingly charts are generated..!
The column i am populating changes dynamically and is never the same.
Now I want to add another option "ALL" in the combo box after/before I populate the combobox...such that my combo box should have all the values frm table as well as an item " ALL " I tried doing it, but it shows error.
Can anyone help me out please. how should i go abt it..?
I am making a Windows Application using C#.
Cheers
Jimish
|
|
|
|
|
One thing you could do is to modify the SQL query so that 'ALL' is in the datatable.
I.e. " SELECT Value1 FROM Table1 UNION ALL SELECT 'ALL' "
Then the option value will be in the datatable and you can select it.
|
|
|
|
|
Query input must contain at least one table or query.
It shows the above error..!
Jimish
|
|
|
|
|
Hi,
After binding your datatable / dataset to Combobox. Add below line.
cmBOX.Items.Insert(0,"ALL");
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
I had tried it earlier..but it shows the following error..:
Items collection cannot be modified when the DataSource property is set.
Jimish
|
|
|
|
|
Hi,
This might be the simplest thing ever. However.....
Our team have used SQL Reporting many times using a web page for the client to go to and select a report and a day from a calendar control then ping... a report opens in Excel and the client saves it on their PC.
What if I want to show the report in the space on my webpage below the calender and the 'select the report you want' dropdown menu. For the report to be inside my webpage?
Can I do this? We have only ever called ReportCommon.ExecuteExcel in our C# code behind page.
Even the report opening in it's own browser would be OK I guess but to the screen better.
Any thanks gladly received
Harvey
|
|
|
|
|
how to add tool tip, each items of combobox?
best Regards.
Tayfun
ISTANBUL/TURKEY
|
|
|
|
|
I don't think you can add a tooltip to each individual item of the ComboBox. However, you could hook into the SelectedItemChanged event and change the tooltip of the ComboBox depending on which item is selected
|
|
|
|
|
Whats the matter with u people? If anything went wrong from my side, then I wont refuse to apologize. But please reply to my queries. If you experts do like this to me, then I'll be left nowhere. Please, help me
|
|
|
|
|
What are you going on about?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I dont know, I dont get replies to my queries. Everyone says that I post wrong answers everywhere. Am I a jerk?
|
|
|
|
|
Rajdeep.NET wrote: I dont know, I dont get replies to my queries
Well unfortunately not even the most experienced of us 'experts' can no all the answers to all the problems, if people dont respond its generally because there is nobody available that can give a decent answer to the problem.
Rajdeep.NET wrote: Everyone says that I post wrong answers everywhere.
If you choose to post an answer to somebodies problem then do not say it cant be done if you dont know that for sure. If you do have an idea then post it as a suggestion and do not try to enforce that it is the only possible way unless you are certain it is. Even when you do offer your 'suggestion' you may still get some people who will knock it just cuz thats who they are. But if you know you have put a suggestion that works then dont worry about what others think. Atleast your putting in your own time to try help others
Rajdeep.NET wrote: Am I a jerk?
lol, i couldnt answer that as i dont know you.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
This site is free, people give their time freely to help. The downside is not everyone that is on the site that particular hour/day/month will have the required knowledge about your particular problem.
If you want fast guaranteed advice then you should search for a site that offers that, but you'll need to get your credit card out and pay.
I would also suggest you look at the reply I posted a few minutes ago.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Actually, I meant nothing like that. Maybe my questions are not efficient. But many say that I post wrong answers to queries posted by others.
Anyway, I'll keep on posting my queries here. No matter whatever happens. Only the site moderator can kick me off and not any Member (J_L_E_N). And from now on, even if I know the right answer, I'll never even try to reply. Coz my answers, cause fever to some person.
Happy programming,
Rajdeep.Crashed
|
|
|
|
|
It may be because you don't appear to be doing any research yourself, just asking CPians to do it for you.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I do research myself, but I dont recieve all those guidance that u guys get there in the West, U know where I stay? in Bangladesh. We get no good guidance here. Whatever we do, we do with our own knowledge and a little knowledge we get from books.
Happy programming,
Rajdeep.Crashed
|
|
|
|
|
All I have is a few old, battered books (none on C#), internet searches/MSDN look ups and CodeProject. Apart from the unrelated old books (yours are probably more relavent than mine!), you have the same.
3 years ago (although I have been programming in one language or another for over 25 years), I decided it was time for me to learn C#. That's when my 'relationship' with CodeProject began. This year I was awarded CodeProject MVP (approx 1 in 150,000 members), my certificate hangs very proudly on my wall. No more resources than you, just determination and a moderate level of intelligence, combined with a willingness to learn and take criticism.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Impressive....!!!!
Have a Happy Coding.....
|
|
|
|