|
Hi VenkataRaman,
As a simple solution you can use Microsoft Web Browser control to display the file.
axWebBrowser1.Navigate(@"C:\FIGHCatalogue.pdf");
Thanks and Regards
Pani.
|
|
|
|
|
System.Diagnostics.Process.Start(string fileName); should solve your problem,
if you want to show the .pdf file in an extern Adobe Reader window.
Arne
-- modified at 6:49 Friday 27th January, 2006
|
|
|
|
|
I want to show window that it's like open.showmodelessdialog in web application. The second window always on the first window. besides, the first window can be operateed.
|
|
|
|
|
Secondwindow.AlwaysOnTop = true?
|
|
|
|
|
If I set SecondWindow.TopMost as True, then show other problem that the first window bring to back, the second window still on top.
|
|
|
|
|
You may recall I asked about binary serialization earlier. I did it but (after a suggestion from someones' reply) I wanted to try something I never tried before so I want to get my feet wet in XML. As you may recall, I have 2 classes of lists derived from collections (class ArrayList to be specific) with objects in the list (also derived from System.Object). I can serialize both of them into one file but in the file I get:
<MyArray1 count="6">
...
</MyArray1><?xml version="1.0" encoding="utf-8"?>
<MyArray2 count="2">
...
</MyArray2>
That "?xml" tag, which as I understand is the document start tag that states it's XML, what version of XML it is and what encoding it has, should only be at the top and not in the middle.
Here's the core of the XML code:
StreamWriter writer = new StreamWriter(dlg.FileName);<br />
<br />
XmlSerializer ser1 = new XmlSerializer(typeof(Array1));<br />
ser1.Serialize(writer, array1);<br />
<br />
XmlSerializer ser2 = new XmlSerializer(typeof(Array2));<br />
ser.Serialize(writer, array2);<br />
<br />
writer.Close();
I figure it's doing that because the second XML serializer figures it's the only XML serializer so it writes that document start tag which I want to get out of there. I found an overloaded constructor for the XmlSerializer which is (Type, Type[]). I figure that's what I'm looking for because the second argument takes "extra types". I tried creating a Type array with a single element (the typeof(Array2)) and the first argument keeps typeof(Array1) but in runtime, I get an exception that says "Specified cast is not valid" at Write1_Array1. Some web pages say it's because it's trying to cast my derived class as the base class and it doesn't like that but I don't know if they are having the same issue. I don't quite know how to fix this, can anyone help me?
|
|
|
|
|
|
Okay, I understand. However, could I create an instance of XmlRootAttribute, and potentially set some namespaces also instead of using a dummy class?
|
|
|
|
|
Has a Excel file like that:
Title
Field1 Field2 Filed3
1 AA 1.1
2
3a CC 3.3
4 DD 4.4
I wrote a program in order to import the excel file datas to DataGrid:
OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Test.xls; Extended Properties=Excel 8.0");<br />
connection.Open();<br />
DataTable dt = new DataTable("Orders");<br />
OleDbDataAdapter da = new OleDbDataAdapter();<br />
da.SelectCommand = command;<br />
da.Fill(dt);<br />
this.dataGridTest.DataSource = dt;
Why in the DataGrid show as:
F1 Title F2 ------> This is header
(null) Field2 Filed3
1 AA 1.1
2 (null) (null)
(null) CC 3.3 ------> Note this line column 1 is null!
4 DD 4.4
If the Excel file like this:
Title
Field1 Field2 Filed3
1 AA 1.1
2a
3a CC 3.3
4a DD 4.4
That the DataGrid turns to like this:
F1 Title F2 ------> This is header
Field1 Field2 Filed3 ------> Note the Field1 now is not null
(null) AA 1.1 ------> Note this line column 1 is null!
2a (null) (null)
3a CC 3.3
4a DD 4.4
Why? How can i prevent this result? (I had try to make the column 1 is Text format not Generic, but also yet)
=== Game is power! ===
|
|
|
|
|
Hi Libra,
Can you try something with your command object.
Insted of selecting a sheet can you try selecting a range of cells.
command.CommandText = "Select * from [Sheet1$A2:B7]";
Thanks and Regards
Pani.
|
|
|
|
|
Thx for you help.
I try as your said but it's trashy. Select of a part datas is base on the Select of whole sheet.
I wonder if the OleDb Engineer adjust the type of each excel column when transfer, so when the column looks has more numerical value that it make the numerical type, when the column looks has more string value that it make the string type.
=== Game is power! ===
|
|
|
|
|
have a TXT file that contains the word FLAT several times.
I want to read the file and replace the word FLAT by ZAG.
|
|
|
|
|
Read the file into a string , then use StringParser.replaceEvery() . See this[^] article.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
public void FileReplaceString(string path, string find, string replace, bool matchcase)
{
System.IO.TextReader r = new System.IO.StreamReader(path);
string text = r.ReadToEnd();
r.Close();
r.Dispose();
text = System.Text.RegularExpressions.Regex.Replace(text, System.Text.RegularExpressions.Regex.Escape(find), replace, (matchcase)?System.Text.RegularExpressions.RegexOptions.None:System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.IO.TextWriter w = new System.IO.StreamWriter(path);
w.Write(text);
w.Flush();
w.Close();
w.Dispose();
} To call:
<br />
FileReplaceString(@"C:\Document.txt", "FLAT", "ZAG", false);<br />
|
|
|
|
|
Has anyone used C# (or even VB.NET) to display video from an ethernet camera? I am trying to do this in the Compact Framework. Does anyone know of any examples, web sites, tools or the best classes to help with this?
Thanks!!!
|
|
|
|
|
May be this can help you... I used a library from DirectShow.Net[^].
This guy has a sample using a webcam (dxwebcam) look for that one.
daniero
|
|
|
|
|
Thanks - I'll check it out and see if it works with the Compact Framework.
|
|
|
|
|
Here's a good problem.
I'm trying to set up a system where text fields in a database define dynamically-generated controls on the form. In other words, when a user makes a selection on the form, the system will pull all the records that match that selection from a database that contains text information that defines all the controls from one table, and text information that defines each of those controls' properties from a related table.
Now, I could set up switch statements that would satisfy many of the possible permutations. But that would require hundreds of lines of code, and it wouldn't be feasible to predict all the possibilities.
My idea is to use generics (which I'm just learning about) to dynamically define the controls and their properties. In essense, I need to somehow get text from the database into the utilization of the generic.
Conceptually, something along these lines:
****
public class GenericControl<T>
{
**Code to construct the control**
}
class TestGeneric
{
private void BuildControl()
{
//In reality, this string would be retrieved from the database.
string controltype = "System.Web.UI.WebControls.TextBox";
//Then the part that won't work:
GenericControl<controltype> MyControl = new GenericControl<controltype>();
}
}
****
Now, if I understand correctly, generic utilization requires that you use a defined object where I have "controltype" - which is why the above example won't work. Is there any way to take the string "System.Web.UI.WebControls.TextBox" and use it to get a TextBox object type (or the appropriate object type) - without using a switch statement?
|
|
|
|
|
I think that you will have much better luck using reflection instead.
Use the GetConstructors method of the Type class to get an array of ConstructorInfo objects. Use the Invoke method to create the object.
---
b { font-weight: normal; }
|
|
|
|
|
In Generics, types must be known compile-time, not run-time, and do not instance parameters (controltype is an instance of the System.String class). The suggestion from Guffa is very good, but you could still avoid having tons of switches in your code.
Start from the fact that all your controls inherit from the System.Windows.Forms.Control class, which, I would say, contains about 95% of the properties of the built-in controls (Size, Font, Text, Position, Name, Visible, etc.).
So, using reflection, you could, as suggested by Guffa, instanciate your controls in a way similar to the one below:
List<Control> controls = new List<Control>();
foreach (....)
{
Type myControlType = Type.ReflectionOnlyGetType(controltype, true, false);
ConstructorInfo myControlContructor = myControlType.GetConstructor(Type.EmtpyTypes);
Control myControl = myControlContructor.Invoke(null);
controls.Add(myControl);
}
Then, set all the properties common to all controls, I think this would cover much of your cases.
You will need some mechanism (maybe a flag from your database) to indicate properties that are not defined in the System.Windows.Forms.Control class.
Hope this helps,
Michel
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
-- modified at 7:39 Friday 27th January, 2006
|
|
|
|
|
I have a program that uses a custom combobox I wrote. On SOME versions of Windows 2K, when the combobox dropdown closes, the area underneath the dropdown is not redrawn/refreshed. If I add a "Refresh()" call to the code to refresh the display when it closes, nothing happens.
I also notice that, on the same display, if I run a program that has a crystal reports control, when the report is finished, the report is drawn offset to the right (on other displays, it is scaled to fit within the window and centered). If you scroll all the way to the right of the report, then back to the left edge, what went under the left edge of the control display is not redrawn (it is missing), even after forcing a refresh. The only way to get it to redraw is to change the scale/size of the displayed report.
So far, I have only seen this happen on SOME versions of Windows 2K. I have not seen it happen on all Win 2K or even Win XP systems. If I do a windows update on the effected systems, it does not fix the problem.
Is there a corrective action, either in Windows settings or programatically?
-- modified at 15:45 Thursday 26th January, 2006
|
|
|
|
|
Try attatching Invalidate() to the drop down / changing events of the listbox, or on the Form.Enter event
|
|
|
|
|
Since I am calling the parent window's "Refresh()" method, shouldn't that cause it to completely redraw, regardless of whether any part if it is invalidated or not. I know that calling the "Update()" method should only cause a redraw of those parts of the interface that are invalidated, but I thought "Refresh()" said redraw entire... no matter what.
|
|
|
|
|
I think refresh() changes the date, all painting should be in paint / invalidate()
Invalidate() is what tells the system to re-draw the client area - call that whenever focus enters the form or leaves the combobox
|
|
|
|
|
Hi.
How can send my programm to system tray.
I write a clock alarm program and want when running go to system tray.
Best wishes
|
|
|
|