Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Cache a DB2 Dynamic Query in ADO.net Pin
Dave Kreskowiak4-Oct-18 6:22
mveDave Kreskowiak4-Oct-18 6:22 
GeneralRe: How to Cache a DB2 Dynamic Query in ADO.net Pin
kumarkoppireddy4-Oct-18 6:25
kumarkoppireddy4-Oct-18 6:25 
GeneralRe: How to Cache a DB2 Dynamic Query in ADO.net Pin
Dave Kreskowiak4-Oct-18 6:46
mveDave Kreskowiak4-Oct-18 6:46 
GeneralRe: How to Cache a DB2 Dynamic Query in ADO.net Pin
OriginalGriff4-Oct-18 6:32
mveOriginalGriff4-Oct-18 6:32 
GeneralRe: How to Cache a DB2 Dynamic Query in ADO.net Pin
Mycroft Holmes4-Oct-18 12:48
professionalMycroft Holmes4-Oct-18 12:48 
Questiondisplay value of a key in dictionary to text box and edit value and save out to file Pin
elfenliedtopfan53-Oct-18 14:02
elfenliedtopfan53-Oct-18 14:02 
AnswerRe: display value of a key in dictionary to text box and edit value and save out to file Pin
Maciej Los3-Oct-18 20:28
mveMaciej Los3-Oct-18 20:28 
AnswerRe: display value of a key in dictionary to text box and edit value and save out to file Pin
OriginalGriff3-Oct-18 20:35
mveOriginalGriff3-Oct-18 20:35 
You can read a value from a textBox very simply, by using it's Text property:
C#
string myString = mMyTextBox.Text;
And you can use that anywhere you wanted - as the key value for a dictionary for example:
C#
value = myDictionary[myTextBox.Text];

But ... the code you show creates the dictionary, but it then throws it away again, as it is only stored as a local variable in your processfile method. You need to decide what you want to do with your dictionary, and either return it from the method (if it's going to be relatively temporary), store it in a class level variable (if it's going to be needed for the whole life of the class instance), or in a static class level variable (if you need to share it between several instance of the class).

BTW: sort out your indentation! it's a mess, which means the code is probably a mess as well: Visual Studio helps you with the indentation as you go along, so bad indentation normally means your code doesn't compile because the system doesn't understand it!
And never do this:
if (false == dic.ContainsKey(k)) dic[k] = v; else dic[k] += "," + v;
There are two things wrong here:
C#
if (false == x) ...
That's messy and hard to read. Us etehis instead:
C#
if (!x) ...
The other is this:
C#
if (x) y; else z;
Indent it, and (certainly while you are a beginner) always use brackets:
C++
if (x)
   {
   y;
   }
else
   {
   z;
   }
It doesn't matter what bracketing style you use, as long as you are consistent:
C++
if (x)
{
   y;
}
else
{
   z;
}
Works as well.
So your code ends up as:
if (!dic.ContainsKey(k))
   {
   dic[k] = v; 
   }
else 
   {
   dic[k] += "," + v;
   }
But for advanced users, we'd go with:
dic[k] = dic.ContainsKey(k)) ? dic[k] + "," + v : v;

Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

AnswerRe: display value of a key in dictionary to text box and edit value and save out to file Pin
dan!sh 3-Oct-18 20:36
professional dan!sh 3-Oct-18 20:36 
AnswerRe: display value of a key in dictionary to text box and edit value and save out to file Pin
BillWoodruff14-Oct-18 15:21
professionalBillWoodruff14-Oct-18 15:21 
QuestionOPC client server Pin
Roberto64_Ge3-Oct-18 2:28
Roberto64_Ge3-Oct-18 2:28 
AnswerRe: OPC client server Pin
Richard MacCutchan3-Oct-18 3:11
mveRichard MacCutchan3-Oct-18 3:11 
GeneralRe: OPC client server Pin
Roberto64_Ge3-Oct-18 4:10
Roberto64_Ge3-Oct-18 4:10 
GeneralRe: OPC client server Pin
Richard MacCutchan3-Oct-18 4:52
mveRichard MacCutchan3-Oct-18 4:52 
GeneralRe: OPC client server Pin
Roberto64_Ge3-Oct-18 9:51
Roberto64_Ge3-Oct-18 9:51 
GeneralRe: OPC client server Pin
Richard MacCutchan3-Oct-18 22:02
mveRichard MacCutchan3-Oct-18 22:02 
GeneralRe: OPC client server Pin
Dave Kreskowiak3-Oct-18 5:00
mveDave Kreskowiak3-Oct-18 5:00 
GeneralRe: OPC client server Pin
Roberto64_Ge3-Oct-18 10:10
Roberto64_Ge3-Oct-18 10:10 
GeneralRe: OPC client server Pin
Roberto64_Ge4-Oct-18 3:28
Roberto64_Ge4-Oct-18 3:28 
GeneralRe: OPC client server Pin
OriginalGriff4-Oct-18 3:46
mveOriginalGriff4-Oct-18 3:46 
GeneralRe: OPC client server Pin
Dave Kreskowiak4-Oct-18 4:29
mveDave Kreskowiak4-Oct-18 4:29 
GeneralRe: OPC client server Pin
Roberto64_Ge4-Oct-18 20:33
Roberto64_Ge4-Oct-18 20:33 
GeneralRe: OPC client server Pin
Dave Kreskowiak5-Oct-18 2:16
mveDave Kreskowiak5-Oct-18 2:16 
GeneralRe: OPC client server Pin
Roberto64_Ge8-Oct-18 2:16
Roberto64_Ge8-Oct-18 2:16 
GeneralRe: OPC client server Pin
Dave Kreskowiak8-Oct-18 4:10
mveDave Kreskowiak8-Oct-18 4:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.