flynn
Avatar/Signature-
Posts
59 -
Joined
-
Last visited
flynn's Achievements
Newbie (1/14)
0
Reputation
-
I have an app that is currently getting data from a remote server, via the internet, and putting that data into a DataGridView. The data (a full client list) is being pulled down when the app is started and displayed. This solution has worked but now the customer is getting too many clients to bring down at one shot. The number of clients is starting to cause a significant delay at startup and I'm looking for a new method of getting the data. The customer wants to keep the DataGridView functionality. I'd like to be able to put a textbox on the form so that on each keystroke I could call a stored proc that would return the first 20 clients that matched the current textbox entry. Then, as the customer would press PageDown or DownArrow, I would retrieve the next 20 that matched the textbox entry. Or if the customer pressed PageUp or UpArrow, I would retrieve the previous 20. Does this design sound workable or am I way off in wanting to accomplish this from a remote server? Can anyone point me toward a sample that would be a good starting point? I realize this will be a significant code change in this part of my application. Current code layout: SqlCommand sc = new SqlCommand(SP_SELECT_CLIENTS, conn); sc.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(sc); conn.Open(); da.Fill(dsClients, CLIENT_TABLE_NAME); conn.Close(); // bind table to BindingSource and DataGridView m_ClientBindingSource.DataSource = dsClients.Tables[CLIENT_TABLE_NAME]; dgvClient.DataSource = m_ClientBindingSource; Thanks in advance, flynn
-
- data
- datagridview
-
(and 1 more)
Tagged with:
-
I understand that the quote character is an illegal character in a path name. What I'm not understanding is why the GetPath() call returns such a mangled string ("\"C:\\\"") and not just C:\ (or at least C:\\). I have attached 2 print screens for reference. When the exception occurs, I execute the GetPath() method in the Immediate window (shown in the print screen). It shows the mangled string. Screen shot 2 shows the value of the tsPathLabel as I entered it (C:\) in the properties window. So I guess what I don't understand is why the string has all the 'escaping' when all I enter is C:\ . I can do this: tsPathLabel.Text.Replace("\"",""); but is this a valid way to handle the problem?
-
On my form, I have a ToolStrip that contains a ToolStripLabel that has it's 'Text' property set to "C:\". When I run the following code, the "diDirectory.GetFiles()" method throws an "Illegal characters in path." exception. DirectoryInfo diDirectory = new DirectoryInfo(tsPathLabel.Text); FileInfo[] Files = diDirectory.GetFiles(tsFilter.Text); this.SuspendLayout(); foreach (FileInfo File in Files) { ListViewItem lvi = new ListViewItem(new string[] {File.Name, File.Length.ToString() }); listView1.Items.Add(lvi); } this.ResumeLayout(); This is what is displayed when I print the label in the Immediate window: ? tsPathLabel.Text "\"C:\\\"" ? tsPathLabel.Text.ToString() "\"C:\\\"" The text I was expecting is "C:\". Is there a reason that I'm seeing the text above instead of what I was expecting? tia flynn
-
Nevermind, I found them: Leave/Enter.
-
Am I missing the obvious? Does the ListView control not have an event for losing/gaining focus? Could someone point me in the right direction of how to detect when these 2 events happen on a ListView? thanks in advance, flynn
-
When I step into the event handler to display the ".SourceControl", I print the following in the Immediate window: ? this.cmMRUList.SourceControl.Name 'this.cmMRUList.SourceControl' is null
-
I have 2 textboxes (tbxCustomerName, tbxCustomerNumber) that has a custom context menu attached (cmMRUList). The context menu has a sub-menu (MRUMenuItem_Recent) that contains the most-recently-used customer names. Within the click event (OnMRURecentItemClick(object sender, EventArgs e)) of the MRUMenuItem_Recent items, I need to get the text of the "parent" textbox that the context menu was initiated from. I've looked at the "sender" object to try to find the top level control, but to no avail. The "owner" property of the "sender" contains the context menu itself. Is there a way to get the top level control ?
-
Got it to work. Thanks Nate for your reply. A special thank you to MrPaul, this is exactly what I needed. MrPaul, I mis-read your original post and put the "new" in the definition instead of the method call, and of course the compiler was having none of that!
-
When I type "new" to create the code you suggested, "new" doesn't display in the drop-down that is displayed (this is the closest match: "NewsStyleUriParser"). Am I missing something?
-
I am trying to create a generic class that will take a most-recently-used list and create a context menu for it. The code below (in a slightly different version) works perfect, but only if I have the function "BuildMRUSection()" in the CustomerClass. The reason for this is because the "tsmi.Click += " needs to be able to see the "OnMRURecentItemClick" event handler in order to assign it. What I need to be able to do is pass a pointer to the function "OnMRURecentItemClick" into the MRUList_Dynamic class in order to do the assignment within that class. This will make the routine more encapsulated and easier for the caller. public partial class CustomerClass { MRUList_Dynamic mruDynamic = new MRUList_Dynamic(); private void OnMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { MRUList_Dynamic mruDynamic = new MRUList_Dynamic(); mruDynamic.BuildMRUSection(ref MRUMenuItem_Recent); <-- need to be able to pass a function pointer here in order to wire up the mru menu items to the event ((TextBox)sender).ContextMenuStrip = cmMRUList; } } // event handler for all mru menu items clicked private void OnMRURecentItemClick(object sender, EventArgs e) { ToolStripMenuItem tsmi = (ToolStripMenuItem)sender; if (tsmi.Equals(MRUMenuItem_Copy)) Clipboard.SetDataObject(tbxCustomerName.SelectedText); else if (tsmi.Equals(MRUMenuItem_Cut)) { Clipboard.SetDataObject(tbxCustomerName.SelectedText); tbxCustomerName.SelectedText = ""; } else if (tsmi.Equals(MRUMenuItem_Paste)) ; else if (tsmi.Equals(MRUMenuItem_Delete)) tbxCustomerName.SelectedText = ""; else { // set the textboxes based on the mru item selected tbxCustomerName.Text = tsmi.Text; tbxCustomerNumber.Text = tsmi.Tag.ToString(); } } } public class MRUList_Dynamic { public const Int16 NUM_ITEMS = 10; const Byte NAME_COLUMN = 0; const Byte ID_COLUMN = 1; // array contains the "most recently used" items static String[,] MRUArray = new String[NUM_ITEMS, 2] { { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" }, { "", "" } }; // adds the name/PCN pair in the first slot, moving all other items down 1 slot public static void AddName(String PCN, String sName) { for (Int16 x = NUM_ITEMS - 1; x > 0; x--) { MRUArray[x, ID_COLUMN] = MRUArray[x - 1, ID_COLUMN]; MRUArray[x, NAME_COLUMN] = MRUArray[x - 1, NAME_COLUMN]; } MRUArray[0, NAME_COLUMN] = sName; MRUArray[0, ID_COLUMN] = PCN; } // retrieve the Name at a specific slot public static String GetNameAt(Int16 x) { return MRUArray[x, NAME_COLUMN]; } // retrieve the PCN at a specific slot public static String GetPcnAt(Int16 x) { return MRUArray[x, ID_COLUMN]; } // pass in the pop-up menu as a reference; then create the mru items public void BuildMRUSection(ref ToolStripMenuItem MRUMenuItem_Recent) { // if the dropdown menu items aren't cleared out, items might be duplicated over and over MRUMenuItem_Recent.DropDownItems.Clear(); for (Int16 x = 0; x < NUM_ITEMS; x++) { ToolStripMenuItem tsmi = new ToolStripMenuItem(); if (tsmi.Text != "") { tsmi.Size = new System.Drawing.Size(245, 22); tsmi.Visible = true; tsmi.Click += new EventHandler(OnMRURecentItemClick); //<--- need pointer to "OnMRURecentItemClick" function passed into here MRUMenuItem_Recent.DropDownItems.Add(tsmi); } } } } I've also tried to pre-fill (in the calling class) a ToolStripMenuItem's Click method with the address of the function of the event handler, then pass this into "BuildMRUSection()" as a template to create the mru menu items, but that doesn't work either. // code to pass in a pre-filled "template" of the menu item mruDynamic.BuildMRUSection(ref MRUMenuItem_Recent, tsmi_tmp); public void BuildMRUSection(ref ToolStripMenuItem MRUMenuItem_Recent, ToolStripMenuItem item_template)
-
Is it not possible to capture every CONTROL-x keyboard combination, where "x" is any alphabetic character? Using the following code, I can't seem to capture CTRL-J, but CTRL-F works. Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean If (keyData = (Keys.Control Or Keys.J)) Then Console.WriteLine("You pressed CTRL+J") Return (True) End If If (keyData = (Keys.Control Or Keys.F)) Then Console.WriteLine("You pressed CTRL+F") Return (True) End If Return MyBase.ProcessCmdKey(msg, keyData) End Function
-
I am tasked with creating a generic "end-user" query tool. One of the features is the ability to query on any field of any table. I have most of my design done, but I still need the ability to determine if a column is based on a "number" type. The type can any of the "number" types: tinyint, bigint, numeric, decimal, money, etc. Basically any column that can be compared using "<", ">" or "=" operators. Using "exec sp_columns 'customer'", I can get a list of the columns and data types (column "TYPE_NAME"), but I was hoping that there was an easier way to determine what columns I can apply the "<>=" operators. If there isn't then I guess I'm stuck with looping through the column types to determine if the selected column can be used as a "number" type. Typical use would be allowing the end-user to select a column from a list of available columns, then select an operator (<>=), then type a number in a text box to use as the compared value. tia, flynn
-
Thank you Nerseus. This is the part that had me stumped: INNER JOIN sales_rep sr ON sr.rep_id = c.rep_id AND ( (sr.employee_number = c.employee_number) OR ( sr.territory = @sr_territory and sr.branch = c.branch ) )
-
Given this SQL query (which uses the old style "WHERE" clause to do joins): SELECT c.cust_id, c.name, c.address_1, c.address_2, c.address_3, c.city, c.state, c.zipcode, co.first_name, co.last_name , co.fax, sr.rep_name, sr.rep_phone, sr.rep_fax, sr.rep_email FROM customer c, contact co, sales_rep sr, customer_price cp WHERE ( c.static_cust_numb = cp.static_cust_numb ) and ( c.rep_id = sr.rep_id ) and ( cp.sales_code = @cp_sales_code ) AND ( c.employee_number = sr.employee_number or ( sr.territory = @sr_territory and sr.branch = c.branch )) AND ( c.status <> @customer_status ) AND ( c.rep_id = @rep_id ) AND ( co.default_contact = 'Y' AND c.static_cust_numb = co.static_cust_numb ) Can someone translate to use "JOIN" statements instead of using the "WHERE" statement? In particular, I'm not quite sure how to translate this line ( c.employee_number = sr.employee_number or ( sr.territory = @sr_territory and sr.branch = c.branch )) AND Thanks in advance, flynn
-
Is there a way to force the DataGridView's "Edit Columns" dialog box to resize (on open) so that all the properties are visible? Every time I open it, I resize it so I can see *ALL* the properties without having to scroll. tia, flynn