|
i have a windows application. which contents a button and a list box when i click the button the list box is filled with the name of file. then i again copy some more file to directory when i click the button again then the name of same file and new file is displayed again which is obviuos.but what i want is in the secnd click it display only the files whic are copied on second instance i.e all the file in directory with out repetation.
well my problem is quiet complex if you have any idea regarding seacrhing in array where getfiles returns would be more appreciable.
|
|
|
|
|
After the 1st process of the files, clear the listbox.
|
|
|
|
|
As Ed Said Just clear the list box but do this before any processsing. So the first line of code in your button event would be:
ListBox.Items.Clear();
Keith
|
|
|
|
|
hi
i want to use iframe tag and set src to one htm file that have picture, but when i use this tag,pictures is not appeare in my webpage,but when i use htm file in browser, it show pictures. where is the problem and how to full my htm file(with images) in ?
note : the images folder already exist in my project.
|
|
|
|
|
Post your code, so we can see where the problem is.
|
|
|
|
|
I do an electronic project, and I would like to know how can I communicate to usb port with c# (in visual studio program).
I only know that I need a dll file and I don't know where can I find it.
tankes,guy.
|
|
|
|
|
|
Hi,
I have a class A that creates subclasses B and those classes have an event OnChanged that is assigned to a procedure in the mainclass A.
Subclass B can be serialized to XML using SOAP so i can send it by TCP to another location / application.
Class B is marked [Serializable] (and ofcours class A not because i don't need to send it.)
Strange thing is when the event OnChanged in class B is not assigned it delivers no problem.
when the event is assigned SOAP needs Class A to serialize also and ofcours it gives an error because that class A is not serializable..
So this is my problem...
I tried to use [nonserializable] for the public event in class B but this isn't allowed..
Anyone any idea how i can solve this problem ?
settings the event to null and assign it again after serialization could be possible but ofcours that is not a very good proper way to do it.
thx for your time
Kurt
|
|
|
|
|
K,
meanwhile we've found it.
i placed this before my event declaration...
[field:NonSerialized]
greetz
Kurt
Thx to dimi.
|
|
|
|
|
I have a array of string .How can I place the array to byte
String[] mm = {"A","B","C"};
byte[] by = new byte[3];
by = mm; This one make error
How can solve this problem.
Continue...
|
|
|
|
|
Hi
YOu are assigning string values to byte, thats why its giving error. You can use following code
String[] mm = {"A","B","C"};
byte[] by = new byte[3];
for (int i = 0; i < mm.Length; i++)
{
by[i] = Convert.ToByte(mm[i]);
}
|
|
|
|
|
Generally you can't convert a string to a byte. For example a string like "Hello world!" does not fit into a single byte.
If you have a special case where all strings always are exactly one character long, you can get that character and get the character code for it.
The character code is still 16 bits, though, while a byte only is 8 bits. To store a character code in a byte only works if the characters are all only ASCII characters, so that you can safely discard the top 8 bits of the character code.
---
Year happy = new Year(2007);
|
|
|
|
|
Hi all,
I'm wondering whether any of you people can help me out with this problem that I have with a user control that I have been trying to get working.
The first part of the user control is a flat circular button ( called SampleButton) that toggles colour when clicked. This control has an OnClick method as follows
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
(code to change colour and call invalidate....)
}
Then, from this I am creating a matrix of these buttons in another user control that inherits from SampleButton (which in turn inherits from UserControl), e.g. a 3 x 3 matrix, like so:
O O O
O O O
O O O
I do this using a couple of for loops (the number of SampleButtons has to be dynamic), a bit like:
for (int i = 0; i <= 2; i++)
{
for (int j = 0; j <= 2; j++)
{
SampleButton samBtn = new SampleButton();
samBtn.Location = new Point(i, j);
this.Controls.Add(samBtn);
}
}
}
In this control I have an OnClick method:
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
MessageBox.Show("The Sample Button Array has been clicked");
}
The problem is that although when I click on the array of sample buttons, their colour changes (so the first OnClick method is running ok), the messagebox never appears (the method is never entered).
Why does this second OnClick method never get called?
Thanks,
Rob
|
|
|
|
|
When you click a SampleButton its OnClick fires, and it causes its base.OnClick to fire
since that is what you requested; but its base is Button, not your 3x3UserControl.
If your 3x3UserControl wants events for its buttons, it should include the line
samBtn.Click+=new EventHandler(...);
where it creates the buttons.
Luc Pattyn
|
|
|
|
|
Hi,
Thanks for your reply Luc. I added the code to add event handlers for each button and tested the event within the User Control designer and all seems fine there. However, when I add a Button Array to a windows form, and create a Click event for the whole array:
private void buttonArray1_Click(object sender, EventArgs e)
{
MessageBox.Show("Button array has been clicked");
}
(and this.buttonArray1.Click += new System.EventHandler(this.buttonArray1_Click) in the initialiseComponent method)
This event does not trigger. This was one reason why I added the OnClick method to the ButtonArray control as I thought that by doing this it would allow clicks on the ButtonArray to be handled within my form (my logic is probably completely wrong here)
Thanks again,
Rob
|
|
|
|
|
Hi,
as far as I understand, when you click the mouse, Windows will fire one event, towards the control that "most deserves" it. If two controls dont overlap, things are obvious;
if one control is inside another in the normal way, the smallest one would get the event.
(Behavior will be influenced by Z-order, by Visible=false, Enabled=false and possibly
many others).
From there on it is up to your code who else may get an event:
- your base class if you call base.OnClick
- and/or anything else that has told your control it is interested (as you now do
with the 3x3UserControl signing up to each of the samBtn.
SO if you have an object buttonArray1 that is interested in the clicks of samBtn,
you must apply a samBtn.Click+=new ..., and not a buttonArray1.Click+=new ...)
Hope this clarifies things.
Luc Pattyn
|
|
|
|
|
Hi,
I also had the samBtn.Click+=....in the loop attaching a common handler each button ...to no avail.
However your comments got me thinking about exactly what was happening (in terms of only 1 event and overlapping controls) and I think I realise why its not working. The problem is that I have a usercontrol that is *full* of buttons. When I added the buttonArray1.Click+= part to the user control and hopeing to catch this, it was not firing because that would *only* fire if I clicked on an *empty* part of the userControl and not a button. If I click on a button, then that SampleButton "most deserves it" and deals with it correctly (it changes colour). As there is no part of the user control that is empty, its never going to work.
Maybe what I need to do is raise a new event from the change colour event and catch that in my main form.
Thanks again,
Rob
|
|
|
|
|
Hi everybody,
I got a big problem dealing with regular expression, I want to extract the text between the body Tag (<body>…</body>) from a html document
I’m using this code
string [] strTabBody; // table containing Body message in case of many Body tag
string sContenu ; // Html returned without Body tag
MatchCollection MatchCase;
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled;
// regular expression to represent the body tag
Regex regSeparBody = new Regex(@"</?(?i:body)(.|\n)*?>*.</?(?i:body)(.|\n)*?>",options);
if(regSeparBody.IsMatch(sContenu))
{
MatchCase = regSeparBody.Matches(sContenu);
sContenu =MatchCase[0].Value.ToString();
}
return sContenu;
the problem is with this kind of text.
String IN:
"<BODY bgColor=#ffffff><DIV> </DIV><DIV style=\"FONT: 10pt arial\">----- Original Message ----- </DIV></BODY>"
String OUT:
"f<DIV> </DIV><DIV style=\"FONT: 10pt arial\">----- Original Message ----- </DIV>"
-->the f charachter musn’t be in my output string
Can anyone correct my regular expression ??
Thanks!!
-- modified at 8:13 Tuesday 16th January, 2007
|
|
|
|
|
I think the formatting has eliminated the regular expression. Try placing it in a pre tag or click the ignore html checkbox.
|
|
|
|
|
it's done! this is the regular expression:
Regex regSeparBody = new Regex(@"</?(?i:body)(.|\n)*?>*.</?(?i:body)(.|\n)*?>",options);
|
|
|
|
|
The following should give you what you are looking for:
string HeadText = Regex.Replace(HTMLText, @"</?(?i:body)(.|\n)*?>(?<inner_text>.*)</?(?i:body)(.|\n)*?>", "<inner_text>");
HTMLText is the full html text.
|
|
|
|
|
When I use a System.Drawing.Font object in a multithreaded environment, I get a InvalidOperationException when I try to add it to a font-collection.
I'm writing a program that generates pdf documents based on a pdflibrary. Every document is generated in a singlethreadapartment. To add text with a certain font to the document, I have to create a font object and add it to the font-collection of the document:
<br />
string _font = elem.GetAttribute("Font");
int fontSize = Int32.Parse(elem.GetAttribute("FontSize"));<br />
Font _f = new Font(_font, fontSize);<br />
font = page.Fonts.Add(_f);
As long as I have only one thread running, it works fine, but when I start two or more threads, an InvalidOperationException is thrown in the line
font = page.Fonts.Add(_f);
The code that starts a thread to generate a pdf:
Thread thread = new Thread(new ThreadStart(convert));
thread.SetApartmentState(ApartmentState.STA);<br />
thread.Start();
VisualStudio also proposes to "call the Release-HDC-method, when you use the graphicobejct after the gethdf-method".
Can you help me how to use the font object in the context above to avoid the Excption?
this is the whole error message:
System.InvalidOperationException wurde nicht behandelt.<br />
Message="Das Objekt wird bereits an anderer Stelle verwendet."<br />
Source="System.Drawing"<br />
StackTrace:<br />
bei System.Drawing.Graphics.get_DpiX()<br />
bei Syncfusion.Pdf.Implementation.Objects.Fonts.PDFTrueTypeFont.RecreateFont()<br />
bei Syncfusion.Pdf.Implementation.Objects.Fonts.PDFTrueTypeFont.Initialize(PDFDocument document)<br />
bei Syncfusion.Pdf.Implementation.Collections.PDFFontCollection.Add(IPDFFont font)<br />
bei Syncfusion.Pdf.Implementation.Collections.PDFFontCollection.Add(Font font, Boolean embbed)<br />
bei Syncfusion.Pdf.Implementation.Collections.PDFFontCollection.Add(Font font)<br />
bei Report_Generator.ReportGenerator.generatePDFReport() in C:\WINXP\Profiles\Hans-Peter\Eigene Dateien\Visual Studio 2005\Projects\Essential Studio\Report Generator\Report Generator\ReportGenerator.cs:Zeile 252.<br />
bei Report_Generator.ReportGenerator.start() in C:\WINXP\Profiles\Hans-Peter\Eigene Dateien\Visual Studio 2005\Projects\Essential Studio\Report Generator\Report Generator\ReportGenerator.cs:Zeile 135.<br />
bei Report_Generator.Form1.convert() in C:\WINXP\Profiles\Hans-Peter\Eigene Dateien\Visual Studio 2005\Projects\Essential Studio\Report Generator\Report Generator\Form1.cs:Zeile 85.<br />
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
bei System.Threading.ThreadHelper.ThreadStart()
thanks, haape
-- modified at 10:09 Tuesday 16th January, 2007
|
|
|
|
|
How can I Collapse and Expand (CrystalReport) sections programmatically using C#
Regards.
|
|
|
|
|
So i create a webservice...
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
}
and run it...
then i create a pocket pc application.. that should consume this webservice...
add reference to the webservice...
then in the button function i write this:
private void button1_Click(object sender, EventArgs e)
{
localhost.Service x = new localhost.Service();
label1.Text =x.HelloWorld().ToString();
}
then i run this project...wait till it loads...press the button and get the following error
"Unable to connect to the remote server"
i'm waiting for your replies
thank you
|
|
|
|
|
Hi
I am trying to test with windows mobile 5.0 emulator..using C#.Net..
but myHttpWebResponse is always null.httpwebexception coming. Please anybody help me..
This is code:
public static void httpRequest(string uri, bool isGetMethod)
{
try
{
Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create(uri);
if (isGetMethod)
myRequest.Method = "GET";
else
{
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
Stream newStream = myRequest.GetRequestStream();
newStream.Close();
}
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myRequest.GetResponse();
Stream streamResponse = myHttpWebResponse.GetResponseStream();
StreamReader streamRead = new StreamReader(streamResponse);
Char[] readBuffer = new Char[256];
int count = streamRead.Read(readBuffer, 0, 256);
string result = "";
while (count > 0)
{
string resultData = new String(readBuffer, 0, count);
result = result + resultData;
count = streamRead.Read(readBuffer, 0, 256);
}
HTTPClass.resultData = result;
streamRead.Close();
streamResponse.Close();
myHttpWebResponse.Close();
}
catch(Exception e)
{
MessageBox.Show(e.Message.ToString());
}
}
Anybody help me..
Thanks
|
|
|
|