|
The combobox run ToString() for each item.
If you have a class, that does not override the ToString() method, it returns the name of the class- type.
I guess you don't need to run cmb_rues.DisplayMember = ... ??
|
|
|
|
|
I understand better now
Thank you !
|
|
|
|
|
Create properties for your members and let the display member be a property. It should work.
Let me know if it doesn't.
|
|
|
|
|
|
Can anybody help me in this? thank you in advance.
|
|
|
|
|
Hi,
this is a two-step process:
1. select the text that needs special handling; you can do that interactively, or programmatically; while it already is in place, or while adding.
2. choose a new font for the selected text (RichTextBox.SelectionFont Property) and use
FontStyle.Underline for it.
For all the details, read up on the RichTextBox and Font classes.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks.
Well there's a problem. What if my selection includes multiple fonts? RichTextBox.SelectionFont Property returns null in that case. How can I underline my selection without changing the original fonts?
|
|
|
|
|
Hi,
if multiple styles are selected, the selection has to be split up into homogeneous
parts; select and underline each part in turn; then restore the original selection.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thank you.
Your suggestion worked. I splitted my multi-font-selection into several homogeneous parts, selected each part and underlined them one after another. Finally I restored the original selection.
However, as I try out the program, it flickers.
|
|
|
|
|
SeeBees wrote: it flickers
sure, all Controls basically have that problem, and the more data they hold and the more
operations you perform on them, the more it shows.
Here are some suggestions to reduce the flickering, you pick and choose:
- optimize your code; tha faster it runs the less you will notice it;
- try using SuspendLayout() and ResumeLayout(); I'm not sure how well it helps with an RTB;
- difficult: get the Rtf property, operate on it (that's string operations now, not very
elegant), and when done, store it again
- alternative: have a second RTB, not visible, copy the Rtf from the first to the second,
operate on the second RTB, then copy back the Rtf. This should work nicely.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks for all the suggestions you give!!!
|
|
|
|
|
Hi!
I guess this article[^] could help...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
This one is really helpful, thank you!
|
|
|
|
|
Im using Visual Studio 2008 language C#.
I have a form with a dataGrid populated from an SQL Stored Procedure, one of the columns on the datagrid it's ButtonColumn and exactly this Buttons HeaderText I would like to use as a parameter for another Stored Procedure.
So if the button is clicked will open a New form with a Datagrid but this time the Datagrid will be populated with a new Stored Procedure which has a parameter and for Parameter value I want to use from the 1st form the ButtonColum Header text.
Is this Possibile?
Thank you
|
|
|
|
|
Yes, this is possible, however somewhat tricky.
You have to use the CellContentClick Event on the DataGridViewButtonColumn .
|
|
|
|
|
can you a question, i am very hurry!!
I have a database, i want to get a record of table in databases and display this record on textbox and I want to next record or back record, then display this record on textbox again! can someone help me??
|
|
|
|
|
Hey,
There are several ways to do this, but the most two common ones are pretty easy actually. You can either write a method that does a new query to the database whenever you want a new record, or you can load the data in a datatable ( my personal favorite ) and iterate through each row in the datatable.
The first method is handy, if you have small amounts of data to transfer each time. You make a new connection, get your stuff, and close the connection. If the network you're on is buggy ( assuming you're not running your database locally ) there might be some lag.
That's why I always use the second method. One connection, get the data, stuff it into a datatable and then work from there, assuming it's read-only data.
Cheers,
|
|
|
|
|
Hello!!
I have managed to load an rtf file in a streamreader :
"StreamReader sr = new StreamReader("C:\\test.rtf");"
and display it in a richtextbox:
"richTextBox1.Rtf = sr.ReadLine();"
Is there any way that I could posibly "read" each ,lets say, 10 lines? I suppose I could detect where this "\par" appears in the stream but don't know how to do it...
Any suggestions??? Does the readline method have any operation for this?
Thanks!!
|
|
|
|
|
Hey,
I guess there are several ways of doing this. One way is :
TextReader tr = new StreamReader("\\test.txt");<br />
<br />
int NumberOfLines = 10;<br />
<br />
string[] ListLines = new string[NumberOfLines];<br />
<br />
for (int i = 1; i = NumberOfLines; i++)<br />
{<br />
ListLines[i] = tr.ReadLine();<br />
}<br />
<br />
Console.WriteLine(ListLines[5]);<br />
Console.WriteLine(ListLines[1]);<br />
<br />
Console.ReadLine();<br />
<br />
tr.Close();
Another way of doing it , could be :
int counter = 0;<br />
string line;<br />
<br />
System.IO.StreamReader file = <br />
new System.IO.StreamReader("c:\\test.txt");<br />
while((line = file.ReadLine()) != null && counter < 10)<br />
{<br />
Console.WriteLine (line);<br />
counter++;<br />
}<br />
<br />
file.Close();<br />
<br />
Console.ReadLine();
You will have to play with it a little bit to get it right, but is not that hard.
Hope this helps
|
|
|
|
|
Thank you Rick but I still have a problem. I tryied out the second way you suggested, and it seems like it is counting the exact lines of the text file and not where "\par" is...I hope you understand what I'm trying to say...
So I believe that I have to check where "\par" is in the stream and then increase the counter. Any suggestions??
|
|
|
|
|
No problem ..
Could you try to explain to me what "\Par" is .. is it a line break, or a text value that it is suppose to detect ?
|
|
|
|
|
Hey rick, I don't want to cause any trouble to you... Anyway, "\par" is a linebreak like " " in html. Rich Text Format uses the backslash to start it's control code instead of tags<>. So I have to detect where "\par" is in the document. I believe that this is the only way to read a formated document line by line. I hope you understand... Any ideas if it's no trouble???
Thanks!!!!
|
|
|
|
|
Hi!
There's nothing like this available out-of-the-box. StreamReader.ReadLine() reads until the next occurrance of \n, \r or \r\n, nothing to do about it.
In an RTF document, these line break characters are more or less treated as white spaces, so there's no point in trying to use ReadLine() on an RTF file.
You'd have to write your own method to read until \par , but even then the RTF data will not be well-formed (for example, some closing braces will be missing) and I cannot say what a RichTextBox does with partially invalid data...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hey, thanks for the reply! I thought that readline isn't suitable and that I have to create a method for this. But don't know how... The method should be able to read from a stream in whitch the formated text of the rtf file is loaded and detect \par. For the problems you mentioned I believe I have to live with them... Could you help me out here??
|
|
|
|
|
Dear all,
I've written a method which I call from a thread. The problem is that it opens the form in the method, as it is suppose to, but it closes the form immediately after it opened it. Any hints ?
here's the code :
void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)<br />
{<br />
Thread thread = new Thread(OpenMethod);<br />
thread.Name = "something";<br />
thread.Start();<br />
}<br />
<br />
private void OpenMethod()<br />
{<br />
if (_form == null)<br />
{<br />
_form = new NewForm();<br />
_form.Closed += new EventHandler(_form_Closed);<br />
}<br />
_form.WindowState = FormWindowState.Normal;
_form.Show();<br />
}
Kind regards,
|
|
|
|