|
Hi,
I have +20 comboboxes in my windows app. and thought its best to have the code in a seperate class and than call that class and pass the parameters using a constructor...
With this one function I hope to fill every combo box that i have in my application from a database table.
But not sure how to get started with it.
thanks
Wouter
|
|
|
|
|
First I'd say from a UI perspective 20+ comboboxes on a screen is probably not the best design. Think about breaking them up with tabs, or sub forms if it makes sense.
What you can do is iterate through the controls collection to find each combobox and set the properties accordingly. Or you could set DataBinding between the comboboxes and your datatable
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I have 14 forms and 20 combo's in total, So each form has max 2 comboboxes on it.
|
|
|
|
|
More reasonable then. DataBinding, IMO, would be the best approach in this case.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark,
Thanks, the answer was indeed easyer than the question, solved the problem !
In class "cls_role.cs":
public DataTable GetRols()
{
DataTable DT = new DataTable();
string Query = "GetRols";
DT = _dbHelper.ExecuteDataTable(Query);
return DT;
}
In Winform:
private void GetRols()
{
Cls_Role Role = new Cls_Role();
cmbRole.DataSource = Role.GetRols();
cmbRole.DisplayMember = "Role_Name";
cmbRole.ValueMember = "Role_ID";
}
I was thinking to complex
|
|
|
|
|
hi,
i am passing datetime.now.tostring() as parMETER IN MY SQL QUERY for retriving all the transaction of todays.but unable to retrive.
please help me.
my query like:
select billno,net amount from bill_details where date='" +DateTime.Now.Tostring() + "';
THANKS IN ADVANCE.
|
|
|
|
|
Please do not repost:
http://www.codeproject.com/Questions/74638/date-time-problem.aspx[^]
Post either here or in Q&A, not both.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Well, have you looked at what you are actually passing to the SQL? datetme.now.tostring() gives you the date AND time down to seconds, so unless your database date EXACTLY matches the system date and time nothing will be returned.
2 minutes in debug would have shown you that.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Don't pass it as a string; use a parameter.
|
|
|
|
|
Don't want Little Bobby Tables to make an appearance!
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
If he does I'll kick his skinny white ass.
|
|
|
|
|
I'm using a PropertyGrid in C# to display ConfigurationElements. I have an implementation of a ExpandableObjectConverter TypeConverter to display the sub-elements (with descriptions) in the property grid.
E.g.
Item 1
First sub-item
Item 1 ID
Second sub-item
x
Item 2
First sub-item
Item 2 ID
Second sub-item
x
...
I want to display the sub-elements in a specific order - not alphabetically (e.g. The ID before the other sub-elements).
Could anyone please tell me how to specify the ordering? (I've Googled it, looked at CodeProject articles, looked on MSDN - where I (momentarily) thought I'd found a solution using SortProperties - which turns out not to be overridable.)
Any ideas would be much appreciated.
P.S. I tried posting this in the Quick Answers - but I can't see my post (so please don't flame me for cross-posting if you can see it in both places).
"...there's what people want to hear, there's what people want to believe, there's everything else, THEN there's the truth!" - New York D.A., The International
|
|
|
|
|
Link to QA post[^]
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Thanks Dave, but if I view all questions under QA (All Questions | Latest) I don't see it. Am I being a dumbass?
"...there's what people want to hear, there's what people want to believe, there's everything else, THEN there's the truth!" - New York D.A., The International
|
|
|
|
|
Right now I see it second entry on page 2, check your filters on the right hand side!
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Thanks Dave. I can see it now.
"...there's what people want to hear, there's what people want to believe, there's everything else, THEN there's the truth!" - New York D.A., The International
|
|
|
|
|
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hola!
I want to use a regexp, and I've partly came up with it, but I cannot get the last bit to work. The regular expression I'm currently using looks like this:
(\d{3}\s\d{2})(\s[A-Z])|(\d{5})(\s[A-Z])
And I want to use it extracting a Swedish zip code which looks as follows:
111 11 City
or
11111 City
The reason I have the letter in the Regexp is that I don't want any other number sequence.
So the question is:
Is there a way to just get the numbers from my regexp, some kind of split or something like that?
All the best
Simon
|
|
|
|
|
You already have the number part wrapped in parenthesis - which implies a capture group - so you already have it.
I suggest you download expresso - a very helpful tool for debugging regex - google will be your friend in finding it.
Having tested your regex using expresso. I can give you 2 pointers:
1) Name your capture for numbers - it makes it alot easier to extract just the numbers:
(?<numbers>\d{3}\s\d{2})(\s[A-Z])|(?<numbers>\d{5})(\s[A-Z])
2) You're only testing for upper case chars - so your regexp only captures as far as the 'C' in city. Fix this like so:
(?<numbers>\d{3}\s\d{2})(\s[A-Z])|(?<numbers>\d{5})(\s[A-Za-z])
|
|
|
|
|
Cheers for your reply J4amieC!
However it doesn't work, Visual Studio doesn't seem to recognize the use of ?<numbers>
I know the part of the letter, but that was just there to distinguish the zip code from any other kind of row of numbers. But if I manage to extract the actual zip code by using numbers, then I could do the same with the letters (City) I presume, so that would be great...If I only could get Visual Studio to understand what I'm trying to achieve
Another question as well...My Visual Studio doesn't want to work with me on a different point too. It won't accept the use of ^ (like in ^\d{2,5}).
I'm using Visual Studio 2005 by the way,,,maybe that's why this is giving me a hazzle?
All the best
Simon
|
|
|
|
|
Why not a simple: \d\d\d\s?\d\d ?
|
|
|
|
|
Hello PIEBALDconsult
I tried using your example, but the thing I want to avoid happened. I just want to get 123 45 or 12345 from a zip code, but \d\d\d\s\d\d and \d\d\d\d\d returns any line of numbers 1234567890. I know it's easy to solve with ^ in the start, but since my Visual Studio wont let me use ^ I have to go the long way around,,,if there's a long way around, I'll probably end up on dark forest paths and eventually plumb into a deep dark hole.
Cheers for the suggestion anyways
|
|
|
|
|
skelmannen wrote: Visual Studio wont let me use ^
What?
|
|
|
|
|
Give this regex a try:
(^|\D+)(?<postalCode>\d{3}\s?\d{2})\s(?<city>[A-Za-z]+)
The first group checks for the beginning of the line or a non-digit character. This should prevent the regex from picking up lines with more than 5 digits. The "postalCode" group will have your Swedish zip code and "city" will have the city name.
|
|
|
|
|
Cheers Kythen, I'll try that one and hope it's working.
And PIEBALDconsult,,,just what I wrote,,,probably just a bug on my machine, still very annoying.
Take it easy
|
|
|
|