|
I had a small application of BHO which retreives each and every element of a web page opened in IE.
I want to change the text that is visible on web page, as the changed text should be directly visible
to user instead of original text.
How can I do this in c#?If I try to change/assign the innerText of an HTMLELement in the following
ways, the original text is visible for a fraction of seconds initially, and then it is replaced by the
"New text".
1. htmlElement.innerText = htmlElement.innerText.Replace(htmlElement.innerText, "New Text");
2. htmlElement.innerText = "New Text";
If I try to set the innertext property in the following way
object obj = "New text";
htmlElement.setAttribute("innerText", obj,0);
it doesn't show any effect,
I think I was missing something. How can I do this?
|
|
|
|
|
|
adneilme wrote: I need help from you guys especially those who work as a Network Engineer. You can figure this out and write down all codes in C language.
Yay, I love doing homework that's not mine.
|
|
|
|
|
hi friends
i have a DataGridView control on a form and when i want to print it
i create one instance and then send it to one class that print it.
but when i change properties of new instance the properties of first
DataGridView automatically changed for example:
DataGridView newdtgv = dataGridView1;
newdtgv.Columns["customercode"].Visible = false;
printer.PrintPreviewDataGridView(dataGridView1);
in this code when i hide customercode Column in newdtgv this Column hide in dataGridView1 too. how i prevent this changing in dataGridView1?
|
|
|
|
|
Hi,
Member 4470166 wrote: DataGridView newdtgv = dataGridView1;
this is not a new DGV, it is a second reference to a pre-existing DGV.
you having "new" in the variable's name does not change a thing, except it confuses you.
DataGridView newdtgv = new dataGridView(); would create a new DGV, without any content though.
BTW: you normally don't need to create new data structures, tables, whatever to get something printed, since printing and painting to screen are very similar actions.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
thanks Luc Pattyn
it is true but how i create new DGV that equal to dataGridView1 and not reference to
dataGridView1 ?
|
|
|
|
|
Hi,
I'm guessing you want to print a DGV that is slightly different from the one displayed on screen, without temporarily changing the one on screen.
If so, you would need a DGV clone; if the DGV got filled from a DataSource, just create a new DGV (with the "new" keyword) and bind to the same DataSource. If not, I suggest you google for "DataGridView Clone".
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
Brothers,
I've successfully coded to load data from db (sql server) to combobox in c sharp (ex: productname); but when I add new data to db (from c sharp), I want to add an pID of productname instead of the productname to db because I have two tables in db which have relationship together (ex: pID, productname) and (ex: cID, pID, qty, price).
Lastly, I have another form to add more productname to db; so, how to refresh the combobox (as mentioned above) when this form is closed?
Thanks so much
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
Hi Chuon Visoth
A Combobox as 2 properties Display Member & Value member. Assign "productname" as your Display member & "pID" as your value member. while saving data to your table assign value member.
The "pID" & "productname" both columns should be in the query from which you assign it to commandText & then get Datatable
Ex:- combobox1.DisplayMember = "productname"
comboBox1.ValueMember = "pID"
Thanks & Regards
Satish Pai B
|
|
|
|
|
But this wouldn't refresh it, he would also have to update the DataTable that the combobox is bound to.
|
|
|
|
|
Thanks for your support.
I've found the way to load pID and productname; but my second question I've not found it yet.
How to do that? HELP ... !
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
|
Hi,
I am writing a program that needs to manipulate Animation Master's models(an 3d animation program).
Hash Inc have available an sdk for developing plug ins using C++. But they have an ActiveX that exposes all the sdk libruary, it's called WebHAMR.
I really need to do what I need to do fast, and because of this I am using C# Express 2008.
I really don't want to do it in C++
This is what I do:
I add WebHAMR as a Reference, And it works fine if I just place a WebHAMR control on a form and load a 3d model.
The problem I am having is that if I create an object using the library exposed by WebHAMR, I get the following error:
Retrieving the COM class factory for component with CLSID {2FDB515C-EA6A-4B4A-8300-A0446FEB7F78} failed due to the following error: 80040154.
I really need help, I am limited on time.
Thanks
|
|
|
|
|
I have a localized form set up with default, en-CA and fr-CA languages. I tried testing the form, for each of the languages by changing the HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value between 0409 (en-US), 1009 (en-CA) and 0C0C (fr-CA). The correct localized text is displayed everytime I test the form without debugging but not when I test using VS debugger.
Here's what I do:
1. Create a localized form with a button which closes the form.
2. Update HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value to 0C0C (was originally 0409)
3. From Visual Studio IDE window, choose "Start without Debugging"
4. Form displays with French text as expected
5. Update HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value to 1009
6. From Visual Studio IDE window, choose "Start without Debugging"
7. Form now displays with Canadian English text - again, as expected
8. Update HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value back to 0C0C
9. From Visual Studio IDE window, choose "Start Debugging"
10. Form displays with Canadian English text - expected to be French
11. Repeat step 9 above - without touching the registry value (still 0C0C)
12. Form now displays in French as expected
I noticed that if I want the form to display in the correct language, in debug mode, I need to run it twice after changing the registry value.
I test by changing HKCU\Software\Policies\Microsoft\Control Panel\Desktop\MultiUILanguageID value because I don't want to change locale in Control Panel everytime. Is this test valid? If so, does anyone know why my test results are different between "Debug" and 'non-Debug"?
Thank you.
cpl
|
|
|
|
|
Hello
I am trying to update record in a database. I can see the changes in the datagrid, but they don't get saved into the database.. The 3 textboxes show the values of the currently selected row in the datagrid. So i press the Change button to make the textboxes active, change the text and then click the Save button.
Here's how the form looks like: http://img529.imageshack.us/my.php?image=45903634.jpg
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private SqlConnection conn;
private string connStr;
SqlDataAdapter da;
DataSet ds;
bool b;
public Form1()
{
InitializeComponent();
connStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=" + Application.StartupPath + "\\dbOne.mdf" + ";Integrated Security=True;Connect Timeout=30;User Instance=True";
conn = new SqlConnection(connStr);
conn.Open();
string selectStr = "select * from people";
da = new SqlDataAdapter(selectStr, conn);
ds=new DataSet();
da.Fill(ds,"people");
da.InsertCommand = new SqlCommand("insert into people(name, age) values (@name, @age)", conn);
da.InsertCommand.Parameters.Add("@name",SqlDbType.VarChar,50,"name");
da.InsertCommand.Parameters.Add("@age",SqlDbType.Int,5,"age");
da.UpdateCommand = new SqlCommand("update people set name=@name, age=@age where id=@id",conn);
da.UpdateCommand.Parameters.Add("@name",SqlDbType.VarChar,50,"name");
da.UpdateCommand.Parameters.Add("@age",SqlDbType.Int,5,"age");
da.UpdateCommand.Parameters.Add("@id",SqlDbType.Int,5,"id");
da.DeleteCommand = new SqlCommand("delete from people where id=@id",conn);
da.DeleteCommand.Parameters.Add("@id",SqlDbType.Int,5,"id");
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.DataSource = ds.Tables["people"];
txtId.DataBindings.Add("Text",ds.Tables["people"],"id");
txtName.DataBindings.Add("Text", ds.Tables["people"], "name");
txtAge.DataBindings.Add("Text", ds.Tables["people"], "age");
txtId.Enabled = false; txtName.Enabled = false; txtAge.Enabled = false;
btnSave.Enabled = false; btnCancel.Enabled = false;
conn.Close();
}
private void btnChange_Click(object sender, EventArgs e)
{
b = false;
txtName.Enabled = true; txtAge.Enabled = true;
btnNew.Enabled = false; btnDelete.Enabled = false; btnSave.Enabled = true; btnCancel.Enabled = true;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (b)
{
DataRow newLine = ds.Tables["people"].NewRow();
newLine["name"] = txtName.Text;
newLine["age"] = txtAge.Text;
ds.Tables["people"].Rows.Add(newLine);
}
da.Update(ds,"people");
}
private void btnNew_Click(object sender, EventArgs e)
{
b = true;
int i = ds.Tables["people"].Rows.Count;
dataGridView1.Rows[i].Selected = true;
txtId.Text = ""; txtName.Text = ""; txtAge.Text = "";
txtName.Enabled = true; txtAge.Enabled = true;
btnSave.Enabled = true; btnCancel.Enabled = true;
}
private void btnDelete_Click(object sender, EventArgs e)
{
int i = int.Parse(dataGridView1.CurrentRow.Index.ToString());
ds.Tables["people"].Rows[i].Delete();
da.Update(ds,"people");
}
}
}
|
|
|
|
|
Your Code is very Ugly, you are not even trapping exceptions, and you open connections at wrong places.
This is how you update a Datagrid
[^]
Hope it Helps
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Everytime i multiselect files it creates so many tabs as files selected..but there is only text of first file in first tab..other tabs are empty...
Here i have code for opening file:
private void evtOpenFile_Click(object sender, EventArgs e)
{
openFileDialog1.Multiselect = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
foreach (String file in openFileDialog1.FileNames)
{
evtNewDocument_Click(sender, e);
RichTextBox richTextBox1 = new RichTextBox();
richTextBox1 = tabControl1.SelectedTab.Controls[0] as RichTextBox;
richTextBox1.LoadFile(openFileDialog1.FileName,RichTextBoxStreamType.PlainText);
saveFileDialog1.FileName = openFileDialog1.FileName;
FileInfo fi = new FileInfo(openFileDialog1.FileName);
string pot = fi.Name;
tabControl1.SelectedTab.Text = pot;
pot = "";
}
}
}
evtNewDocument_Click(sender, e); creates new tab in tabcontrol with selectedindex on it! Still can't figure out what is wrong... PLZ HELP!
THanks
|
|
|
|
|
Aljaz111 wrote: richTextBox1 = tabControl1.SelectedTab.Controls[0] as RichTextBox;
for each iteration of the foreach this statement acts exactly the same, AFAIK SelectedTab is not changing (unless there is something hidden inside evtNewDocument_Click that succeeds in changing the tab whilst inside the evtOpenFile_Click, so the GUI thread is busy and not acting on extra messages right now).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
TabPage newPage = new TabPage();
newPage.Text = "Nov"+tabControl1.TabPages.Count;
tabControl1.TabPages.Add(newPage);
tabControl1.SelectedIndex = i;
i++
I am changing selectedindex..Something is wrong with changing to next text file.. In all tabs richtextboxes is text from first file in multiselect..
modified on Wednesday, May 27, 2009 8:13 PM
|
|
|
|
|
Sorry, I missed that.
There is one mistake though, you foreach "file" but never use it, instead you use "openFileDialog1.FileName" all the time, which isn't right. That would make all textboxes show the same text.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
|
Aljaz111 wrote: What should i change??
the only thing that changes value for each iteration of the foreach is the "file" variable, so you should USE it where ever you need to do something to one of the many files you are handling one by one.
If the code inside the foreach block does not rely on "file" it will perform the same actions over and over again, always using the same data.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
So where to use file?...Or can i walk through files in some other way?
|
|
|
|
|
Hint: what do you think openFileDialog1.FileName is holding when multiple files are selected?
Suggestion: buy a tutorial book on C# and work your way through it, you will acquire a lot of knowledge and insight from it.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|