Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'am struggling with the following, I have a datatable with some columns what i want is to have the items in this column displayed in a combobox. But it must not display double items.
How can i do this?
Try this:
private void FillComboFromColumnIndex(int columnIndex){
yourDataTable.AsEnumerable()
.Select(r=>r[columnIndex])
.Where(x=>x != null)
.Distinct().ToList()
.ForEach(x=>yourComboBox.Items.Add(x));
}
//To add all the items in column at index 1, do this
FillComboFromColumnIndex(1);
Try this, I'm not sure is it right answer on your question because I'm not sure if I have understood you as well:
Hidden Id With ComboBox Items?
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I am doing a c# project of making "Age Calculator" and I have the following problem:
When i select February from month's combo box then in date's combo box it shows 1-31 numbers. But i want to show 1-29.How can i solve this without database?
private void ListBox1_SelectedValueChanged(object sender, EventArgs e)
{
if (ListBox1.SelectedValue == "February")
{
for (int i=1; i<=29; i++)
Listbox2.Items.Add(i.ToString());
}
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a datatable with a column that is named Month.
Month column has int type by default(I have stored a month to datatable from a sql server table).
I want to set datatable.Rows[0]["Month"] to a string like: "hello".
how can I do this?
Change your Month column to string instead of int .
Here is example ,
DataTable _dt= new DataTable();
_dt.Columns.Add("Month", typeof(string));
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I´m using C# to create and format a Excel spreadsheet, so I need to format (merge cells, change the font, etc) until the final of the first page. How can I know the final line of the page in the Excel spreadsheet?
The following code will give you the last row number before every horizontal page break in an Excel worksheet:
foreach (Excel.HPageBreak pageBreak in worksheet.HPageBreaks)
{
int row = pageBreak.Location.Row - 1;
// ...
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a typed dataset with a column called price, which is of string datatype. And I'm showing this via ultrgrid/datagrid
How can I show the price in number format.
For example: price ==123456
in the grid it should be like 12,354,56
Try this
var a = price.ToString("##,###,##");
Reference
Custom Numeric Format Strings!
Look at some of the related links to the right of the screen. Some of them even ask the same question as you !
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need remove all items step by step from list and add removed items to another list, but I need max effective and hithperformance operation. What is whe best practics?
You could use this code and hope that framework'll do the best for you:
public static void MoveItems<T>(List<T> list1, List<T> list2)
{
list2.AddRange(list1);
list1.Clear();
}
list2 = list1.ToList();
list1.Clear();