|
So the situation is the folowing
Inside a tabview control; i add programaticly a number of tabs (the number is not fixed); on each tab i add a listview. My question is how do i add an event item so that when i click any item from any list i fill a textbox with something from that item; my code looks like this
public void lv_SelectedIndexChanged(object sender, EventArgs e)
{
while (n!=0)
{TabPage tp=new TabPage();
tabControl1.TabPages.Add(tp);
ListView lv = new ListView();
tabControl1.TabPages[k].Controls.Add(lv);
n--;
}
}
I've written just a portion of the code.Help will be apreciated.Thank you in advance.
Alex.
|
|
|
|
|
Immediately after creating the new listview instance, subscribe to the desired event.
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)
|
|
|
|
|
Hi,
not exactly sure what you want. Here are three pointers:
1.
you can program anything by code that you also could do interactively in Visual Designer; all VD does is add code in some file (myForm.designer.cs), there is no magic involved; look at such code, and do the same thing in the appropriate method yourself.
2.
you can share event handlers across multiple controls; all event handlers have a first argument object sender that serves to identify the exact sender of the event; you would probably have to cast it to the appropriate control type first.
3.
you may find it useful to somehow make one Control (say ListView) refer to another Control (say TabPage); every Control has a object Tag property that serves no particular purpose, so you can store anything you like there, and use it where useful. As an alternative you could create a map using a Dictionary.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: Control has a object Tag property that serves no particular purpose
It's purpose has always been to provide User-defined data associated with the object . I think it should be programmer-defined , but hey ho.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
That's what I meant to say, unlike the other properties Windows doesn't use it, so the programmer can store just anything in there.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: so the programmer can store just anything in there
Sshhh... some things should be kept secret, you may have just opened Pandoras Box!
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)
|
|
|
|
|
Someone had to put things in first for Pandora's box to work...
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
DaveyM69 wrote: just opened Pandoras Box!
I miss her
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
She's still around, changed her name to WPF.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
As I typed it, I remembered Spike's line in Notting Hill (I know that loses ALL my man points!)
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)
|
|
|
|
|
DaveyM69 wrote: I know that loses ALL my man points
#grrrrrnnnt# Have some o'mine. They're in this here can'o'woopass, do you want me top open it for you?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
What i want to do is the folowing|:
when i click a line from the listview the text from it should appear in a textbox
|
|
|
|
|
Read the previous answers, it's mostly there for you.
0. Listen for the event.
1. Identify which list raised it.
2. Read the value.
3. Wash, rinse and repeat.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I am trying to log a user into a site using HttpWebRequest or WebClient Class
Now the site will probably issue me some cookies that tell the browser i'm already logged in. I need to pass those cookies on subsequent requests so I can fetch the data on that page.
Thanks in advance
|
|
|
|
|
Exactly. As for the cookies, just copy all the cookies you receive in the Response to the subsequent Request(s). This is simple.
|
|
|
|
|
Can u Give me a sample code for that?
|
|
|
|
|
Hi,
I've a list box with 4 columns out of which one column has width as 0 and want to restrict the users to re size it and see the content. How can get this ?
Thanks
|
|
|
|
|
If you don't want the content vsible, why put it in the visible part of the control at all? I would either:
0. Store the required non visible data in the Tag property of the ListViewItem
1. Subclass ListviewItem to have a new property of the correct type to store the data to avoid unboxing/boxing associated with 0.
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)
|
|
|
|
|
I thought, oh here we go that's s stupid question. Then I read the details and remembered that I have the same problem, not one I worry about but it is there.
I use a DGV if I need to hide a column, it support visible. I also have a utility that loads any table/dataview into a listview that assumes the first field is the ID and it gets loaded into the tag property.
If the list is short I sometimes load the datarow into the tag property and only create cols for the fields I want to display.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Have some issues and questions about creating a .dll from code in the form of a string array and a file. I seem to be close, but errors are raised when the code tries to creat the .dll.
Main question is, does the 'OutputAssembly' refer to the file name to create? Whenever I run the code below it says it could not find the file that 'cp.OutputAssembly' is set to. Also if this line is commented out, it says it could not find a randomly named file in a temporary directory.
The other question I have is if there is any difference between creating the .dll from an existing file or a string array. I plan on having the system create a common .dll for both the main program and for other .dll's the main program creates. These non-common .dll's can then be used directly in other programs.
This code is to create the common .dll .
public CompilerResults CompileImageAquisition(string OutputFile)
{
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
CompilerParameters cp = new CompilerParameters();
CodeTypeReferenceCollection cref = new CodeTypeReferenceCollection();
cp.OutputAssembly = OutputFile;
cp.GenerateInMemory = false;
cp.TreatWarningsAsErrors = false;
cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\PresentationCore.dll");
cp.ReferencedAssemblies.Add("System.Drawing.dll");
cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.Windows.Forms.dll");
cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.XML.dll");
CompilerResults cr = provider.CompileAssemblyFromFile(cp, ImageCoderSourceLocation);
if (cr.Errors.Count > 0)
{
Console.WriteLine("Errors building {0} into {1}", ImageCoderSourceLocation, cr.PathToAssembly);
foreach (CompilerError ce in cr.Errors)
{
Console.WriteLine(" {0}", ce.ToString());
Console.WriteLine();
}
}
else
{
Console.WriteLine("Source {0} built into {1} successfully.", ImageCoderSourceLocation, cr.PathToAssembly);
}
return cr;
}
modified on Wednesday, July 22, 2009 6:51 AM
|
|
|
|
|
Replying to my own post. After some extra debugging I was able to get the compile sequence to create a .dll. Here is and updated code to show what was changed and give a working example for anyone else to use as an example.
'OutputFile' has the directory of the file you wish to create such as "C:\\Folder\\File.dll". You can also set 'cp.GenerateExecutable = True' to have it create a .exe file.
'cref' is the directory to a C# file, such as "C:\\Folder\\Code.cs", but can also be a .txt.
You should be able to modify the code so the 'ReferencedAssemblies.Add' lines look more like "cp.ReferencedAssemblies.Add("System.dll");", but I was having some issues with it not being able to compile without the full path. This could just be a bug in VS2010 beta.
public CompilerResults CompileImageAquisition(string OutputFile)
{
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
CompilerParameters cp = new CompilerParameters();
CodeTypeReferenceCollection cref = new CodeTypeReferenceCollection();
cp.OutputAssembly = OutputFile;
cp.GenerateInMemory = false;
cp.TreatWarningsAsErrors = false;
cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.dll");
cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\PresentationCore.dll");
cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.Drawing.dll");
cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.Windows.Forms.dll");
cp.ReferencedAssemblies.Add("C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.0\\System.XML.dll");
CompilerResults cr = provider.CompileAssemblyFromFile(cp, ImageCoderSourceLocation);
if (cr.Errors.Count > 0)
{
Console.WriteLine("Errors building {0} into {1}", ImageCoderSourceLocation, cr.PathToAssembly);
foreach (CompilerError ce in cr.Errors)
{
Console.WriteLine(" {0}", ce.ToString());
Console.WriteLine();
}
}
else
{
Console.WriteLine("Source {0} built into {1} successfully.", ImageCoderSourceLocation, cr.PathToAssembly);
}
return cr;
}
|
|
|
|
|
Hi Guys
I have quite an urgent problem which is really getting on my nerves...
I have a stream reader which goes through a file line by line, and extracts information. The problem I have though, is that for some reason, the very first character is getting left out...
string chkLine = ChkReader.ReadLine()
Does anybody know why this could be happening?
Thanks
oooo, the Jedi's will feel this one....
|
|
|
|
|
Is the first character anything special? What encoding are you using? Is the first character even there - check with a hex editor?
I use StreamReader quite a bit, and it's never given me a problem, and never left out any characters.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
The first character is a number. nothing special. It misses all of them though. It's not like it's just dropping a leading zero... It is very baffeling. Just does not make any sense.
oooo, the Jedi's will feel this one....
|
|
|
|
|
You mean it misses the first character of every line?
File:
0Hello
1There
2Goodbye
gives you three lines "hello", "There" and "Goodbye"?
What is so different about your code from the standard and very boring:
using (StreamReader sr = new StreamReader(@"C:\XXTemp\Lines.txt"))
{
string s;
while ((s = sr.ReadLine()) != null)
{
MessageBox.Show(s);
}
}
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|