|
Here's one way to do this:
- Handle the text changed event of the text box.
- Use the current text to repopulate the combobox.
/ravi
|
|
|
|
|
Please, when posting a question, throw in some code to discuss. If below does not what you expected, then I probably misinterpreted your question. When including code, please wrap in <PRE> tags. I've included some linenumers so we can easily refer to parts of the code using it's linenumber.
1 class Program
2 {
3
4 class Person
5 {
6 public string FirstName { get; set; }
7 public string LastName { get; set; }
8 }
9
10 static void Main(string[] args)
11 {
12 using (var f = new Form())
13 {
14
15
16
17 var cmb = new ComboBox()
18 {
19 Dock = DockStyle.Top,
20 DataSource = typeof(Person)
21 .GetProperties()
22 .Select(p => p.Name)
23 .ToArray()
24 };
25
26
27
28 var theTextBox = new TextBox()
29 {
30 Dock = DockStyle.Top
31 };
32
33
34 theTextBox.TextChanged += delegate
35 {
36 string zeTextDatWeNeed = theTextBox.Text;
37 cmb.DataSource = typeof(Person)
38 .GetProperties()
39 .Select(p => p.Name)
40 .Where(p => p.Contains(zeTextDatWeNeed))
41 .ToArray();
42 };
43
44 f.Controls.AddRange(new Control[]{ theTextBox, cmb });
45 f.ShowDialog();
46 }
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
This sounded easy at first and I'm already spending a whole day.
I am looking for cells which contain non-zero or non-null float values in one particular column. My code is
Excel.Range Cells = currentWorksheet.get_Range(lowRange, upRange);
currentFind = Cells.Find(cellName, lowRange, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false, misValue, misValue);
Now the problem lies with cellName. I cannot define it because I don't know what float values I will be getting from my cells. And is there anything like definite non-null or non-zero object that I can possibly use in place of cellName?
Thanks in advance!
modified 15-Jan-14 3:17am.
|
|
|
|
|
According to MSDN[^], the first parameter is the value you look for, not the cells' name. It'll look at all the cells in the specified range, and return those with specified value. MSDN suggest foreach-ing them.
emma.sun.sts wrote: And is there anything like definite non-null or non-zero object that I can possibly use in place of cellName? Not if it expects a name; but if the cell is named, then there would not be a use for the range.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
No, the cells are not named. I don't even know what values those cells are holding.
|
|
|
|
|
The Find method is not appropriate for this type of filtered enumeration.
You could apply an Autofilter to the Range and then retrieve the Range.SpecialCells(Excel.XlCellType.xlCellTypeVisible) Range and iterate over that. However this is a lot work that would be easier to do in your own .Net code.
Once you have a Range object defined, you can retrieve the entire range as a two dimensional array of System.Object. Here is snippet showing how to do this.
rng = ws.get_Range("A1", "A5");
object[,] retrievedarray = (object[,])rng.get_Value(Excel.XlRangeValueDataType.xlRangeValueDefault);
for (Int32 col = retrievedarray.GetLowerBound(1); col <= retrievedarray.GetUpperBound(1); col++)
{
for (Int32 row = retrievedarray.GetLowerBound(0); row <= retrievedarray.GetUpperBound(0); row++)
{
if (retrievedarray[row, col] is double)
{
double value = (double)retrievedarray[row, col];
System.Diagnostics.Debug.WriteLine(value.ToString());
}
else if (retrievedarray[row, col] == null)
{
System.Diagnostics.Debug.WriteLine("null");
}
}
}
|
|
|
|
|
This works amazingly! Thank you so much!
|
|
|
|
|
I am using Visual Studio 2010, Sql server Express Edition & C#.
I have develop a simple Master Detail application (mostly with the help of experts help from this forum) An Order system, and now I want to go one step further from simple application to N-Tier version.
Did some search on net and came up with Tutorial which guides me enough to create Order class which contains methods: -DataTable GetOrders(int OrdId) Retrieve order based on ID provided -int SaveData(string CustID, DateTime ShpDate, DateTime OrdDate) To save the order, This method has all Insert, Update, Delete command in it, using SqlAdapter.
Following the same pattern I've also created OrderDetails class for setting up line items for each order. OrderDetails also contains methods GetOrder & SaveData...
Now the main problem, what should I do to save the whole Order with OrderDetails? I know this is something I should wrap up in Transaction and create Relation after adding Data to Dataset...But not sure how to do it? any link/tutorial/sample/guidance will be highly appreciated.
I've not posted any code due to make this post clear...If required I will post the code immediately.
Thanks
Ahmed
|
|
|
|
|
"N-Tier" means usually "3-tier", which usually means having a GUI, a DAL, and a BO-layer. Take a look at some codegenerators, they usually come with templates to generate a lot of the scaffolding.
I suggest adding layers as you need them; the database is a DAL - it has abstracted away the data-saving and validation in abstraction that one can query using SQL. There are also some nice ORM-packages out there that automagically load datatables into BO's.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks for your reply,
I've created DAL class for data access ofcourse, purpose of which is to provide Database connection and execute Sql commands or stored proc.
As mentioned in my question, I've created Order class which will access DAL class and Get and Save Order..
The problem I am facing is from OrderDetails class...
My approach is: On the Winform (which is I think Presentation layer) when user clicks save button It should do the following:
1-Create Order class instance (for eg. Order od = new Order()) and then call Order class SaveData method by providing parameters: Like od.SaveData(OrdId,CustId OrdDate, ShpDate)
Which then ultimately save the order Master data...Order master is bind to DataTable.
Now the problem: How should I save OrderDetails...which is in DataGridView name dgGrd, dgGrd is also bind to DataTable.
OrderDetails also have SaveData method which take parameters (ProductID, Quantity, UnitPrice)...How should I call SaveData method within Order class? How should I pass whole DataGridView DataTable to SaveData method of OrderDetails class?
I will be very much appreciate if you could help me to line up my coding, perhaps if you could provide a sample? showing N-Tier Master Detail...I am still at beginner learning stage...And still doing lots of net searching for answer..
Thanks in advance
Ahmed
|
|
|
|
|
ahmed_one wrote: I've created DAL class for data access ofcourse, purpose of which is to provide Database connection and execute Sql commands or stored proc. That means that the other two layers aren't allowed to touch the database.
ahmed_one wrote: Now the problem: How should I save OrderDetails...which is in DataGridView name dgGrd, dgGrd is also bind to DataTable. That's a problem indeed; one would use the Order and OrderDetails classes, not a DataTable. If the GUI has a datatable, then you have a data-access class in your UI (you'd have an element in the presentation layer that should not be known outside the DAL)
ahmed_one wrote: How should I call SaveData method within Order class? When the order is saved, foreach the details and save them under the correct order-Id.
ahmed_one wrote: I will be very much appreciate if you could help me to line up my coding I can help with specific questions; if you'd post a summary on how the order(detail) class looks and is saved and we'll look at it.
ahmed_one wrote: perhaps if you could provide a sample? The N-Tier architecture is a bit too elaborate to catch in a small sample.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you very much for your reply...
I've modified my Order and OrderDetails class..Actually overall Project..
Now My form Master Fields bind to DataTable dt and Details DataGridView was bind to dtDet...
Then create relation for both tables
Then both tables added to Dataset...2 bindingSource bindMaster and bindDetail created...Set bindMaster datasource to Dt and bindDetail datasource to relation name. Pass the dataset to Order's SaveData method..
Both class's SaveData method are also modified to accept Dataset and DataTable....Also both classes now set up for Sql Insert/Update/Delete commands via SqlAdapter.
Now it works for Saving Order with order Details...Now I need to move one step further to use classes for search the orders by OrderID or OrderDate options...I guess this is not so difficult task as saving the order...
Thanks again for your guidance...I hope if I will stuck in future I will get help from here
Regards
Ahmed
|
|
|
|
|
ahmed_one wrote: Now it works for Saving Order with order Details Nice
ahmed_one wrote: Now I need to move one step further to use classes for search the orders by OrderID or OrderDate options The DataTable has a handy filter-method.
ahmed_one wrote: I hope if I will stuck in future I will get help from here That's the idea; and soon you'll be helping others to get unstuck
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I've add SearchOrder method to Order class which take Id as parameter and retrieve records from Database, same method added to OrderDetails class. Difference is only return type, Order class method return Dataset because in Order class I've also retrieve OrderDetails (which return as DataTable) and add to Dataset of Order class SearchOrder method. Then I bind the WinForm with this DataSet...
I hope one day I will be competent enough to help others.
Thanks for your help and support.
regards
Ahmed
|
|
|
|
|
You're welcome
|
|
|
|
|
|
You've come to the wrong forum. This is not the place to post your "jobs".
|
|
|
|
|
Dave Kreskowiak wrote:
You've come to the wrong forum website. This is not the place to post your "jobs". |
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
My bad! I'm picking my brain up off the floor now. I'm so clumsy with it sometimes.
|
|
|
|
|
I have that problem most days...
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
where can i get the .net framework Source code.i want it!thks.
|
|
|
|
|
Have you asked Microsoft nicely?
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
.NET is not open source, it is proprietary to Microsoft, who are unlikely to be willing to part with it.
However, you should be able to find the source to MONO - which is the Open Source version for Linux boxes. Google can help you. Be prepared for a significant sized download...
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
|
Hades hath skating rinks!
I am soooo tempted to download that - any idea how big it is? Chrome just says it's an ASPX file and doesn't give me a total size. And with a 3.5mb/s connection...
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|