Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am using devexpress XtraGrid. If I filtered this grid using a value related to specific column, I want to get that column(s) and value(s) in c#. Can any body help???
Regards
It looks like you need GridView.ActiveFilter.Criteria property.
It returns CriteriaOperator which is actually expression tree (just because DevExpress gridview filtering can be complex - not by single column).
In your simple case (filtering by one value in one column) you can just convert it to string by .ToString() and then parse string you'll get.
It will be something like [columnName] = columnValue string, and parsing it not a problem.
In complex cases (when it's a real expression tree) you can create your own class having implemented IClientCriteriaVisitor interface and traverse expression tree using CriteriaOperator.Accept method.
See example of such traverse implementation here.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
var approve = UnitOfWork.Query.Lexis.ApprovedLexis2(DialogService.User.UserID, List.Where(x=>x.Check).Max(x=>x.TxnDate), _batch);
what does line of code returns? can someone explains that? TYIA
List.Where(x=>x.Check).Max(x=>x.TxnDate)
Presumably here List is a list/collection/some IEnumerable<T> for a type T that has (at least) a bool member named Check, and some other member TxnDate (presumably a DateTime of the transaction date).
The Where applies a predicate filter, i.e. it creates a filtered sequence of the items where Check is true. The Max finds the greatest (in terms of x>y, implemented by IComparable[<T>]) of the .TxnDate of each item in the filtered sequence.
So: the expression returns the greatest (last, timewise) transaction date of all the "checked" items in List. If there are no "checked" items, it will throw an exception (you can't ask for the largest of no values; or rather, you can ask, but you won't get a sensible answer).
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I have a methode searching for a winform control by name. My first approche was to do it like that
private Control SearchControlByName(Control parent, string name){recursive search...}
Calling the methode looks like
Label temp = (Label)SearchControlByName(panel1, "label4");
Then a thought to myself it would be better do do it with an generic methode like this
private T SearchControlByName<T>(Control parent, string name) where T : Control {recursive search}
calling like
Label temp = SearchControlByName<Label>(panel1, "label4");
And now I'm not sure which is the better approach. What are the advantages / drawbacks of the generic method vs casting after calling the method?
In the generic methode I also have to cast the result like this
return (T)result
I don't think there are any disadvantages.
Since there are at least two advantages (see below), I would use the generic version.
It's prettier (no need for that cast).
You could use OfType<T> on Control.Controls inside the implementation (your recursive search) so you don't have to worry about returning a Label when the person wants a PictureBox. However keep in mind that you can only do that at the bottom level, otherwise you won't go through all the elements of course.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a website dropdown that is populated from a SQL query. The values in the dropdown are from a table column and are like:
ABC-0123
ABC-0124
ABC-0125
ABC-0126.01
ABC-0126.02
ABC-0127
DEF-0123
DEF-0124
DEF-0125.1.01
DEF-0125.1.02
DEF-0125.2
I have a button to generate a new number based on what is selected in the dropdown. For example, if ABC-0125 is selected, ABC-0128 would need to be created since it's the next number in sequence. If ABC-0126.01 is selected, ABC-0126.03 would need to be created.
I'm looking for ideas on how to perform this. I considered just using the dropdown or querying the database directly.
I've split the selected value as a start:
String strDocFamily = drpDocFamily.SelectedValue;
string[] strDocTiers = strDocFamily.Split('.');
This may be open ended, but I'm looking for some suggestions on how to proceed. Thank you.
A solution might be to split the storage of the data into two or more columns, one for the alphabetic part ('ABC') another for the 'family' (0128 - the first set of digits) and others for the other tiers. You could then directly look up the maximum value of the 'family' column based on alphabetic. For example:
SELECT MAX(family-number)
FROM table-name
WHERE alpha-part='ABC';
Here is a UniqueID generator that can be easily adapted to generate a similar sequence to the one you need.
https://stackoverflow.com/a/39312025/2495728
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
IN SQL SERVER can create XML Document like following format with every column name come with Datafield FieldName="Batch"
CID,BATCH,EXP_DATE are column names.
enter image description here
Try something like
SELECT 'BATCH' AS [DataField/#fieldName]
,BATCH AS [DataField]
,''
,'EXP_DATE' AS [DataField/#fieldName]
,EXP_Date AS [DataField]
FROM SomeWhere
FOR XML PATH('Memory');
The empty string in the middle is needed to start a new element
And be aware, that the dateformat will be ISO8601 and not 190615 (you should be happy about this!)
If you want to achieve XML document creation from C#, then it can be achieved through ADO.net with Help of DataSet. Method name is DataSet.WriteXml(string Filename).
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
In my current project I want to implement a checkbox that, if checked, replaces all strings in labels, tabs, etc. currently being shown on a form with a different string.
For example, If checked, all instances of the word "car" would change to the word "truck" all through out the program.
I'd rather not go through a do a .replace on every single string in the code. I was wondering if there was some way to "intercept" output strings and replace them on the fly; something like making a string-listener. Any help would be appreciated!
I am no GUI/WinForms program but this would be my personal approach. Add all of these UI elements to a List<T> in the forms constructor. Then in the "replace box checked event handler" you can just iterate over the list applying the same change to all the items. It's by no means a perfect solution but it does mean you only have to statically reference each of the items once. After they're in the list you can operate on all of them very easily.