|
ReHi!
Nader Elshehabi wrote: Well, last time I checked my GC wasn't on vacation! My graphics objects are local variables, they will be disposable once the call to the handler is over
It's not that the GC isn't working correctly, you're not calling Dispose() !
You shoud use:
using (Graphics g = textBox.CreateGraphics())
{
} Nader Elshehabi wrote: Unfortunately, no! This is not a webpage where the user may click refresh, and almost all the causes of paint are mouse involved. Once the mouse is out of the box, it doesn't matter!!
Sorry to say that, but this is exactly the cause for many questions in this forum when people ask why they are having problems when they paint directly on top of controls.
The paint event is the only correct place to perform painting.
With your suggestion, just move another window over the textbox (or part of it) and you'll see what I mean.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hello
I don't want to sound like I'm just arguing, but it's nice to have this talk with you.
mav.northwind wrote: you're not calling Dispose()
Best practice, you should call dispose() I know, but it occurs to me, why to dispose it, if it will be disposed by itself after the event handler is finished??
mav.northwind wrote: just move another window over the textbox (or part of it) and you'll see what I mean.
How could you do that without moving the mouse out of the textbox first?;P
Again, it's nice to have this talk with you.
Regards
|
|
|
|
|
Rehi!
Graphics implements IDisposable and is freeing the native GDI+ graphics handle in its Dispose() method.
When you don't call Dispose() the resource doesn't get freed and your app will crash the computer after a while because it's running out of GDI handles eventually.
Nader Elshehabi wrote: How could you do that without moving the mouse out of the textbox first?
Alt-Tab? And another Alt-Tab to get back to the original window. The mouse still is inside the TextBox but I'm pretty sure there'll be no red border.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Hello
Thank you for your kind advice. I'll make sure to dispose managed objects I create. Also I'd be happy to read an article -specially if you wrote it- about when to dispose and when to leave that to the GC.
About the Alt-Tab!! Nice catch!!
Extra Regards
|
|
|
|
|
Hello
If you were following the conversation I as having with mav.. There will be a slight change in the code for the sake of optimization
private bool DrawBox = false;
private void textBox1_MouseEnter(object sender, EventArgs e)
{
Drawbox = true;
}
private void textBox1_MouseLeave(object sender, EventArgs e)
{
Drawbox = false;
}
private void textBox1_Enter(object sender, EventArgs e)
{
Drawbox = true;
}
private void textBox1_Leave(object sender, EventArgs e)
{
Drawbox = false;
}
private void textBox1_Paint(object sender, EventArgs e)
{
Graphics g = textBox1.CreateGraphics();
if(DrawBox)
g.DrawRectangle(new Pen(Brushes.Red, 3), new Rectangle(0, 0, textBox1.Width - 5, textBox1.Height - 5));
else
g.DrawRectangle(new Pen(Brushes.White, 3), new Rectangle(0, 0, textBox1.Width - 5, textBox1.Height - 5));
g.Dispose();
}
i hope that work mav.. Thanks!
Regards
|
|
|
|
|
Formally, this could work (although you don't have to create a Graphics object - the Paint event has one in its event args - and your rectangles will not be centered), but unfortunately in real life it doesn't.
It's because the TextBox isn't signalling a Paint event to a caller out of the box and thus your rectangle isn't painted.
You could derive from TextBox and set some control styles (UserPaint, mainly), but altogether the effect is not worth the trouble IMO...
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
i want to add first column of datagrid as checkedbox against every row of datagrid. then from the list i will select some checkboxes according to need.how i will implement this thing plz tell me any simple way.
reply soon.
|
|
|
|
|
Can you elaborate?
As of how to accomplish this, have you ever tried Google?
|
|
|
|
|
yes i have tried all even i read many articales in codeproject also. they are very complex and webbased. i dont understand them i read one artical
http://www.codeproject.com/aspnet/ChkBoxInGrid.asp
i want to do the same thing but in windows form. i dont understand how to bind checkbox with datagrid.and i want to display checkboxe with every row of datagrid. so plz help me
|
|
|
|
|
To add a checkbox column just open the Column designer and add a column of type DataGridViewCheckBox .
If you want to perform the selecting and deselecting etc, why you can just use Control and Shift combinations to achieve the same thing. There should be a property called SelectedRows so you can enumerate them.
As of how to accomplish this, have you ever tried Google?
|
|
|
|
|
I'm working on a HTTP(S) proxy and I got the HTTP part working complete with authentication.
Only HTTPS keeps buggering me, how should I handle this?
Do I need to setup a connection and just relay the data between the client and the server?
Because if I do that, the user is unabe to request another URL afterwards, at least with HTTP 1.1 and internet explorer 6/7 that is.
For HTTP I made the relaying part work by intercepting each request from the client and handle it as if it were a request for the proxy. That works great, but I'm unsure about HTTPS...
Any ideas on how to get this part to work?
WM.
What about weapons of mass-construction?
|
|
|
|
|
I have a class library I wrote, which deals with sockets.
I raise events through this library, such as DataArrival (which gives me the problem btw).
This is a snippet from my receiveCallback function:
Buffer bf = (Buffer)result.AsyncState;
bf.QueuePacks();
if (OnDataArrival != null)
{
if (caller != null) caller.Invoke(OnDataArrival, bf);
else OnDataArrival(bf);
}
sck.BeginReceive(bf.Data, 0, bf.Data.Length, SocketFlags.None, new AsyncCallback(receiveCallBack), bf); Buffer is also a class I wrote, and caller is a reference to a form.
This code works most of the time.
I'm currently working on a new project which uses my class.
In this project, I sometimes get an "Parameter is invalid" exception, on this line:
caller.Invoke(OnDataArrival, bf); It works most of the time, and never happend in my previous projects.
Is it wrong to invoke an event?
What's wrong with my parameters?
|
|
|
|
|
shyagam wrote: Is it wrong to invoke an event?
What's wrong with my parameters?
Care to provide some more details?
As of how to accomplish this, have you ever tried Google?
|
|
|
|
|
Ed.Poore wrote: Care to provide some more details?
Well... I don't really know what details I can give you...
Could you please point me in the right direction?
Ed.Poore wrote: As of how to accomplish this, have you ever tried Google?
Of course! That's how I knew I should use the Invoke method...
|
|
|
|
|
I meant details as to the exception, stack trace etc.
Nader's advice holds strong though.
As of how to accomplish this, have you ever tried Google?
|
|
|
|
|
Hello
shyagam wrote: I sometimes get an "Parameter is invalid" exception
You said "Sometimes", while other times not!! try debugging each call-;P- to Invoke, and see the values of the parameters, what's wrong with them. Also try to understand the pattern of the exception. Maybe a certain call is the problem. When the code works sometimes, it should work all the tims. So another code could be causing the problem.
shyagam wrote: never happend in my previous projects.
I guess this should point you to the possibility that the problem is in the current project!!
Regards
|
|
|
|
|
I have inserted a DataGridViewCheckBoxColumn in a DataGridView. But whenever I click on its DataGridViewCheckBoxCell, the box is not checked. How do I check it? Is any event needed?
dgvcbc = new System.Windows.Forms.DataGridViewCheckBoxColumn();
dgvcbc.HeaderText = "Check to delete";
dgvcbc.Name = "Check to delete";
dgvcbc.CellTemplate = new DataGridViewCheckBoxCell();
dataGridView1.Columns.Insert(0, dgvcbc);
Thanks!
|
|
|
|
|
Hello
The problem is for sure NOT in the code that you've posted. Are other columns in the DataGridView working too?!! Maybe you've set the eable to false by mistake or something. The above code should work fine!!
Regards
|
|
|
|
|
Hi,
There is only one DataGridViewCheckBoxColumn in the DataGridView. Other columns are mainly DataGridViewColumn and DataGridViewLinkColumn. The links work perfectly.
You mentioned the setting problem. What do you think has been set to false by mistake? What is the code for that setting?
Thanks again.
|
|
|
|
|
Hello
Well, as I told you in my previous post, this code should work!! You can tamper with the settings of your DataGridView in a way that it may stop responding. I gave you an example. Check the Enable prpperty of your DataGidView.
Also check to see if you've made this column as ReadOnly . You can check both from the property grid.
When I asked about other columns, I meant are they working in any how?? Can you edit the cells??
Regards
|
|
|
|
|
Hi,
Do you mean the dataGridView.Enabled property? But it is set to true which allows user interaction. And the CheckBoxColumn isn't set to ReadOnly. So what else should I check?
Thanks!
|
|
|
|
|
Hello
Well, err... Yes! Forgive the typo. I mean Enabled.. I'm running out of guesses here. Try to add another CheckboxColumn, and see what happens. Also you didn't answer my question. Do other Text columns work? Can you type in them?
Regards
|
|
|
|
|
Hi,
It's working now. I found out that the datagridview is readonly though I checked that the checkboxcolumn is not readonly.
Anyways, thanks very much for your help.
|
|
|
|
|
I need to know how to edit a combobox on a web page in a webBrowser object (using MSHTML). The code for the combobox in HTML uses the SELECT and OPTION tags. I can check the checkboxes, fill the textfields and click the buttons, but I can't figure this one out. Any help would be appreciated! Thanks!
Scott Clayton (My birthday was on the 23rd!)
|
|
|
|
|
Hi Everybody!
Can anyone recommand program that creates and HTML in MSDN style out of the xml documentation?
I've been looking for one on the web, but strangly I couldn't find one! (I thought there would be dozens!)
Thanks!
|
|
|
|