|
Hi,
I've creared a form with tabcontrol,
in one tab i put a richtextbox.
how can i access the richtextbox and edit a text in it?
Thanks
|
|
|
|
|
richTextBox1.Text="I got you";
you can access any control in form or any container control(if subcontrol is added by current form) by using its Name property. If Name is "richTextBox1" then just write
richTextBox1 and rest depends on you...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen W.K. wrote: you can access any control in form or any container control(if subcontrol is added by current form) by using its Name property. If Name is "richTextBox1" then just write
richTextBox1 and rest depends on you...
WOW thanks,
i thougth i need to access tought the tab.
|
|
|
|
|
Hi,
If the Rich Text Box is the first control inside the tabpage, then there are two ways you can acheive this:
Directly access the RTB:
tabControl1.SelectedTab.Controls[0].Text = "I have just accessed my Rich Text Box and put text in it";
OR:
RichTextBox rtb = tabControl1.SelectedTab.Controls[0] as RichTextBox;
rtb.Text = "I have just accessed my Rich Text Box and put text in it";
I'll explain the above code a little:
First, we access the tabControl, and say, "we need to look inside the Selected Tab", then we say goto Control[0] (0 being the very first control inside the selected tabpage). Then we use .Text to access the Text property of the RichTextBox control and write something in it.
Note: If the RichTextBox control is NOT the first control inside your TabPage, then you will need to replace the number [0] with the appropriate number. I.e. If the RTB is the second control in your tabpage then replace [0] with [1].
I hope this has helped.
Regards,
Jason Pezzimenti.
If you liked the answer that I have provided, then please click the 'Good Answer' link on the bottom-right of this post. Thank you.
|
|
|
|
|
Why on earth would one use an array index to refer to a Control of which one has a perfectly good reference variable anyway?
This is a terrible suggestion, it weakens the robustness of the code as it introduces an unnecessary constant, that obfuscates the real intent and might accidentally change when the app gets modified and controls get added or removed.
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.
|
|
|
|
|
Hey there
I'm experiencing a little problem over here... In NotePad, when the scrollbars are visible I can use my middle mouse button to scroll horizontally or vertically, but when I create my own Text Editor in C#, this does not work. I can see for a split second the circular scroller thing appear but then it dissappears right away. Does anybody know a way to fix this?
|
|
|
|
|
make sure textbox has focus as well as middle mouse is not pressed
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thank you for your reply. I think I understand what you meant. I just went and made a change. I added textBox1.Focus(); to the code when I create the TextBox. but it still doesn't work. Do you know what causes this problem?
Regards,
Jason Pezzimenti.
If you liked the answer that I have provided, then please click the 'Good Answer' link on the bottom-right of this post. Thank you.
|
|
|
|
|
use RichTextBox instead
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Ah, the good ol' RTB... My Arch Nemesis. The thing that would never save as PlainText. lol Thanks
Regards,
Jason Pezzimenti.
If you liked the answer that I have provided, then please click the 'Good Answer' link on the bottom-right of this post. Thank you.
|
|
|
|
|
well, If I need to have large text with scrolling then textbox will be that the last thing I would think of.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Yeah, that's understandable. Thanks for your help Xmen W.K. I'll go and whip out my good old RTB and see what I can do
|
|
|
|
|
Hello
I have an ImageMap created using YDreams ImageMapDemo 2.0. I'm using this control for the rollover image effect with circle and polygons hotspots. My issue is I can't seem to figure out how to write the correct C# code for each hotspot. I am able to get one hotspot to have the rollover effect but not the other 4. Can someone please help me out with the code behind. I am very very new with C+. Anyone's help would be much appreciated. Been banging my head for 2 months.
Thanks in advanced
Dale
Form code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="YDreams.Web.UI.WebControls" Namespace="YDreams.Web.UI.WebControls"
TagPrefix="ydreams" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function pageLoad() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
</div>
<div>
<ydreams:ImageMap ID="ImageMap1" ImageUrl="methodology_circle_green.gif" OnClick="ImageMap1_Click" runat="server">
<ydreams:CircleHotSpot CenterX="210" CenterY="45" Description="Click to test post back..."
HotSpotMode="Navigate" Radius="41" ToolTip="Post back" Id="AssessCircle" />
<ydreams:CircleHotSpot CenterX="310" CenterY="120" Description="Click to test post back..."
HotSpotMode="Navigate" Radius="41" ToolTip="Post back" Id="AnalyzeCircle" />
<ydreams:CircleHotSpot CenterX="270" CenterY="240" Description="Click to test post back..."
HotSpotMode="Navigate" Radius="41" ToolTip="Post back" Id="ArchitectCircle" />
<ydreams:CircleHotSpot CenterX="145" CenterY="240" Description="Click to test post back..."
HotSpotMode="Navigate" Radius="41" ToolTip="Post back" Id="AssembleCircle" />
<ydreams:CircleHotSpot CenterX="103" CenterY="120" Description="Click to test post back..."
HotSpotMode="Navigate" Radius="41" ToolTip="Post back" Id="AssimilateCircle" />
</ydreams:ImageMap>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
Code Behind
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
YDreams.Web.UI.WebControls.HotSpot AssessCircle = new YDreams.Web.UI.WebControls.CircleHotSpot(210, 45, 41);
{
ImageMap1.HotSpots.Add(AssessCircle);
{
YDreams.Web.UI.WebControls.CircleHotSpot circleHotSpot = (YDreams.Web.UI.WebControls.CircleHotSpot)this.ImageMap1.HotSpots["AssessCircle"];
if (circleHotSpot != null)
{
circleHotSpot.Attributes.Add("onMouseOver", "javascript:DisplayImage(image2);");
circleHotSpot.Attributes.Add("onMouseOut", "javascript:DisplayImage(image1);");
}
string script = @"
var image1 = new Image(413, 285);
image1.src = 'methodology_circle_green.gif';
var image2 = new Image(413, 285);
image2.src = 'methodology_circle_blue_assess.gif';
function DisplayImage(image) {
var theImage = document.images['ImageMap1'];
if (!theImage) {
theImage = document.getElementById('ImageMap1');
}
theImage.src = image.src;
return true;
}
";
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "DisplayImage", script, true);
}
}
YDreams.Web.UI.WebControls.HotSpot AnalyzeCircle = new YDreams.Web.UI.WebControls.CircleHotSpot(310, 120, 41);
{
ImageMap1.HotSpots.Add(AnalyzeCircle);
{
YDreams.Web.UI.WebControls.CircleHotSpot circleHotSpot = (YDreams.Web.UI.WebControls.CircleHotSpot)this.ImageMap1.HotSpots["AnalyzeCircle"];
if (circleHotSpot != null)
{
circleHotSpot.Attributes.Add("onMouseOver", "javascript:DisplayImage(image2);");
circleHotSpot.Attributes.Add("onMouseOut", "javascript:DisplayImage(image1);");
}
string script = @"
var image1 = new Image(413, 285);
image1.src = 'methodology_circle_green.gif';
var image2 = new Image(413, 285);
image2.src = 'methodology_circle_blue_analyze.gif';
function DisplayImage(image) {
var theImage = document.images['ImageMap1'];
if (!theImage) {
theImage = document.getElementById('ImageMap1');
}
theImage.src = image.src;
return true;
}
";
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "DisplayImage", script, true);
}
}
}
protected void ImageMap1_Click(object sender, YDreams.Web.UI.WebControls.ImageMapClickEventArgs args)
{
YDreams.Web.UI.WebControls.HotSpot hotSpot = args.HotSpot;
int x = args.X;
int y = args.Y;
this.Label1.Text = string.Format("Clicked on hot spot \"{0}\" at image coordinates ({1}, {2})", hotSpot.Id, x, y);
}
protected void Button1_Click(object sender, EventArgs e)
{
this.Label1.Text = string.Empty;
}
}
|
|
|
|
|
It would seem to me that you should be asking this, or at least you stand a better chance of an answer, if you had asked it in the Web Development or ASP Forums
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
Hi All,
I've been able to change the colour of a dateTimePicker inherited field by overriding the backColor method and looking for the WM_ERASEBKGND message in wncProc.
I also want to change the font colour of the dateTimePicker. I thought I could do this by overriding the foreColor method similar to how I did for the backColor. I can't find the message/hex bumber to look for within wncProc.
Is there any such message for ForeColor? Any help/ideas on this would be great.
Thanks,
Mel
|
|
|
|
|
I've got the same problem. Does anyone knows how to change the forecolor?
|
|
|
|
|
Hi All,
I have disabled a checkbox however when it's disabled I don't want it to be grayed out I want it to have it's enabled appearance. So instead of gray I whan it to be white.
Unlike TextBoxes when I use the following code the surrounding area of the checkbox and it's text change colour instead of the inside of the checkbox:
oCheckBox.BackColor = Color.White;
Does anyone know how I would go about doing this?
Thanks,
Mel
|
|
|
|
|
I dont think its possible unless you draw your own image on it but thats not good way. However, you can make your own CB using a Button and a Label. Change button background image or color on MouseEnter, MouseLeave, MouseDown and MouseUp.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi xman
thanks for the idea. Are you suggesting that I make the button appear to look like a checkbox and go from there?
Thanks,
Mel
|
|
|
|
|
yupp, search for checkbox images or just capture 'em from screen...
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
|
Um. I just created a project and added a checkbox to the form and set Enabled to FALSE. Then I changed the Form's backcolor to white and the checkbox backcolor also changed to white? This doesn't happen on your computer? What version of Vis' Studio are you using?
Regards,
Jason Pezzimenti.
If you liked the answer that I have provided, then please click the 'Good Answer' link on the bottom-right of this post. Thank you.
|
|
|
|
|
Hi Jason,
Thanks for your reply. I'm using VS 2005. What version are you using?
When I set
oCheckBox.Enabled = false; and then
oCheckBox.BackColor = Color.White; it makes the surrounding area behind the checkbox whiteish.
|
|
|
|
|
Sorry for the late response MWRivera, I fell asleep.
I'm using VS 2008 Express Edition.
MWRivera wrote: When I set
oCheckBox.Enabled = false;
and then
oCheckBox.BackColor = Color.White;
it makes the surrounding area behind the checkbox whiteish.
...Are you saying that you have solved your problem? I'm a little confused. In your original post you stated that you want it to be white. I hope you have solved it. I do have a question though, is your checkbox ontop of another control, picturebox? Or is it just on the form background?
Regards,
Jason Pezzimenti.
|
|
|
|