|
That is still confusing to me. It is not really your typical popup because it was a link that I clicked on. I wasn't something opened by script code in the HTML code. So if I am controlling the event and telling it to open a new form with a browser control in it why would it override that and open a second window on top of that? I did see in my Google searches that people referenced something called NewWindow2 and NewWindow3 but that doesn't seem to be available for trapping under the web browser control.
|
|
|
|
|
I should mention that this worked correctly under the old ActiveX browser that we were using before.
|
|
|
|
|
The NewWindow event fires AFTER you click on a link that opens a new window (OR) use the "Open in a New Window" context menu (AND) BEFORE the new window actually opens. To cut the crap, this wont open a new Form with another webbrowser control on it. It'll only launch a new IE window.
If you want to open a new Windows Form, you've to put in your own code that opens a new Form with another web browser control and cancel the event so that IE is not launched.
SG
|
|
|
|
|
Once I was able to keep in mind that another event was firing to create the IE instance then I was able to cancel it and figure out what my other issues were. Thank you very much!
|
|
|
|
|
Hi,
I am new to C# Xml programming. Basically, I am trying to save a XML file to a database. I found that if I just take the below string and try to save it a table which contain a XML datatype column, it creates a SQL Exception:
SqlException: XML parsing: line 1, character 38, unable to switch the encoding
String Test_PSQ1 = @"<?xml version=""1.0"" encoding=""UTF-8""?><Data Type=""Query"" Version=""2.1""><Query Product=""Test""></Query></Data>";
I couldn’t find a good way to switch this encoding on my end in order to be able to save to the database, since SQL Server expects UTF-16 data. I tried to switch the encoding to UTF-16(Unicode) using the below cod but when I try to save to the database get an “illegal xml character” error. Moreover the data in alteredText looks like garbage data.
MemoryStream memStream = new MemoryStream();
StreamWriter swUtf16 = new StreamWriter(memStream, Encoding.UTF8, Test_PSQ1.Length);
swUtf16.WriteLine(Test_PSQ1);
int length = Convert.ToInt32(memStream.Length);
byte[] buffer = new byte[length];
memStream.Write(buffer, 0, length);
memStream.Seek(0, SeekOrigin.Begin);
String alteredText = System.Text.Encoding.Unicode.GetString(memStream.GetBuffer());
I did some investigation and found that, If I can remove “<?xml version=""1.0"" encoding=""UTF-8""?>” part from the XML string, the save would work fine. I am trying to do some XML parsing so that I can strip out this tag, but am unable to do so.
MemoryStream memStream = new MemoryStream();
StreamWriter swUtf16 = new StreamWriter(memStream, Encoding.Unicode, Test_PSQ1.Length);
swUtf16.WriteLine(Test_PSQ1);
int length = Convert.ToInt32(memStream.Length);
byte[] buffer = new byte[length];
memStream.Write(buffer, 0, length);
memStream.Seek(0, SeekOrigin.Begin);
XmlReader reader = new XmlTextReader(memStream);
test = reader.ReadElementString();
test = reader.Value;
if (reader.NodeType == XmlNodeType.Element)
{
test = reader.Value; ;
}
reader.Read();
if (reader.NodeType == XmlNodeType.Element)
{
test = reader.Value; ;
}
Any suggestions about the code, pointing to resources would be highly appreciated.
|
|
|
|
|
This should work:
XmlReader reader = new XmlTextReader(memStream);
reader.MoveToContent();
string NewXmlText = reader.ReadOuterXml();
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
Hello everyone,
I am trying to place an image into a button. The Image originally is placed in the DataGridView and using the following code I am placing it in the desited button.
btnItemImage0.Image = (Image)dataGridView1.Rows[ItemRowIndex0 - 1].Cells["item_image"].FormattedValue;<br />
The images have different sizes (They are mainly bigger than the button size!). Can someone tell me how I can resize the image to make sure the entire image is visiable in the button?
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
You can create instance of Bitmap class and specify sizes
|
|
|
|
|
I am having problems saving changes made in a datagrid to a database. I am using SqlDataAdapters with a generic "Select * FROM tbl" to load a dataset. I then assign the one table at a time to the control listing the contents of the table (all the tables are lookups for the application). Everything works great up to the point that the data is not being saved back to the server. It looks like it works. The problem is that it does not appear that the values in the datagrid are loaded back to the datatable. Here is how I am loading the grid (I am assuming that I am missing something basic here):
<br />
SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM [" + sTmp + "];", dbConn);<br />
dbTableAdp.Add(adp);
adp.FillSchema(dbSet, SchemaType.Source, sTmp);<br />
adp.Fill(dbSet, sTmp);<br />
adp.AcceptChangesDuringUpdate = true;<br />
adp.ContinueUpdateOnError = true;<br />
<br />
DataTable dt = dbSet.Tables["tablename"];<br />
if (dt != null)<br />
{<br />
dgLookups.DataSource = dt;<br />
}<br />
<br />
if (row.IsCurrentRowDirty == true)<br />
{<br />
DataRow dr = dbSet.Tables["tablename"].Rows[e.RowIndex];<br />
if (MessageBox.Show("Do you wish to commit changes to the database (Yes/No)?",<br />
"Values Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==<br />
DialogResult.Yes)<br />
{<br />
DataGridViewRow dgr = dgLookups.Rows[e.RowIndex];<br />
dgr.SetValues();<br />
dr.AcceptChanges();<br />
}<br />
else
{<br />
dr.RejectChanges();<br />
}<br />
}<br />
I am fairly new to using the DataGrid. I have tended toward using ListView since I normally don't allow direct access to the database. Any assistance will be a great help.
Leo T. Smith
Senior Programmer
|
|
|
|
|
Try this.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
I developed a Transactional Server that receives at leat a transaction per second.
The application has a pool of threads that resolve each incoming transaction. This threads use reflection for dynamic execution of generated source code. If the execution returns 0 the program send an approval. If the executions returns 0, the application creates a thread to notify the adminitrators of the systems.
The thread join was resolve creating a CollectorThread that receives a reference of every thread and it wait to them to die.
The application is working well, except for one issue. When each thread uses the Reflection to create the Dinamic execution the memory grows about 80kb, after that I disposed the object and wait for the garbage collector to clean that memory.
When the app is running in Windows XP everything seems to work just fine. But, when the app is running in Windows 2003 ( Dual Core 2 ) the memory grows and grows and it's never collect by the GC.
I also try the AppConfig GCServer option, but it didn't fixed the issue.
Somebody knows something about a bug with the Framework 2.0 in Windows 2003? Is there something else that reflection? (Besides programming my own parser)
Thanks.
rmga
|
|
|
|
|
Hi,
gc runs automatically when it needs to run (i.e. when free memory is needed and
not available); if your Win2003 machine has more memory,
or your process is allowed a larger working set, gc will not run (or only much
later).
So my guess would be there is no problem at all. You could try to (dis)prove this
by reducing the working conditions e.g. adding other, unrelated processes, and/or
changing system parameters reducing the default or max working set (which may
be larger on any Windows server).
BTW I do not recommend calling gc explicitly !
|
|
|
|
|
Hi,
Thanks for the advice. We hope that there are no problems with the code and it is just a configuration issue. Just a doubt, where can I change the max working set?
Thanks,
rmga
|
|
|
|
|
I forgot to tell you, When the application is running in Windows 2003 and it reach 200Mb, the app stop performing the reflection dynamic execution.
This is beacause the app try to request for more memory but the OS doesn't give the requested memory. From that momment the app could't verify the state of the incoming transaction and reponse OK to everything. (This was developed to do that, When the app tries to create an object and couldnt achieve to get enough memory, it approve the transaction)
In Windows XP works fine and always achieve to free memory and re-use it to complete each evaluation.
rmga
|
|
|
|
|
So there must be a real problem then.
Did you call Dispose() on everything you create (either with keyword new,
or by calling a method that has Create in its name) that offers a Dispose()
method ?
I would recommend you add logging (preferably to a file), so you can
track the major events in your app; then compare the log sequence when things
go wrong with the sequence when things are still fine.
|
|
|
|
|
Hi,
I dont know, I trust you can somehow but I never needed it.
|
|
|
|
|
I have added a microsoft word 2003 reference to a program of mine.
I use C# .net visual studio 2005.
It all works fine.
I create a release and a dll file called Interop.Word.dll is created.
The release work fine on my computer but when i try it on another it doesn't work.
Do you know why?
Word exists on the other computer.
Is it because word doesn't exists at the same location on the other computer?
|
|
|
|
|
Did you copy Interop.Word.dll to the other computer, this is what lets it talk to Word? Is it the same version of word on the other computer? When you say it doesn't work, do you get an error? If so what is the error? If not what are the symptoms?
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
Did you hard coded the dll location?? Well, DONT .. You can always use the pretty handsome System.Environment.SpecialFolder to locate special folders on different computers.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi!:
I have created a usercontrol with one textbox and a button, and I need this control to be loaded in the datagridview. In a cell the value is the text property of the textbox. I have seen some examples but with the keyboard and the focus have problems. (There are answers in some links by Mark Rideout and Zhi-Xin Ye, but not a complete example running with the keyboard).
Any complete code example?
Thanks
|
|
|
|
|
webbrowser in csharp ?.
my progressbar just can't know when to restart ?
|
|
|
|
|
Omm... no one know this... .
when a website download his document his fired "DocumentCompleted" Messege some time before his actually downloaded the hole the web page.
So see if can repharse this again.
How do I can know which is the last "|DocumentCompleted" messege or
What the nexr Messege/Event that came after "DocumentCompleted last messege ?
Thank alot.
Guy.
|
|
|
|
|
How do I listen for program events?
At the moment when listening for key presses, it only works on user controls that have the keypress event set up.
How can I get the program to listen to the keypress event that occus in all of a single forms child controls.
E.g. so if the form has 5 different user controls, is there a way to set up the even in the form so that if the key is pressed while any of the child controls have focus, the event in the main form is still called?
- Munty
|
|
|
|
|
Assign all of the child controls keypress events to the forms keypress event handler. Note that this would not actually raise the forms event. If you needed that you may be able to call the forms keypress event (using the RaiseEvent statement) from the event handlers of each of the controls.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
The problem with that, is that the KeyPress events don't seem to work on the User controls that edit their Graphics. (Button Click events do, but I need keypress events.)
That's why I was hoping there's some way of making shortcut keys from the parent form.
- Munty
|
|
|
|