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
This is my table
ID SubID
============
1 1001
1 4432
1 2345
1 6322
2 2014
2 5432
The final result in treeview list should be
1
--1001
--4432
--2345
--6322
2
--2014
--5432
How to do that? Those data are stored in DataTable.
You can set the "key" of a node and check if it exists. If it doesn't, add it, then you can reference that key to add the child nodes:
foreach (DataRow dr in table.Rows) {
if (!treeView1.Nodes.ContainsKey(dr["ID"].ToString())) {
treeView1.Nodes.Add(dr["ID"].ToString(), dr["ID"].ToString());
}
treeView1.Nodes[dr["ID"].ToString()].Nodes.Add(dr["SubID"].ToString());
}
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 4 years ago.
Improve this question
txtpayAmount.Text = gblFunction.ConvertTwoDecimal(
txtpayAmount.Text,
btn.Tag.ToString(),
txtpayAmount.SelectedText.Length);
txtpayAmount.Focus();
txtpayAmount.SelectionStart = txtpayAmount.Text.Length;
This is my code , am trying to add the value of button to textbox but its adding as last element of textbox.I want to add as first element
If I understand correctly (your question is confusing), you want prepend the text in a textbox.
If you want to do so you can do a txtBox.Value = 'ValueToPrepend' + txtBox.Value;
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 4 years ago.
Improve this question
Hi sp returns 2 tables set record how to marge result set.
Result set table 1:
Result set table 2:
dtAll = new DataTable();
...
dtAll.Merge(dtOne);
dtAll.Merge(dtTwo);
dtAll.Merge(dtThree);
...
and so on.
This technique is useful in a loop where you want to iteratively merge data tables:
DataTable dtAllCountries = new DataTable();
foreach(String strCountry in listCountries)
{
DataTable dtCountry = getData(strCountry); //Some function that returns a data table
dtAllCountries.Merge(dtCountry);
}
If iam understanding you correctly
You wish to merge 2 identical data tables
dataTable.Merge(dataTable1);
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
It my sound trivial but I can't get around. How do I know if item in checklistbox is selected ? I've got checklistbox with 3 items and I'd like to do some 'if then' statements. Basically ,if chkbox1.Checked Items 'ABC' is selected / checked then..
Thanks
CheckedListBox contains CheckedItems property. You can get all checked items from this collection. Read here: MSDN
got this solved by using
GetItemCheckState(0) == CheckState.Checked
and using 0 first item ,1 second item etc.
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 8 years ago.
Improve this question
I have two IEnumerable data collections that I would like to compare and get first collection values selected.
Here is what I am trying to do.
ClassA
Column|IsMatched
----
1
2
2
2
3
4
5
ClassB
Column
1
2
7
3
5
2
After comparison, I would like to get following.
ClassA
Column|IsMatched
1 true
2 true
2 true
2 false
3 true
6 false
5 true
4 false
Second collection may be in any order.
Any help to sort this issue would be really appreciated.
Thanks
You could do something like the following:
var workingBag = new List<int>(secondCollection);
var results = firstCollection.Select(i => new ClassA(i, workingBag.Remove(i));
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
I have a list I want to remove the column RiskRegisterEntryId and RiskRegisterTypeId how can I to do that..?
SeriesNumber RiskRegisterEntryId RiskRegisterTypeId RiskRegisterType
RCMSRA19111300001 1 1 Site Risk Audit
RCMSRA19111300002 2 1 Site Risk Audit
RCMSRA19111300003 3 1 Site Risk Audit
RCMSRA19111300004 4 1 Site Risk Audit
RCMSRA20111300016 16 1 Site Risk Audit
You can just create a new list of an anonymous type without those columns:
var newList = myList.Select(l => new {
l.SeriesNumber , l.RiskRegisterType
}).ToList();
List.Select(x => new { x.SeriesNumber, x.RiskRegisterType});
This will create a list with an anonymous type containing only those two fields.