|
Hello, Thanks again
Here's what I got, now:
private void pictureBox3_Click(object sender, EventArgs e)
{
TabPage page = new TabPage("Tab");
tabControl1.TabPages.Add(page);
WebBrowser wb = new WebBrowser();
wb.Dock = DockStyle.Fill;
wb.Name = "WebBrowser1";
page.Controls.Add(wb);
TabPage tp = tabControl1.SelectedTab;
tp.Controls["WebBrowser1"].Text = string.Format("WebBrowser1", (tabControl1.SelectedIndex + 1).ToString());
tp.Controls["wp"].Text = string.Format("wp", (tabControl1.SelectedIndex + 1).ToString());
}
...But, When I debug, and then click on pictureBox3(add tab button) it brings up a debug error: "object reference is not set to an instance of an object"... it doesnt even open a new tab any more hahaha... Any ideas?
thanks,
j.t.
|
|
|
|
|
jay_t55 wrote: tp.Controls["wp"].Text = string.Format("wp", (tabControl1.SelectedIndex + 1).ToString());
What is "wp"? Did you mean "wb"? Even with "wb" you'll get this error. wb is an object, as I told before, you have to set the object's Name property in tp.Controls, as you did in this line:
jay_t55 wrote: tp.Controls["WebBrowser1"].Text = string.Format("WebBrowser1", (tabControl1.SelectedIndex + 1).ToString());
Clear this line:
jay_t55 wrote: tp.Controls["wp"].Text = string.Format("wp", (tabControl1.SelectedIndex + 1).ToString());
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
thank you,
i have this:
TabPage page = new TabPage("Tab");
tabControl1.TabPages.Add(page);
WebBrowser wb = new WebBrowser();
wb.Dock = DockStyle.Fill;
wb.Name = "WebBrowser1";
page.Controls.Add(wb);
TabPage tp = tabControl1.SelectedTab;
tp.Controls["webBrowser1"].Text = string.Format("webBrowser1", (tabControl1.SelectedIndex + 1).ToString());
tp.Controls["webBrowser1"].Text = string.Format("webBrowser1", (tabControl1.SelectedIndex + 1).ToString());
..and it still gives the same error message ..totally weird :-p
|
|
|
|
|
C# is Case-Sensitive which means 'A' is not equal to 'a'.
You named your wb , "WebBrowser1" (look at 'W', it's Capital) and told to tp that I have a control named "webBrowser1" (did you see 'w'?) and tp tried to find that but nothing found and got this error. Do you understand?
And why did you write this line twice?
jay_t55 wrote: tp.Controls["webBrowser1"].Text = string.Format("webBrowser1", (tabControl1.SelectedIndex + 1).ToString());
tp.Controls["webBrowser1"].Text = string.Format("webBrowser1", (tabControl1.SelectedIndex + 1).ToString());
Clear one of them and change "webBrowser1" to "WebBrowser1"
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
Sorry about that muck up before.
Here is the code that I have as of your last post:
private void pictureBox3_Click(object sender, EventArgs e)
{
TabPage page = new TabPage("Tab");
tabControl1.TabPages.Add(page);
WebBrowser wb = new WebBrowser();
wb.Dock = DockStyle.Fill;
wb.Name = "WebBrowser1";
page.Controls.Add(wb);
TabPage tp = tabControl1.SelectedTab;
tp.Controls["WebBrowser1"].Text = string.Format("WebBrowser1", (tabControl1.SelectedIndex + 1).ToString());
}
Although it still tells me "object reference not set to instance of an object." and it points to the following line:
tp.Controls["WebBrowser1"].Text = string.Format("WebBrowser1", (tabControl1.SelectedIndex + 1).ToString());
Regards,
j.t.
|
|
|
|
|
Oooooooooh,
Why didn't I notice before?
A WebBrowser control does NOT support the Text property!!!!
But why did you get NullReferenceException?!!
I tried this code and did work for me well:
TabPage tp = new TabPage("Tab");
tabControl1.TabPages.Add(tp);
WebBrowser wb = new WebBrowser();
wb.Name = "WebBrowser1";
wb.Dock = DockStyle.Fill;
tp.Controls.Add(wb);
TabPage p = tabControl1.SelectedTab;
(p.Controls["WebBrowser1"] as WebBrowser).DocumentText = "Hello!";
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
You, Pedram, are a genius! Thank you so much for letting me pick at your brain! You have just solved my problem that i have had for the last 6weeks.
Regards,
j.t.
p.s.
if you would like to help me again, (just general advice), i need to create a "DocumentCompleted" event handler for the WebBrowser1 control. But I don't know how to do this programatically since there isn't one on my form design. Any advice would be much appreciated.
best regards,
jason.
|
|
|
|
|
No problem
jay_t55 wrote: (just general advice)
Search Google, MSDN and CP articles for your will, they're more helpful and faster. If you got any problem, ask it here and if anybody can help, surely will help you. Good Luck
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
I recently made a program for organizing marks and realized that it is slow and repetitive to type the same teacher's name 20 times for students in the same class.
I chose to add a little copy and paste feature when the user presses ctrl+v and the active cell becomes the contents of the clipboard.
Here is the snippet:
else if (e.Control && e.KeyCode == Keys.V)
{
if (Clipboard.ContainsText() & dataGridView1.CurrentCell.OwningColumn.Index == 4)
{
dataGridView1.CurrentCell.Value = Clipboard.GetText();
}
if (dataGridView1.CurrentCell.OwningRow.Index == nUD_counter)
{
dataGridView1.Rows.Add();
}
}
What I'm having problems with is the last part, where I add another row (Microsoft made it so it would automatically add a row if the cell is edited by the user, but not programatically. The problem is that when I add the new row, it places it above the row which I just pasted info into such that:
col1 col2
a b
<-blank line where I press ctrl+v->
It becomes
col1 col2
a b
<-blank line where I press ctrl+v->
hi
How can I fix this? Also feel free to make suggestions on my code.
Thanks in advance.
modified on Saturday, November 1, 2008 5:23 PM
|
|
|
|
|
I messed around with it a bit and ended up using SendKeys. I know this isn't the best method, but its the only one I tried so far that works.
Basically,
try
{
dataGridView1.BeginEdit(true);
String tempText = Clipboard.GetText();
tempText = tempText.Replace("{", "{{}");
tempText = tempText.Replace("}", "{}}");
tempText = tempText.Replace("{{{}}", "{{}");
tempText = tempText.Replace("(", "{(}");
tempText = tempText.Replace(")", "{)}");
tempText = tempText.Replace("+", "{+}");
tempText = tempText.Replace("^", "{^}");
tempText = tempText.Replace("%", "{%}");
tempText = tempText.Replace("~", "{~}");
SendKeys.Send(tempText);
SendKeys.Send("{DOWN}");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n\nThe previous value was restored.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
dataGridView1.CurrentCell.Value = previousValue;
}
|
|
|
|
|
Hi,
I need to generate an ordered sequence of numbers from 1 - 9. At no point is any number allowed to be used twice.
There are 81 combinations.
So it would look something like this:
123456789,
192345678,
193456782,
194567823,
195678234,...
and so on.
Thanks
|
|
|
|
|
Hi,
that has been asked and answered here[^].
And there are 9! permutations (that's 362880, not 81).
|
|
|
|
|
i have a datatable contain 3 columns(id,type,price);
and a sqldatareader have a 1 column(name);
i want to add the column(name) from sqldatareader to datatable
using datacolumn,,
please how I can do that??
thanks all
|
|
|
|
|
Hi all.
I wanna create a plugin for Internet Explorer with C# ?
How can I do it ?
Thank you
|
|
|
|
|
Hi Mohammad,
Take a look here[^]. There's the same question, hope help
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Hello.
I have a MP3 file. I wanna split it where the volume is silent.
How can I do it ?
Thanks in advance .
|
|
|
|
|
I don't know if this article[^] uses zero crossing for determining the split location - but it shold get you started.
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)
|
|
|
|
|
An mp3 file is divided into blocks, so you would only be able to split the sound stream between blocks. Also, it would be very hard to analyse the sound while it's compressed.
You have to decompress the file in order to easily analyse it and split it where you want. Then you can either save the parts as wave files or compress them into mp3 files.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks Guffa.
Do you have any references about it for further learning ?
|
|
|
|
|
www.google.com[^]
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
How i CReate Ajax Control
How This Don.
I Want On Drop Down List.
When i Select any Item Then open other Window Which inClude Detail information about That Item
How This Done . Please Reply urgent
Please Send me Code
Ishtiaque Hussain Jalbani.
Thanks in advance
|
|
|
|
|
Hello Ishtiaque,
It seems you're new in CP, am I right?
So, take a look at the first post in page 1 titled "How to get an answer to your question" by "Chris Maunder". There are several great articles here in CP also, like CodeProject Forum Guidelines[^] by Scott Dorman or Some guidelines for posting questions in the forums[^] by Pete O'Hanlon. They will help you posting your question.
For this question, you better ask it in ASP.NET forum or Php forum.
Good Luck
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Hi!
I'm working on an application which will need to insert text into a RichTextBox where the user is currently writing. But to do that I need the index of where the text marque is. Does anyone know how to insert some text into the a RichTextBox where the text marque is or how to get the index position of the text marque?
(I don't know what it's called, therefore I call it text marque. I mean the thing which is in front of the text you're writing in e.g. a RichTextBox)
/GuitarComet
|
|
|
|
|
GuitarComet wrote: how to get the index position of the text marque?
It's called the "caret". The property you're looking for is SelectionStart.
|
|
|
|
|
Hello
I want to access data from peach tree files in C# data structures.
How it is possible?
Any one do it before?
Which components/Classes are required for the compeletion of this task.
Thanks
Syed Shahid Hussain
|
|
|
|