|
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
|
|
|
|
|
My code is:
while (chkReader.Read())
{
string chkLine = chkReader.ReadLine();
}
I just created a new text file of my very own and pointed my app at it and got the following:
Actual line in file: "Hello There"
Line picked up in chkReader.ReadLine(): "ello There"
oooo, the Jedi's will feel this one....
|
|
|
|
|
There's your problem: the while(chkReader.Read()) reads and discards the first character of each line...
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
|
|
|
|
|
Your completely right... I can't believe I didn't spot that... More coffee is required me thinks!!!
Thank you
oooo, the Jedi's will feel this one....
|
|
|
|
|
You're welcome - I have days like that meself!
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
|
|
|
|
|
Try setting a break point in the below code snippet:
<br />
foreach (char c in ChKReader.ReadLine())<br />
{}<br />
See if it is picking it up using that.
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
Just tried your suggestion. It still misses it out...
oooo, the Jedi's will feel this one....
|
|
|
|
|
Is the text file ANSI encoded?
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
Thats the assumption I'm making. Although I'm not sure how to check.
The text file appears to be a straight forward text file for use with the likes of notepad.
oooo, the Jedi's will feel this one....
|
|
|
|
|
Well its hard to say, I would try creating a whole new text file, and typing in a few of the problem lines. That way you will know if the problem is the text file or your code.
The code you posted should work fine...
Mark Brock
"We're definitely not going to make a G or a PG version of this. It's not PillowfightCraft." -- Chris Metzen
|
|
|
|
|
Hi,
you could create your special stream reader that does exactly that, or there could be something very special about your file (not sure what). To make sure, use a hex editor/dumper to look at the first few lines of data.
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.
|
|
|
|
|
Hey does any body knows how to write a javascript code using the code behind in .NET
for example i use Response.Write("<script language='javascript'>alert('x');</script>");
It works but am searching for another method that i could use
modified on Wednesday, July 22, 2009 5:58 AM
|
|
|
|
|
It'll work every time.Can you give detail when its not working
Cheers!!
Brij
|
|
|
|
|
I edited the the question. becuase yes it works but the problem that am facing with it is that i am using the following Master Page --> Tab --> Grid -- > Text Box
An doing the following
response.write("document.getElementById('"+txt.Text+"').focus();");
it tells me that object is null and gives a js Error
I am using this method on page load so directly the focus will be on that textbox. The JS code that i wrote works fine if i paste it in the URL tab so there is no problem with syntax.
|
|
|
|
|
response write writes the code to the begining of the page. Pages are rendered by browser from top to bottom. That means when you are trying to get an object that object is not still created. So instead of response write use Page.ClientScript.RegisterStartupScript method.
|
|
|
|
|
Could you explain more about this method
|
|
|
|