|
if you want to send to your own phone, create a solid connection maybe it can do, but i dont want to recieve your files without my "YES".
|
|
|
|
|
i would like to write control like IE-8 address bar - with the option of auto-complete text and with the option of the delete (like the X that appear on the right of each option when doing hover)
how can i add the delete option?
any idea?
Thanks
|
|
|
|
|
You'll need to subclass a ComboBox, set the autocomplete stuff and set the DrawMode to one of the OwnerDraw ones so you can draw the image and override OnDrawItem .
|
|
|
|
|
the droped-down part is more like a listview than an item of combobox, so i think you can try to implement it by a listview, refer to source code of "ObjectListView2008"(google and download it).
|
|
|
|
|
If you're using WPF you can add one of the panels as an item. That panel can contain a textbox and an icon.
Still not easy as there will be some squirks, but it's an idea.
V.
|
|
|
|
|
Hi
How can I draw Line in background of richtextbox ?(something like handwriting notebooks) even in with spaces also.
somthing like this :
1.this is my book ___________________________________________________
2.My Name : _________________________________________________________
3.My Address : ______________________________________________________
|
|
|
|
|
The easiest way probably is by using the underline font style while adding text and/or spaces.
|
|
|
|
|
Yeuch! I hate it when you have to do that, when you change the font size or text all the alignment goes out unless you use a non-proportional font. Which looks tatty. I don't have a better solution (other than "don't do it") but it is still a nasty solution.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I almost never use underline style, and I would expect it not to mess up horizontal alignment (if any) as there is no reason I can think of it would change character widths.
I agree it isn't a really elegant solution, however drawing real lines and get them align somehow with text probably is quite a task.
BTW: I hate forms with full lines where I'm supposed to write, a subtle gray dotted line is much better. I think I left that as homework.
|
|
|
|
|
Please help and give me sample
I need it very much
Thanks\
|
|
|
|
|
I'm not going to provide any code, it is elementary. You can apply underline style in the same way you would apply bold or italics.
I suggest you first experiment inside WordPad to see if what you can obtain is acceptable; then read up on RichTextBox class.
|
|
|
|
|
It will only change character width if you change the font, font size or style, or replace a space with a non-blank character in a proportional font - 'W' is wider than ' ' (and depending on the font you select '.' may be narrower). So in a RichTextBox with
1) 2) the "2)" bit will move left or right if you type over the "1)" entry. Yeuch.
I agree whole heartedly on the lines bit - don't clutter things up!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I think that you didnt get me question(i know underline style).
I wanna something like this ?
<a href="">http:
|
|
|
|
|
the example in your original post seems quite doable in WordPad, and hence with underlining only.
The link you provided now is defective as well as suspiciously long and complex.
|
|
|
|
|
This[^] is a 'proper' link in case you're interested
|
|
|
|
|
proper it is; is it somehow related to the original question as well?
|
|
|
|
|
well I dont see how he could hope to acheive that using a rich text box.
I think he's just after some kind of lined page effect that responds to the selected Font height. This is probably doable (measuring string sizes in GDI+ ) but more work than I'm prepared to do to experiment as it's not something I'd ever use!
|
|
|
|
|
I haven't done multi-threading before, so I need a bit of help with this.
I have a form with a button. When user clicks on the button for the first time, a recursive function is called. When a certain condition in the function is true, I want the function to wait where it's at for the next button click.
An example:
void ButtonClick(object sender, EventArgs e)
{
if (running)
{
}
else functionCall(0);
}
void functionCall(int num)
{
if (num % 2 == 0)
{
displaySomething();
}
functionCall(num + 1);
}
How would I do this? If I understand correctly, I have to create a class for the thread that's going to run the recursive function. The second thread should wait for the main thread (Monitor.Wait(MainThread???)) to give a pulse, but how would I define the main thread?
modified on Monday, September 6, 2010 2:37 PM
|
|
|
|
|
A simpler solution would be to use a BackgroundWorker object to start the thread off and then use the Monitor object as you specified.
|
|
|
|
|
Thanks for the reply. BackgroundWorker class seems better for my situation, but I still don't really know what I'm doing. Here is what I tried as a test, but it gives me synchronization error.
public partial class Window : Form
{
bool running = false;
BackgroundWorker worker;
int num = 0;
public Window()
{
InitializeComponent();
this.button.Click += new EventHandler(ButtonClick);
}
void ButtonClick(object sender, EventArgs e)
{
if (running)
{
Monitor.Pulse(this);
}
else
{
running = true;
worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(Work);
worker.RunWorkerAsync();
}
}
void Work(object sender, DoWorkEventArgs w)
{
++num;
label.Text = num.ToString();
Monitor.Wait(this);
Work(null, null);
}
}
Also, the function Work should have additional parameters, but this is not possible, because DoWork event requires only object and DoWorkEventArgs and nothing more. Would calling another function from function Work (and adding Wait statement to that function) work properly?
Thanks in advance!
|
|
|
|
|
I would personally use the AutoResetEvent class instead of Monitor. I'm not sure if I understand your problem correctly, but the WaitOne() and Set() methods of AutoResetEvent might do exactly what you need.
|
|
|
|
|
Thanks! Surprisingly (since I didn't really add much), the code below works alright. However, I had to set the BackgroundWorker to sleep, otherwise the recursive function "skips" if user clicks the button multiple times really fast. Anyway to fix this? Also, am I doing this whole thing the right way?
void ButtonClick(object sender, EventArgs e)
{
if (running)
{
trigger.Set();
trigger.WaitOne();
label.Text = data.ToString();
}
else
{
running = true;
worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(Work);
worker.RunWorkerAsync();
trigger.WaitOne();
label.Text = data.ToString();
}
}
void Work(object sender, DoWorkEventArgs w)
{
recursive(0);
}
void recursive(int num)
{
if (num % 4 == 2)
{
data = num;
trigger.Set();
trigger.WaitOne();
Thread.Sleep(1);
}
recursive(num + 1);
}
Thanks again for the help!
|
|
|
|
|
Typically, when working with a thread, the thread expects a single object. In order to pass multiple values across, a common solution is to create a custom class that wraps the values and pass that instead. Now, another point - I wouldn't lock on this - use a static lock object instead, try:
private static readonly object _syncLock = new object(); Then you just lock on that object, i.e.
lock (_syncLock)
{
Monitor.Pulse(_syncLock);
} Finally, don't attempt to update a control property from a thread - WinForms uses STA, so you have to invoke back onto the UI thread and set it there.
|
|
|
|
|
Use of AutoResetEvent is good idea by using Set and Waitone methods.
You will require two instance of AutoResetEvent, one is for triggering condition(in your case button click) and other is for waiting for triggering.
Have you ever heard about producer/consumer pattern? Your problem can be easily solved by using this pattern. This pattern can be implemented in conditions where you have one thread producing the data and other thread consuming it. I cant make it out from your example whether the background worker is producing data or not (but i am sure it must be).
I would suggest you to go and search for this pattern you will get many good articles describing this pattern.
some of them are
www.albahari.com/threading/part2.aspx
Producer/Consumer Implementation Using Thread,Semaphore and Event
I hope this helps you to solve your problem
oops...I forgot to mention that recursive is not required if you use the above pattern use while(someflag){} instead.
Best Regards,
AD
|
|
|
|
|
Solution on: http://www.sendspace.com/file/f4pcjo
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
_tw = new ThreadingWrapper(this);
}
private ThreadingWrapper _tw;
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
_tw.ButtonClicked();
}
public void SetText(object o)
{
string text = (string)o;
label1.Text = text;
}
public void WaitingOnClick(object o)
{
label1.Text += " - WAITING";
button1.Enabled = true;
}
}
public class ThreadingWrapper
{
private AutoResetEvent _are = new AutoResetEvent(false);
private bool _waiting;
private Form1 _form;
public ThreadingWrapper(Form1 toControl)
{
_form = toControl;
}
internal void ButtonClicked()
{
if (_waiting)
{
_waiting = false;
_are.Set();
}
else
{
ThreadPool.QueueUserWorkItem(new WaitCallback(functionCall), 0);
}
}
private void functionCall(object p)
{
int num = (int)p;
Thread.Sleep(500);
_form.BeginInvoke(new WaitCallback(_form.SetText), num.ToString());
if (num % 10 == 0)
{
_form.BeginInvoke(new WaitCallback(_form.WaitingOnClick), "");
_waiting = true;
_are.WaitOne();
}
functionCall(num + 1);
}
}
Let me know if you need abort functionality... and I'm also open to any suggestions on how to improve code... always love to learn something new.
|
|
|
|