|
Hi,
I would like to create a drag box on a form. The behavior that I'm talking about is what you see in the Form Designer of the IDE when you click and hold down the mouse button on a form (but not on a control that you placed) and drag the mouse. A dashed box is drawn while you hold down mouse. Could somebody tell me where I should be looking to begin coding something like this? (It would be cool if there were an example but anything would do.)
Thanks!
|
|
|
|
|
I have a database that contains 2 tables.
The first called Users contains username and password
the second called PhoneNumbers contains a primary key called PhoneNumberID, a User column and a column with the telephone numbers of the users, that can be 0, 1 or more.
There is a relationship one-two-many between the username in the Users table and the username in the PhoneNumbers table.
Now I want to make an application that displays the phone numbers of a given user and allows to add or delete new numbers.
I thought that the best method is to use a listBox, a texBox and two buttons, add and remove.
The user loads the data from the database, populate the listBox, selectt a number and clicks delete, and the number is deleted. Write a number in the textBox and clicks add and the number is added.
I make this through an XML Web Service.
I have a method that takes username and password, and returns a DataSet to the clien.
Than i use foreach to add all the returned phone numbers to the listbox.
Now THE QUESTION:
How I manage the update?
If a user added a phone number, the update should add a row to the database, if delete delete the corresponding row.
When the user clicks the update button, the code should,
check all the items actually in the listbox, determine if it was added, or know if some of the previously held was deleted.
HOW I ACCOMPLISH THIS?
And after this, how I create a link with the rows in the database, since the listbox, contains only the phone number value, but no primary key of the PhoneNumbers table?
An help is greatly apreciated.
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
|
|
|
|
Nnamdi Onyeyiri wrote:
hmmm - may take a while for me to pick the code out.
Are you trying to write your own based on the one by Carlos H. Perez? or just use that one in your project? If the latter, it is rather easy to use.
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
|
Nnamdi Onyeyiri wrote:
im making my own one,
Good luck then! how's yours different? it is suitable for general-case use? if so, you could write an article for CP
Cheers,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
In my main form's code, it has a button for adding another tabbed pane with
the following handling code:
<br />
private void button2_Click(object sender, System.EventArgs e)<br />
<br />
{<br />
<br />
BidPage bp = new BidPage(tabControl1);<br />
<br />
bp.Location = new System.Drawing.Point(4, 22);<br />
<br />
bp.Size = new System.Drawing.Size(552, 326);<br />
<br />
bp.TabIndex = this.tabControl1.TabCount + 1;<br />
<br />
bp.Text = "BidPage" + currID;<br />
<br />
tabControl1.TabPages.Add(bp);<br />
<br />
<br />
<br />
currID++;<br />
<br />
}<br />
<br />
However, when a new BidPage is added, it's supposed to contain a button, but
it's blank! What's going on? Here's the BidPage class code:
<br />
<br />
using System;<br />
<br />
using System.Windows.Forms;<br />
<br />
namespace WindowsApplication1<br />
<br />
{<br />
<br />
<br />
<br />
<br />
public class BidPage : TabPage<br />
<br />
{<br />
<br />
private Button removeButton;<br />
<br />
private System.Windows.Forms.Label label1;<br />
<br />
private System.Windows.Forms.Button remButton;<br />
<br />
private TabControl parentTabControl;<br />
<br />
public BidPage(TabControl tcOwner): base()
<br />
{<br />
<br />
<br />
<br />
<br />
InitializeComponent();<br />
<br />
parentTabControl = tcOwner;<br />
<br />
}<br />
<br />
private void InitializeComponent()<br />
<br />
{<br />
<br />
this.SuspendLayout();<br />
<br />
this.label1 = new System.Windows.Forms.Label();<br />
<br />
this.remButton = new System.Windows.Forms.Button();<br />
<br />
<br />
<br />
<br />
this.label1.Location = new System.Drawing.Point(17, 17);<br />
<br />
this.label1.Name = "label1";<br />
<br />
this.label1.TabIndex = 0;<br />
<br />
this.label1.Text = "label1";<br />
<br />
this.label1.Click += new System.EventHandler(this.label1_Click);<br />
<br />
<br />
<br />
<br />
this.remButton.Location = new System.Drawing.Point(98, 17);<br />
<br />
this.remButton.Name = "remButton";<br />
<br />
this.remButton.TabIndex = 0;<br />
<br />
this.remButton.Text = "remove tab";<br />
<br />
this.remButton.Click += new System.EventHandler(this.remButton_Click);<br />
<br />
<br />
this.ResumeLayout(false);<br />
<br />
}<br />
<br />
private void remButton_Click(object sender, System.EventArgs e)<br />
<br />
{<br />
<br />
parentTabControl.TabPages.Remove(parentTabControl.SelectedTab);<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
|
|
|
|
|
After you 'new' the button, you must then add a call to this.Controls.Add(remButton) . This tells the TabPage that it is the "Owner" of the button and should then display it, if remButton.Visible = true. You can do this either in the Initialize() or in the constructor.
Later,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
How can I stop a form from redrawing itself while I make a lot of changes to its child controls?? In Win32 there is the WM_SETREDRAW (or is it WM_REDRAW) message. Is there a way to do it in Windows Forms? Or do I have to send the message to the Windows the Win32-way? if so, how do I do that?
Thanks,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
You can use this method:
Control.SuspendLayout Method
(from help)
"The layout logic of the control is suspended until the ResumeLayout method is called.
The SuspendLayout and ResumeLayout methods are used in tandem to suppress multiple Layout events while you adjust multiple attributes of the control. For example, you would typically call the SuspendLayout method, then set the Size, Location, Anchor, or Dock properties of the control, and then call the ResumeLayout method to allow the changes to take effect."
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Hi, try adding these 2 lines to the constructor of the form/control:
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
From the MagicLibrary help file:
The first line will request that double buffering be used whenever the OnBackground or OnPaint methods are called. This will reduce the amount of flicker but may not remove it completely as painting the whole control still results in two separate blitting operations.
The second line of code above is used to ensure that only a single blitting operation occurs when drawing. This occurs when the underlying windows WM_PAINT message is processed. When this happens it will create the memory bitmap, call the OnBackground method, call the OnPaint method and then finally blit the result to the screen.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
This doesn't stop the form from painting itself while everything is being moved. It does stop most of the flickering involved but with him moving/resizing controls more will have to be done to prevent the redrawing.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I added those two lines, and it caused some problems... the toolbar appeared with the images on top of what was previously where my window appeared (background not erased) and if I moved a dialog on top of it, it did not repaint itself well.
But I removed a great deal of flicker by changing the order of making controls visible and invisible, moving panels and so on.
Thank you all for your help!
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
What about SuspendLayout ? did it work ?
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
Andres Manggini wrote:
What about SuspendLayout ? did it work ?
No. I tried it also, but I have to call it for each control (for the toolbar, status bar, outlook bar, different panels, and so on) and when I called ResumeLayout for each, the same flicker occured because it first did everything for the toolbar and painted, then the outlook bar and repainted, and so on... But thanks anyway for your help,
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
I meant to use the method on the form, not each control, I thought that was what you were looking for.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
I first tried calling the form's method, but nothing happened differently... As I understood the documentation, calling SuspendLayout acts only on changes in the control's own Location, Size, Dock and Anchor properties, not on its children's.
-- LuisR
──────────────
Luis Alonso Ramos
Chihuahua, Mexico
www.luisalonsoramos.com
"Do not worry about your difficulties in mathematics, I assure you that mine are greater." -- Albert Einstein
|
|
|
|
|
Anybody knows how to implement the Context Sensitive Help? I looked into the MSDN there is no example and no hint how to do it, also I worked with HelpProvider class but unable to achieve it. Is anybody can help me in this or send me link where I can get the info about it.
Thanks in advance.
|
|
|
|
|
i have a static arraylist Commands , and a struct SvrCmd
i have used the following code to create a static member of type SvrCmd, and also add that static member, to the Commands array list
public static SvrCmd Abor = new SvrCmd();
Abor.Cmd = "ABOR";
Abor.Description = "Abort Transfer";
Commands.Add(ServerCommand.Abor); and i get a whole load of errors.
oh yer, the SvrCmd struct has public string members Cmd and Description
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
|
|
Nnamdi Onyeyiri wrote:
Commands.Add(ServerCommand.Abor);
What is ServerCommand? You say you have a SvrCmd type.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|