|
Unlike Graphics.DrawLines, there is no equivilent DrawEllipses. You have no choice but to loop through each ellipse you want to draw.
|
|
|
|
|
I'm working on windows application.I need to find out the number of bold letters available in the Word document.
I have used name space Microsoft.Office.Interop.Word to read the word document and also tried with some of the properties like Selection,Range to find whether the character is in bold or not but no result.
I have read each character by reading the content of document and checking its format but here while reading the text the character is missing its Format.
I have also tried by converting it into html format and tried by using HTML Element Collection but it is unable to read/recognize the bold tag.
Please give the solution to count the bold letters of word document.
Thanks
|
|
|
|
|
This[^] wasn't good enough?
|
|
|
|
|
My application has a WebBrowser object
Inside a WebBrowser object i navigate to google site and from there a want to type something in the textbox and then press search button
how can i achieve that? can anyone check this code?
WebBrowser_Main.Navigate("http://www.google.com/");
while (WebBrowser_Main.IsBusy == true)
{
Application.DoEvents();
}
HTMLDocument myDoc = new HTMLDocumentClass();
myDoc = (HTMLDocument)WebBrowser_Main.Document;
HTMLInputElement otxtSearchBox = (HTMLInputElement)myDoc.all.item("q", 0);
otxtSearchBox.value = "code project";
HTMLInputElement btnSearch = (HTMLInputElement)myDoc.all.item("btnI", 0);
btnSearch.click();
thanks
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
You're going about it all wrong. If you want to add search capabilities to your own site or app, use the search API Google provides, here[^].
|
|
|
|
|
i understand what you said, but i don´t want to do that
google is a exemple, i what to login to one site using that type of code
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I don't do screen scraping of web pages - it's just too inefficient for me...
So what's not going right with the code you posted??
|
|
|
|
|
" Cannot convert type 'System.Windows.Forms.HtmlDocument' to 'mshtml.HTMLDocument' "
it for a browsergame bots, i need to see the bot work
i got the code from a project here but it uses a AxSHDocVw.AxWebBrowser and assemblers shdocvw and axshdocvw, i think is from old version
for course if a change the project code it works
i want do changes in code in order it to work in webbrowser object (not in AxSHDocVw.AxWebBrowser)
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
|
solved
i will use that axbrowser intead, i add to tools
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hello guys!
I'm writing my first network based application in order to learn yet a little more about the C# programming language. And I've been up for hours now working on this program that works, to about 99%. But I want this extra feature that helps me when beta testing it. It's a server / client application that simply connects using sockets and IP addresses. I found it to be the best starting point since it's really basic.
So, the problem I have is that I made a "preloader" for my program, when the server starts it directly tries to establish a connection to my IP in order to send the servers IP address to me. If I got my client up and running and I've choosen to scan for new connections then it works as intended. However, I only get 1 IP adress, the first line sent to me. I know why, I just dont know the best solution to get multiple lines recieved.
Posting a small example so that you guys might be able to help me out on this one.
private void b3_Click(object sender, EventArgs e)
{
try
{
string serverIP = "";
TcpListener tcpListener2 = new TcpListener(1235);
tcpListener2.Start();
Socket socketfromServer = tcpListener2.AcceptSocket();
networkStream2 = new NetworkStream(socketfromServer);
streamReader2 = new StreamReader(networkStream2);
streamWriter2 = new StreamWriter(networkStream2);
serverIP = streamReader2.ReadLine();
t3.Text = serverIP;
}
catch (Exception xx)
{
MessageBox.Show(xx.ToString());
}
}
The server uses a For loop and if more IP addresses then one are found, then it will use WriteLine to post them one after another until they are all sent. With this usage, I got 1x ReadLine(), and thus I only get the first line sent from the server. So, how do I get multiple lines in a smart way? ^^
|
|
|
|
|
noiser wrote: serverIP = streamReader2.ReadLine();
Will only ever read one line ya know!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Yes, I know. That's why I'm wondering what other function to use or how use the readline to get multiple lines of data.
|
|
|
|
|
how about:
string line;
while((line = streamRead.ReadLine()) != null)
{
// do something
}
or
string text = streamReader.ReadToEnd()
However all those method have problem when reading from a socket where the flow of data is potentially unpredictable (although, I believe, a TCP packet is at least 255 user bytes long and guaranteed to arrive in one burst)
So it's why over the wire communication protocol makes heavy use of header fields!
I would be you, the simplest thing I would do is
// server
var br = new BinaryWriter(outsream);
br.Write(numString);
for(int i=0; i<numstring; i++)="" br.write(strings[i]);
on="" the="" server="" side
var="" br="new" binaryreader(instream);
int="" n="br.ReadInt32();
for(int" i="0;" i<n;="" list.add(br.readstring());
and="" that's="" simplest="" one!
i="" might="" do="" some="" more="" sophisticated="" header...
and="" better="" exception="" handing="" of="" course!="" =""
<div="" class="ForumSig">A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Ey thanks man! This is a much better answear then the first one.
I'll be trying these methods out.
|
|
|
|
|
Cool!
Good luck with that!
Yeah, sometimes I feel cheeky with questions and answers...
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
I fixed the problem. ^^
Using this code block dosn't work. Apparently it gets stuck on reading the last line even though it should be empty.
string line;
while((line = streamRead.ReadLine()) != null)
{
}
So what I did was this:
while ((serverIP = streamReader.ReadLine()) != "EOF")
{
ipBuffer += serverIP + "\n";
serverIP = "";
}
On my server application whenever I am done sending data I send a line with the text "EOF" and thus I can break the infinite loop. :P
|
|
|
|
|
Hello,
VS 2008 SP1
I am using the web client to download a file. Which works ok.
However, now I have to download many, and the number of files to download will change everyday. And will not know the name of the files.
I am not sure how I can get the web client to know which files have been downloaded or not? I was thinking of using a for loop to download each file. But I will never know how many there are to download?
The web client could download the same file twice?
Many thanks for any suggestions,
private void btnStartDownload_Click(object sender, EventArgs e)
{
WebClient client = new WebClient();
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
client.DownloadFileAsync(new Uri("SomeURLToFile"), "SomePlaceOnLocalHardDrive");
btnStartDownload.Text = "Download In Process";
btnStartDownload.Enabled = false;
}
|
|
|
|
|
Why would it download the same file twice ? Why would it miss a file ? Where does the list come from ? How do you hope to work out what you want ?
You can work out what's been downloaded by checking if a file exists. That won't help you if the file needs to be downloaded again. You could keep a list in memory of files downloaded today and compare to your download list
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Trying to Fill
List string Items = new List string();
with textBox1.Text.
Anyone help me out on how to do this, or point me to where I can Learn how?
I want the code to read textBox1.Text until endofline add word to List then go to the next until the end.
|
|
|
|
|
You can use the split method on the string class to break the text in the textbox into lines, then you will have a string array to work with.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I am using a data grid view which loads data from the database and displays. Moreover, on my form are the buttons as INSERT(i.e for inserting records in database and grid), DELETE_SELECTED_ROWS(i.e for deleting records from database and grid). Now as you know that grids are editable so if any changes are made inside the grid then how to update.
Talking all in all I need to know how to update a dataset/datatable
<pre>
<code>
private void ManageCustomer_Load(object sender, EventArgs e)
{
LoadCustomers();
}
private void btnInsertInDataBase_Click(object sender, EventArgs e)
{
// Insert Customer In Database
DALHelper helper = new DALHelper();
helper.InsertCustomer(textBox1.Text);
LoadCustomers();
}
private void LoadCustomers()
{
// Load Cashiers from Database
DALHelper dal = new DALHelper();
dataGridView1.DataSource = dal.GetCustomers();
dataGridView1.Refresh();
}
List<int>customerIDsToDelete = new List<int>();
private void btnDELETE_Click(object sender, EventArgs e)
{
// Iterate all the Rows in DataGridView Rows Collection
foreach (DataGridViewRow row in dataGridView1.Rows)
{
// Get the status of CheckBox in the current Row
bool deleteStatus = Convert.ToBoolean(row.Cells[0].Value);
// Get the CashierID of the Cashier in the current row
int customerID = Convert.ToInt32(row.Cells[1].Value);
if (deleteStatus)
{
row.Selected = true;
customerIDsToDelete.Add(customerID);
}
}
// Remove From DataGridView
foreach (DataGridViewRow selectedRow in dataGridView1.SelectedRows)
{
dataGridView1.Rows.Remove(selectedRow);
}
// Remove From Database
DALHelper dal = new DALHelper();
dal.DeleteCustomers(customerIDsToDelete);
customerIDsToDelete.Clear();
// Load Cashiers from Database
LoadCustomers();
}
}
}
// THE FOLLOWING IS THE CODE I AM USING IN MY DAL(Data Access Layer) CLASS
public DataTable GetCustomers()
{
string query = "SELECT * FROM Customer_2";
SqlDataAdapter da = new SqlDataAdapter(query, constr);
DataTable table = new DataTable();
da.Fill(table);
return table;
}
// For Inserting Customers
public void InsertCustomer(string customerName)
{
string query = "INSERT INTO Customer_2 (CustomerName) VALUES (@CustomerName)";
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand(query, con);
com.Parameters.Add("@CustomerName", SqlDbType.NVarChar).Value = customerName;
con.Open();
com.ExecuteNonQuery();
con.Close();
}
// For Deleting Customers
public void DeleteCustomers(List<int> customerIDsToDelete)
{
string query = "DELETE FROM Customer_2 WHERE CustomerID = @CustomerID";
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand(query, con);
SqlTransaction tr = null;
try
{
con.Open();
tr = con.BeginTransaction();
com.Transaction = tr;
com.Parameters.Add("@CustomerID", SqlDbType.Int);
foreach (int item in customerIDsToDelete)
{
com.Parameters["@CustomerID"].Value = item;
com.ExecuteNonQuery();
}
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
throw ex;
}
finally
{
con.Close();
}
}
</code><code></code><code></code></pre>
|
|
|
|
|
"...Now as you know that grids are editable so if any changes are made inside the grid then how to update..."
sorry i didn´t check your code because of this sentence
you don´t edit that DataGridView, you edit the database
in sql database, you create Store Procedures that you trigger in an c# event like button click
the SP you create are: insert row, update row, delete row etc etc etc
so, to make changes in the DB you have to trigger the procedure you want, after, show it in the DGV
(later, don´t forget to use crystal report to display and print data)
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I have a web service (Called ABWebService) that I have created that contacts someone else's webservice (ZWebService). My main project has a reference to ABWebService and also has a reference to ZWebService, which it needs to contact directly. The problem I have is if I create a WebMethod in ABWebService that gets passed an object from ZWebService in the web method it is expecting and object of type ZWebService. But in the Main Project if I call the web method in ABWebService the object type for what I am passing is ABWebService.object, even though the type of object I want to pass to it is ZWebService.object.
It then says I can't do this because they are different types.
Any suggestions?
|
|
|
|
|
Your issue is not coming out very clear.
|
|
|
|