|
Ok,i have string word = "safdsa"; string word2 = "sdfafds"; string word3 = "asdas";
richTextBox1.AppendText(word + word2 + word3);
And i want word2 to be with different font and cursor.I mean let's say that i do something else with the application and if i decide to move the cursor over the "word2" at some moment,the cursor must be changed and "word2" to be with different font/color.Just like hyperlinks in web pages.How is that achieved in other .Net applications?
|
|
|
|
|
hi ,
The only way , according to me atleast , to do that would be to get the word the mouse pointer is on , and then change the word.
1.You get the position of the mouse by handling the MouseMove and MouseDown events from the richtxtbox.
2.The Richtextbox class has a GetCharIndexFromPosition(Point) method, which takes a point. You can suppy the mouse position there
3.Once you get the char index , use the text property and loop first backward , then forward , till you get a space , that should give you the index positions for the word. If then , the word is the one you're after , select it , and set its font and color.
struct Word<br />
{<br />
public string Text;<br />
public int StartPos;<br />
public int EndPos;<br />
}<br />
Point pt;<br />
int p = richTextBox.GetCharIndexFromPosition(pt);<br />
Word GetWordFromIndex()<br />
{<br />
int i=p;<br />
while(true)<br />
{<br />
if(richtextbox.Text[i--]==' '||i==0) break;<br />
<br />
}<br />
Word wd = new Word();<br />
wd.StartPos = i<br />
i=p;<br />
while(true)<br />
{<br />
if(richtextbox.Text[i++]==' '||i==0) break;<br />
<br />
}<br />
wd.EndPos = i;<br />
wd.Text = richtextbox.Text.Substring(wd.SatartPos , (wd.EndPos-wd.StartPos));<br />
return wd;<br />
}<br />
You could then check if the Word.Text is what you we're looking for , and if it is , you can change the Font by setting the SelectedText property to the text , then changing the selectionFont and SelectionColor properties.
Hope i helped
Gideon
|
|
|
|
|
what you need to do is selecting the apt substring and change its font:
richtextbox.Select(Length);
richtextbox.selectedFont = Font.Bla bla bla
|
|
|
|
|
Hello All,
I have a desktop aaplication in C#.NET 2005 (2.0) which uses the datagridview. In that I have two hyper link column say Edit and Delete . For that I add two column of type Hyperlink.
Now I want to merge them in a single column like Action is the colmn name and Edit link and Delete Link .. Like Belove Diagram
I have this...
-----------------------
EmpCode | Edit | Delete
------------------------
1 | Edit | Delete
2 | Edit | Delete
I want this...
------------------
EmpCode | Action
-------------------
1 | Edit Delete
2 | Edit Delete
How I Can do that...?
Regards
Pankaj Joshi
|
|
|
|
|
my apologies. i didnt catch that part on a desktop application.
-- modified at 8:16 Saturday 16th June, 2007
|
|
|
|
|
Sir I allready Mention This is not an ASP.NET Project this is Desktop Application
And also I don't use Any Datasource... I Add Lines one by one Using DataReader
into the datagridview rows and cells.
Regards
Pankaj Joshi
|
|
|
|
|
You can still try his first suggestion.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hello All,
I Have combo which have it'd dropdown style = dropdownlist. i.e. no body can
enter the data in it. I add some values in it on the folrm load like ....
cmbQ.Items.Clear();
cmbQ.Items.Add("A");
cmbQ.Items.Add("B");
cmbQ.Items.Add("C");
cmbQ.SelectedIndex = 0;
that means After Form Load the displayed value in cmbQ = A. Right.
Now my Problem ...
If save the values in database using cmbQ.text that means either A,B or C it is save.
But suppose the saved value is C.
when user open form again in edit mode, I want to display the selected values in cmbQ should be C.
How I can Do that...?
Remeber I Don't use DisplayMember, ValueMember property bcoz the ABC values are hardcoded.
I just to show it.
I allready tried
SelectedText
SelectedIndex
Text
SelectedValue
But unable to get desire output...?
I also Change the dropdown style before assign the values like
cmbQ.DropDownStyle = ComboBoxStyle.Simple;
cmbQ.SelectedText = ObjDS.Tables["Version"].Rows[0]["Version"].ToString();
cmbQ.Refresh();
cmbQ.DropDownStyle = ComboBoxStyle.DropDownList;
But Unable To Get Desire Output.
Please Help
-- modified at 4:47 Saturday 16th June, 2007
Regards
Pankaj Joshi
|
|
|
|
|
try:
cmbQ.SelectedIndex=cmbQ.FindStringExact(dataFromDB);
|
|
|
|
|
Thx Luc really Greate Solution
Regards
Pankaj Joshi
|
|
|
|
|
here im getting active directory users ? i want to get that user active or inactive in that..How can we know. any property to use like,,
oSearcher.PropertiesToLoad.Add("samaccountname");
here my code, to get all users...
public Hashtable GetAllUsers(string ldapServerName)<br />
{ <br />
string _ldapServerName = ldapServerName;<br />
DirectoryEntry oRoot;<br />
oRoot = new DirectoryEntry(ldapServerName);<br />
<br />
DirectorySearcher oSearcher = new DirectorySearcher(oRoot);<br />
SearchResultCollection oResults ;<br />
Hashtable RetArray =new Hashtable();<br />
try<br />
{<br />
oSearcher.SearchScope = SearchScope.Subtree;<br />
oSearcher.Filter = "(&(objectClass=user) (objectCategory=person))";<br />
<br />
oSearcher.PropertiesToLoad.Add("name");<br />
oSearcher.PropertiesToLoad.Add("samaccountname");<br />
oSearcher.PropertiesToLoad.Add("cn"); <br />
oResults = oSearcher.FindAll();<br />
foreach (SearchResult oResult in oResults)<br />
{<br />
if (oResult.GetDirectoryEntry().Properties["samaccountname"].Value != null)<br />
{<br />
RetArray.Add(oResult.GetDirectoryEntry().Properties["samaccountname"].Value,<br />
oResult.GetDirectoryEntry().Properties["userAccountControl"].Value);<br />
}<br />
}<br />
}<br />
catch(Exception e)<br />
{<br />
MessageBox.Show("Error is " + e.Message);<br />
return RetArray;<br />
}<br />
return RetArray;<br />
}
-------------------------------------------------------------------
here get log in ,...can i use that here also???
DirectoryEntry entry = new DirectoryEntry(< LDapPath>,< username >, < pwd > );
try
{
// Bind to the native AdsObject to force authentication.
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + txtUserName.Text + ")";
search.PropertiesToLoad.Add("name");
SearchResult result = search.FindOne();
if (null == result)
{
MessageBox.Show("User doesn't Exit.");
}
else
{
// Update the new path to the user in the directory
MessageBox.Show("Loged Succesfully user " + (String)result.Properties["name"][0]);
}
}
catch (Exception ex)
{
MessageBox.Show("Error authenticating. \\n"+ex.Message);
}
Thnks in advance!!!
|
|
|
|
|
i am new to programming, so plz help me.
I had design a wordpad or notepad editor, in this a user can fix the number of character in line, like if he sets chracter to 65 then only 65 chracters will appear in that line and further character will starts from next line.
so, at end of line instead of bringing the whole word to next lines it cuts the word(means if 65 character completed it force rest letters to next line). The word got cut.
so, how to solve this problem. So that, the whole word come to next line.
Help me.
|
|
|
|
|
You can check out one version of the WordWrap and LIne Breaking algorithm here:
http://www.velocityreviews.com/forums/t20370-word-wrap-line-break-code-and-algorithm-for-c.html
|
|
|
|
|
you need to search first for the '/n' char which mean a new line. then you cut the word you need to transfer and put it in the apt place
|
|
|
|
|
Hi
I have a strange problem.In an application ,I have a login process and I'd like to show the progress of this process on a progress form using a progress bar and a label describing what is going on.Thus I put a progress form in my project and whenever this form is activated starts the login process and listens to a progress event that tells it to refresh the controls according to the progress.
There's a LoginFailedException in my app that is thrown whenever the username and/or the password is incorrect.I've handled this exception by showing a message box.Every time I debug my project using VS2003 IDE and provide some incorrect information It works fine and shows me the message box but when I exceute the exe file directly ,an unhandled exception is thrown just like there is no exception handler available.
What is wrong with my program?
please help me.
|
|
|
|
|
Hard to say, without seeing some code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Here it is :
In my login form:
<br />
private void OnOKButtonClicked()<br />
{ <br />
try<br />
{<br />
this.Cursor=Cursors.WaitCursor;<br />
progressForm.Login(this.txtUsername.Text,this.txtPassword.Text) ;<br />
this.Cursor=Cursors.Default;<br />
this.Close();<br />
}<br />
catch(LoginFailedException)<br />
{ <br />
this.Cursor=Cursors.Default;<br />
MessageBox.Show("Invalid username and/or password.");<br />
}<br />
catch(Exception exp)<br />
{<br />
new ExceptionViewForm(exp).ShowDialog();<br />
}<br />
}
In my progress from:
<br />
internal static void Login(string username,string password)<br />
{<br />
progressForm frm=new progressForm() ;<br />
frm.username=username;<br />
frm.password=password;<br />
frm.ShowDialog(); <br />
}<br />
<br />
protected override void OnActivated(EventArgs e)<br />
{<br />
if(! activated)<br />
{ <br />
LoginForm.engine=<br />
LoginProcess.Instance.Login(this.username,this.password); <br />
}<br />
} <br />
|
|
|
|
|
And what is the exception when it is run standalone? When you run it stand alone is it a debug or release build?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Hi
Exception is LoginFailedException and the stand alone program has been built using debug configuration.
|
|
|
|
|
Hi!Friends...Now Im working with datalist.In it I have added only one image button control..how come I knonw which image is clicked in a datalist..please help me firends..
Hi,Im Razana
|
|
|
|
|
winforms or ASP.NET ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi
i used a quicktime object in my project to show 3 file in .mov extention.
my form object is axQTControl1 and one btn to play movie and one btn to set nevt movie url
i set the first clip url in form.load() and play it whitout problem.
when click next clip btn and click play i get the System.AccessViolationException
"System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.AxHost.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageA(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at QuickPlayer.Program.Main() in D:\\MyDoc\\My Project\\Q\\QuickPlayer\\QuickPlayer\\Program.cs:line 24"
please help me.
|
|
|
|
|
|
Good Day Sir/Maam,
<br />
DateTime StartTime = DateTime.Now;<br />
for (int i = 0; i <= List.Length - 2; i++)<br />
{<br />
for (int j = 0; j <= List.Length - 2 - i; j++)<br />
if (List[j + 1] < List[j])<br />
Swap(ref List[j], ref List[j + 1]);<br />
}<br />
DateTime EndTime = DateTime.Now;<br />
TimeSpan Duration = EndTime - StartTime;<br />
This is a bubble sort algorithm, I want to get the total duration of the sorting in Milliseconds. But the sorting was too fast that I got a 0 MS duration.
Can I get the duration in Nanoseconds using Timespan?
|
|
|
|
|