2 ways to do it. You can either pull the entire datatable worth of information and databind the table using a bindingsource(look up the bindingsource control), or you could make a call to the db every time you enter something and get that information. Conceptually its pretty easy, you have a db full of information, and something you're using as the key to look stuff up. Hopefully you'll be able to figure out how to apply the SQL queries/form interaction.
Drew McGhie
Posts
-
Bind data into textbox -
Bind data into textboxDoes this data need to be editable, or is it just displaying information based on the (i'm assuming unique) code?
-
Refresh DataGrid with Latest ValuesThe bindingsource does all that for you. When you update the underlying dataset, it updates anything the bindingsource is linked to.
-
Refresh DataGrid with Latest ValuesYou probably want to take a look at the BindingSource[^] class. It should handle what you're looking for.
-
uploading multiple files using ftpWow. 5 crossposts about 3 issues in 10 minutes, all saying "I need x". You won't get that here. Ever. People here won't do work for you, unless you pay them.
-
Windows Form TableThere's a toolbox in the designer. You should be able to click and drag one of many kinds of tables from there.
-
Cannot get datagridview to show recordsThe fact that you're using the DataGridView means you're using VS.Net 2005. The designer is really helpful in setting up datagridview columns and formatting if you need anything beyond basic formatting and display. Check that out if you get a chance.
-
Cannot get datagridview to show recordsAs far as I can see, you do all the data stuff fine, but you never actually add the datagridview to the form itself. Try this.Controls.Add(objDBGridView);
-
loading a combobox without repitition, how to??As an alternative to what people have said, is there any sort of pre-population of the items in the combobox? If you're just populating the CB from items in a database, and you don't want things to repeat, just use DISTINCT in the query from the database (I'm assuming SQL here), and just use the combobox.displaymember, combobox.valuemember, and combobox.datasource to set it up.
-
inserting a text box into datagridviewDataGridViewTextBoxColumn MyColumn = new DataGridViewTextBoxColumn(); myDataGridView.Columns.Add(MyColumn);
Try that. Syntax is off the top of my head, so you may have to modify things slightly, but at runtime, that's the way to do it. In the designer, right click the DGV and select "add column" -
strange error in DataGridView Control windows FormsHow are you attaching it to the view, through a bindingsource or just saying DGV.DataSource=theView; Also, how are you trying to access the value of the cell?
-
Suspending event handlingOn a usercontrol, is there an easy way to suspend all event handling on the control and all child controls? I don't want my event handling to keep firing as I set the form up, rather I just want to call a set of calculating/formatting functions just once in Load(), and then have all the events (which call the calculating/formatting functions) start firing. Right now I have an if statement in each event that ties to a boolean that I set when I want events to start working, but it seems like there might be an easier way. Any suggestions?
-
problem in DatagridAs an expansion to this, use a DataGridView and a BindingSource. It provides superior data management capabilities. Search the CP articles for a good one on data binding and the datagridview
-
how to add rows in DataRow object and How to Merge it to Dataset ObjectYou really can't merge a datarow and a dataset, they're a level of abstraction away from each other. If you're looking to add a row to a table within a dataset, you can use ds.Tables["tablename"].Rows.Add(DataRow), assuming they have the same schema.
-
Finding specific coordinates in MS Word using C#Can you give us more information as to what information you have that define what will be selected?
-
Difference in showing formsAh, you're right. I was trying to give an example of something visual that the user would see.
-
Difference in showing formsTo Support what Luc said.
Application.Run(myForm); MessageBox.Show("whee!");
Would wait for your form to close to display "whee!", while
myForm.Show() MessageBox.Show("whee!");
Would open your form, then immediately show the messagebox. If I have child forms in windows applications I'm running, I generally use Form.Show() Form.ShowDialog() depending on what I need. ShowDialog acts similarly to Application.Run(), in that it must return before code is executed in the parent, while Show() allows for parallel interaction.
-
DataGridView Current RowDataGridView.CurrentRow returns the Row that contains the currently selected DataGridViewCell. In addition, if you handle the DataGridView.RowHeaderClick event, you can check the e.RowIndex Property to see the row number that was clicked.
-
SQL DistinctWell, say there are 3 rows agtMast ID Name Other One 22 James Other1 One 22 James Other2 Two 22 Bond Whee! There are 2 distinct values for the agtMast column, but 2 possible sets of values are different. Do you want one row for each agtMast value, and are there specifics as to which one should be selected, or do you want the distinct sets of values (So if One/22/James/Other1 appeared 10 times, you would want it to appear only once, but have One/22/James/Other2 appear as well after the query) I need some more information as to how you're clarifying the "correct" row.
-
Listbox selecteditemsThanks for the response. What I ended up getting working was looping through the items list (which will never be more than a dozen or so), rather than the List<> of items that needed to select. From that, I could parse the correct object from the associated datarow (by casting it as such) and then compare that to the list of approved items.
uxlbSuite.SelectedItems.Clear(); List objectsToAdd = new List(); foreach (object unit in uxlbSuite.Items) { System.Data.DataRowView Row = unit as System.Data.DataRowView; if (Row != null && toSelect.Contains(Row["ID"].ToString())) { objectsToAdd.Add(unit); } } foreach (object unit in objectsToAdd) { uxlbSuite.SelectedItems.Add(unit); }