|
I have a viewer of word in my application and I want to manage it`s Print event.
it means I want, when user presses Print Button in my application toolbarit happens the same occur that we press "Ctrl+P" in Microsoft Word
What should I do for this
Thanks in advance
Hello Friends
|
|
|
|
|
|
How to print content of RichTextBox
Hello Friends
|
|
|
|
|
Suprisingly, a Google search for print richtextbox c#[^] brings up a plethora of results.
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)
|
|
|
|
|
HI,
I have a little application that downloads Adam Carolla podcasts. Right now, it does not contain threading. I have read a lot of articles and get the concept, but I am drawing a blank when it comes to actually implementing it in my application.
If anyone could take the time to add threading to this app, I would greatly appreciate it. If you're a fan of the Ace Man, feel free to use this. I am really hoping to understand this via my real life example so I may truly grasp the concept enough to be able to do this myself on other apps.
I only want to download two MP3s at a time. This is .Net 1.1 code.
Regards,
Mark
the code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
using Pantheon.Software.Networking;
namespace FetchAceMan
{
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnFetchAceMan;
private System.Windows.Forms.ListBox listContents;
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.Label lblProgress;
private System.Windows.Forms.Label lblActivityLog;
private System.Windows.Forms.Label lblURLList;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
#endregion
#region Handler for the "Get the URLs" button
private void btnFetchAceMan_Click(object sender, System.EventArgs e)
{
GetTheURLs();
GetTheMP3s();
}
#endregion
private void GetTheURLs()
{
string strAceManRSS = "http://www.971freefm.com/pages/podcast/43.rss";
XmlDocument doc = new XmlDocument();
doc.Load(strAceManRSS);
XPathNavigator nav = doc.CreateNavigator();
XPathExpression expr;
expr = nav.Compile("/rss/channel/item/link");
XPathNodeIterator iterator = nav.Select(expr);
listContents.Items.Clear();
try
{
while (iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
listContents.Items.Add(nav2.Value.Trim());
}
}
catch(Exception ex)
{
textBox6.Text += ex.Message + System.Environment.NewLine;
textBox6.Focus();
textBox6.Select(textBox6.TextLength, 0);
textBox6.ScrollToCaret();
}
finally
{
listContents.Refresh();
}
}
private void GetTheMP3s()
{
this.textBox6.Clear();
try
{
string targetDir = @"c:\AdamCarollaShow";
if (!Directory.Exists(targetDir))
{
DirectoryInfo di = Directory.CreateDirectory(targetDir);
}
}
catch (Exception ex)
{
textBox6.Text += ex.Message + System.Environment.NewLine;
textBox6.Focus();
textBox6.Select(textBox6.TextLength, 0);
textBox6.ScrollToCaret();
}
finally {}
FileStream fs = new FileStream(@"C:\Program Files\McMorrine\Get the AceMan\LastDownload.txt", FileMode.OpenOrCreate);
StreamReader r = new StreamReader(fs, Encoding.UTF8);
int lastFile = int.Parse(r.ReadLine());
r.Close();
fs.Close();
int numItems = listContents.Items.Count;
int theItem = numItems - 1;
while (theItem >= 0)
{
DoDownload(listContents.Items[theItem].ToString(), lastFile);
theItem --;
}
textBox6.Text += "****" + System.Environment.NewLine +
"All of the files have been downloaded." + System.Environment.NewLine +
"They can be found in the C:\\AdamCarollaShow directory" + System.Environment.NewLine;
textBox6.Focus();
textBox6.Select(textBox6.TextLength, 0);
textBox6.ScrollToCaret();
}
#region DoDownload file downloading routine
private void DoDownload(string theItem, int lastFile)
{
try
{
FileDownloader downloader = new FileDownloader();
downloader.DownloadCompleted += new FileDownloadCompletedEventHandler(downloader_DownloadCompleted);
downloader.DownloadProgressChanged += new FileDownloadProgressChangedEventHandler(downloader_DownloadProgressChanged);
downloader.DownloadStatusChanged += new FileDownloadStatusChangedEventHandler(downloader_DownloadStatusChanged);
String strFile = theItem;
int intFileExt = strFile.IndexOf(".mp3");
int intFileNameStart = strFile.LastIndexOf("/");
int fileNameForDownload = int.Parse(strFile.Substring(intFileNameStart +1, intFileExt - (intFileNameStart + 1)));
string strFileName = strFile.Substring(intFileNameStart +1);
this.textBox6.Text += "Filename to download: " + strFileName + System.Environment.NewLine;
textBox6.Focus();
textBox6.Select(textBox6.TextLength, 0);
textBox6.ScrollToCaret();
if (fileNameForDownload > lastFile)
{
this.textBox6.Text += "Download the file " + strFileName + "." + System.Environment.NewLine;
textBox6.Focus();
textBox6.Select(textBox6.TextLength, 0);
textBox6.ScrollToCaret();
FileStream fs = new FileStream(@"C:\Program Files\McMorrine\Get the AceMan\LastDownload.txt", FileMode.Create);
StreamWriter w = new StreamWriter(fs, Encoding.UTF8);
w.Write(fileNameForDownload.ToString());
w.Flush();
w.Close();
downloader.Download(new Uri(theItem), @"C:\AdamCarollaShow");
}
else
{
this.textBox6.Text += "Already have " + strFileName + ", skip the download." + System.Environment.NewLine;
textBox6.Focus();
textBox6.Select(textBox6.TextLength, 0);
textBox6.ScrollToCaret();
return;
}
}
catch(Exception ex)
{
textBox6.Text += ex.Message + System.Environment.NewLine;
textBox6.Focus();
textBox6.Select(textBox6.TextLength, 0);
textBox6.ScrollToCaret();
}
}
#endregion
#region downloader_DownloadCompleted
private void downloader_DownloadCompleted(object sender, FileDownloadCompletedEventArgs e)
{
this.progressBar1.Value = 0;
textBox6.Text += "Download complete." + System.Environment.NewLine;
textBox6.Focus();
textBox6.Select(textBox6.TextLength, 0);
textBox6.ScrollToCaret();
}
#endregion
#region downloader_DownloadStatusChanged
private void downloader_DownloadStatusChanged(object sender, FileDownloadStatusChangedEventArgs e)
{
textBox6.Text += e.Message + System.Environment.NewLine;
textBox6.Focus();
textBox6.Select(textBox6.TextLength, 0);
textBox6.ScrollToCaret();
}
#endregion
#region downloader_DownloadProgressChanged
private void downloader_DownloadProgressChanged(object sender, FileDownloadProgressChangedEventArgs e)
{
this.progressBar1.Value = e.ProgressPercentage;
}
#endregion
}
}
|
|
|
|
|
For simplicity, I'd use the background worker component. Create an instance for each download. Your DoDownload method relates to DoWork, DownloadProgressChanged to ProgressChanged and DownloadCompleted to RunWorkerCompleted. You can pass any objects around in the various EventArgs.
If you want to do it the hard way, Sacha Barber has a series of articles on here. Just type threading into the CP search bar.
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)
|
|
|
|
|
I created a class Library in C# Visual Web Developer 2008 and I am attempting to 'learn' how to use it in a web app I created, but I can't get it to work. I've searched the web for hours, but only seem to find old examples that don't look like Visual Web Developer 2008 and tell me to do things I can't find or they say to do what I 'think' I'm doing, but its not working.
Can anybody point me in the right direction as to what I'm doing wrong please?
When I created the class library I used:
namespace createDll
{
public class Class1
{
public Class1()
{
}
public long Add(long val1, long val2)
{
return val1 + val2;
}
}
}
Im creating my web app on my server using Front Page Extensions(if that matters) & I clicked Add Reference-> & selected my dll from the bin/debug folder where I made it on my computer. The reference shows up in the references folder along with the method Add(..)
In my code behind file is I included the using:
using ....<default_usings>
using createDll;
public partial class dllTest : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e)
{
long temp;
Class1 myObj = new Class1();
temp = myObj.Add(5, 7);
lblMsg.Text = temp.ToString();
}
}
It compiles fine, but gives me the error message:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'createDll' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 9: using System.Data.SqlClient;
Line 10: using System.Data;
Line 11: using createDll;
Line 12:
Line 13:
Source File: d:\hosting\xxxx\Syllabi\dllTest.aspx.cs Line: 11
As for the error message, using directive is on line 11 & I did the "Add Reference" Is there something else I need to do?
I tried removing the "using createDll" & fully qualifying (think thats what its called
createDll.Class1 myObj = new createDll.Class1();
exc..
But then that just gives a different error:
Compiler Error Message: CS0246: The type or namespace name 'createDll' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 23:
Line 24: long temp;
Line 25: createDll.Class1 myObj = new createDll.Class1();
Line 26: temp = myObj.Add(5, 7);
Line 27: lblMsg.Text = temp.ToString();
Source File: d:\hosting\xxxx\Syllabi\dllTest.aspx.cs Line: 25
I'm sure I'm just missing something simple, but I just can't find the answer. Can anyone point me in the right direction please?
|
|
|
|
|
hi
Let me try to Help, because i once Referenced some DLLs to the Web Project. You Obviously have to Create two Projects , One that has your Class and will be Compiled into a DLL and your Web where you will be referencing it. So if yoou created this with VS.NET there is no problem.
Go to your referencing Project and Click on Add Reference and Click in the Project Tab and Choose the Project that Creates that DLL or your can Browse to it , after that in your Application you will access it like this
int num1 = Convert.ToInt32(txtnum1.Text);
int num2 = Convert.ToInt32(txtnum2.Text);
int Results;
createDll.Class1 myobj= new createDll.Class1();
Results = myobj.Add(num1,num2);
Be carefull when using Datatypes , use long when its really needed.
Hope this Helpes
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Does anyone know of a control in which I can check a word programmically to see whether it exists in a dictionary?
something like: boolean = spellcheck(word); where boolean is a true false result if the word exists.
It would be nice to have interop with MS Word dictionaries, but everything I have found is built straight into a textbox gui. I also need it to work with english and german words.
Thanks
|
|
|
|
|
I would like to be able to connect to and read/modify a local database file from the coding side of c#. I am using Visual C# 2008 Express Edition but don't want to use the 'Data Sources' wizard, but rather the 'SqlConnection' Coding commands.
I am using Microsoft SQL server 3.5 Database files.
Thanks in advance.
|
|
|
|
|
you should use Data class of framework.
Using data;
SqlConnection dataConn = new SqlConnection();,
dataConn.ConnectionString = "Integrated Security = True; Initial Catalog =dbName; Data Source=localhost;"
dataconn.open();
after this time u ll have a data conn what db you wrote there. Then time you should search what you wanna want.
thanks for everything i have...
|
|
|
|
|
Sorry, I have tried to connect using this method, the file is called Register.sdf and is in the same directory as the project content. This code fails to load the database effectively.
This is the code I am trying to use (The 'Global' Class is a static class containing the RegDB Variable)
private bool loadDatabase() {
Global.RegDB = new SqlConnection();
Global.RegDB.ConnectionString = "Integrated Security = True; Initial Catalog =dbName; Data Source=localhost;";
try {
Global.RegDB.Open();
return true;
}
catch {
return false;
}
}
|
|
|
|
|
TALHAKOSEN wrote:
did you take an error like below
TITLE: Connect to Server
------------------------------
Cannot connect to C:\DEV\SyncServices\learning\ConsoleSync1\ConsoleSync1\bin\Debug\awclientdb.sdf.
------------------------------
ADDITIONAL INFORMATION:
You are trying to access an older version of a SQL Server Compact Edition database. If this is a SQL Server CE 1.0 or 2.0 database, run upgrade.exe. If this is a SQL Server Compact Edition 3.0 or later database, run Compact / Repair. [ Db version = 3505053,Requested version = 3004180,File name = C:\DEV\SyncServices\learning\ConsoleSync1\ConsoleSync1\bin\Debug\awclientdb.sdf ] (SQL Server Compact Edition ADO.NET Data Provider)
------------------------------
BUTTONS:
OK
No, the function just failed in the try block and then returned false in the catch block
|
|
|
|
|
|
No, I don't think that I have explained myself correctly. I want to be able to access the database file as if it were a database, but without running SQL server. I plan to move the program to another machine that is not running SQL server.
|
|
|
|
|
You can't use a SQL Server database without SQL Server AFAIK.
SQL Server doesn't come built-in to the .NET framework.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Isn't that like trying to open an MS Excel document without Microsoft Excel? I imagine, if you want, you could open the SDF as a text file and have a look inside, but it won't act as a database without a database server. The clue is in the name - server. It 'serves' the data. The fact that the underlying datastore is a file is irrelevant.
Knowledge is hereditary, it will find its way up or down.
Luc Pattyn
and since what every time when i want to add button to this control one add two times
posted in C# forum
|
|
|
|
|
Ok, Thanks. I will investigate using SQLite as I have haerd that that can be used without a server (I.E Integrated)
Thanks anyway.
|
|
|
|
|
My Paranoid Hubby wrote: anyone else getting sick of this basic question?
Yes, which is why I generally ignore them.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Right Click your project in Solution Explorer,
Add / Component / SQL Database
You can then use the database as a file in your project.
Kind Regards.
|
|
|
|
|
Well, it sounds like you are using SQL Server Compact Edition 3.5, which means SqlConnection is not what you want. You need to use the System.Data.SqlServerCe[^] namespace. There are a lot of samples out there just for that, like this one[^].
|
|
|
|
|
Hi to all,
I am doing DirectShow Programming in VC++ & C#.Net.
I am using "MPEG-2 Multicast Receiver" filter & using IMulticastConfig interface on it.
In VC++, when I use SetMulticastGroup(ip, port) of IMulticastConfig it sets port properly to the filter.
But when same thing I do in C#.Net (same code of VC++), it fails to sets different port to that filter. (every-time sets a new port. No compilation or run-time error).
For C#.net, IMulticastConfig is written using IMulticastConfig of DirectX 9.0 of VC++.
Following is my interface,
<br />
using System.Runtime.InteropServices;<br />
<br />
[ComImport, System.Security.SuppressUnmanagedCodeSecurity,<br />
Guid("1CB42CC8-D32C-4f73-9267-C114DA470378"),<br />
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]<br />
public interface IMulticastConfig<br />
{<br />
[PreserveSig]<br />
int SetNetworkInterface([In] ulong ulNIC);<br />
<br />
[PreserveSig]<br />
int GetNetworkInterface([Out] ulong pNIC);<br />
<br />
[PreserveSig]<br />
int SetMulticastGroup([In] ulong ulIP, [In] ushort usPort);<br />
<br />
[PreserveSig]<br />
int GetMulticastGroup([Out] ulong pIP, [Out] ushort pPort);<br />
}<br />
My code is,
<br />
m_MulticastRcv] = Func.AddFilterByName(this.m_GraphBuilder, FilterCategory.LegacyAmFilterCategory, cNetworkInputFilterName);<br />
if (m_MulticastRcv == null) throw new Exception();<br />
IMulticastConfig Inetwork = (IMulticastConfig)m_MulticastRcv;<br />
<br />
m_hResult = Inetwork.SetMulticastGroup(InetAddress("234.1.1.1"), (ushort)System.Net.IPAddress.HostToNetworkOrder((ushort)1234));<br />
DsError.ThrowExceptionForHR(m_hResult);<br />
<br />
m_hResult = Inetwork.SetNetworkInterface(InetAddress("192.168.2.112"));<br />
DsError.ThrowExceptionForHR(m_hResult);<br />
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
Hey! Guyz i'm newbie in this developing business.
so got sum issues....
please help me to find out the solution.
I'm developing an application that is Counting PagesIndexed, BackLinks and PageRank from various SearchEngines.
My Application is windows based and i'm able to fetch data from search engine. Now! I've to create a<b> Pause Button</b> that is also working as <b>Continue Button</b> and a <b>Stop button </b>to end the process of counting the PagesIndexed,PagesRank, and BackLinks..
Please! Help.......
|
|
|
|
|
if you put your main processing into a separated thread. it will be easier to pause/resume the thread.
Best regards,
Jaime.
|
|
|
|
|
There are 5 functions are getting called for different purposes for a same argument.
when Pause button is clicked, how is it possible to know which function is executed or which one is being executed currently or which one will be executing next. And then pauses the execution till the time it is resumed by again clicking the PAUSE button....
|
|
|
|