Click here to Skip to main content
15,902,891 members
Home / Discussions / C#
   

C#

 
QuestionWindows remote desktop but all in HTML Pin
Dr Gadgit18-Apr-15 6:23
Dr Gadgit18-Apr-15 6:23 
QuestionCreate Chart in Excel with C# Pin
Member 836750218-Apr-15 2:17
Member 836750218-Apr-15 2:17 
AnswerRe: Create Chart in Excel with C# Pin
Brisingr Aerowing18-Apr-15 12:24
professionalBrisingr Aerowing18-Apr-15 12:24 
Questionfloat to and from frequency Pin
DaveyM6917-Apr-15 10:06
professionalDaveyM6917-Apr-15 10:06 
AnswerRe: float to and from frequency Pin
Sascha Lefèvre17-Apr-15 11:02
professionalSascha Lefèvre17-Apr-15 11:02 
GeneralRe: float to and from frequency Pin
DaveyM6917-Apr-15 13:16
professionalDaveyM6917-Apr-15 13:16 
GeneralRe: float to and from frequency Pin
Sascha Lefèvre17-Apr-15 13:48
professionalSascha Lefèvre17-Apr-15 13:48 
GeneralRe: float to and from frequency Pin
DaveyM6917-Apr-15 14:15
professionalDaveyM6917-Apr-15 14:15 
GeneralRe: float to and from frequency Pin
Sascha Lefèvre17-Apr-15 14:29
professionalSascha Lefèvre17-Apr-15 14:29 
GeneralRe: float to and from frequency Pin
DaveyM6918-Apr-15 0:01
professionalDaveyM6918-Apr-15 0:01 
GeneralRe: float to and from frequency Pin
Sascha Lefèvre18-Apr-15 3:53
professionalSascha Lefèvre18-Apr-15 3:53 
AnswerRe: float to and from frequency Pin
Mycroft Holmes17-Apr-15 22:51
professionalMycroft Holmes17-Apr-15 22:51 
GeneralRe: float to and from frequency Pin
DaveyM6918-Apr-15 0:03
professionalDaveyM6918-Apr-15 0:03 
QuestionRe: float to and from frequency Pin
Kenneth Haugland17-Apr-15 23:23
mvaKenneth Haugland17-Apr-15 23:23 
AnswerRe: float to and from frequency Pin
DaveyM6918-Apr-15 0:00
professionalDaveyM6918-Apr-15 0:00 
GeneralRe: float to and from frequency Pin
Kenneth Haugland18-Apr-15 0:40
mvaKenneth Haugland18-Apr-15 0:40 
GeneralRe: float to and from frequency Pin
Kenneth Haugland18-Apr-15 0:43
mvaKenneth Haugland18-Apr-15 0:43 
GeneralRe: float to and from frequency Pin
DaveyM6918-Apr-15 3:02
professionalDaveyM6918-Apr-15 3:02 
QuestionDataTable output to string with filter Pin
Blubbo17-Apr-15 8:58
Blubbo17-Apr-15 8:58 
What I am trying to accomplish is that I am making the datatable to interpret large data. I only wanted to print out the header, then the data. Also only to show "Variable" and "Value" columns.
I'm not sure how to weed out the "Hex Value" column. Also to list the rows that are (Hidden = false).
I'm not sure how to accomplish this.

On the bottom code (with variable "res" does show all of the rows with all of the columns, but no header... Sigh | :sigh:
C#
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Variable", typeof(string));
dataTable.Columns.Add("Hex Value", typeof(Int64));
dataTable.Columns.Add("Value", typeof(string));
dataTable.Columns.Add("Hidden", typeof(bool));

dataTable.Rows.Add("Ronald", 0x0, "Value = 0", false);
dataTable.Rows.Add("Ronald", 0x1, "Value = 1", false);
dataTable.Rows.Add("Ronald", 0x2, "Value = 2", true);
dataTable.Rows.Add("Ronald", 0x4, "Value = 4", true);
dataTable.Rows.Add("Ronald", 0x8, "Value = 8", false);
dataTable.Rows.Add("Ronald", 0x16, "Value = 16", true);
dataTable.Rows.Add("Ronald", 0x32, "Value = 32", false);
dataTable.Rows.Add("Ronald", 0x64, "Value = 64", false);
dataTable.Rows.Add("Ronald", 0x128, "Value = 128", false);
dataTable.Rows.Add("Ronald", 0xFF, "Value = 255", true);

try
{
   DataRow selectedRow = dataTable.Select("").FirstOrDefault(x => (Int64)x["Hex Value"] == Convert.ToInt64(tb_Input.Text, 16));
   lbl_Result.Text = selectedRow["Value"].ToString();
}
catch
{
   lbl_Result.Text = "Unknown";
}

string res = String.Join(Environment.NewLine, dataTable.Rows.OfType<DataRow>().Select(x => String.Join(" ; ", x.ItemArray)));

MessageBox.Show(res);

GeneralRe: DataTable output to string with filter Pin
PIEBALDconsult17-Apr-15 9:06
mvePIEBALDconsult17-Apr-15 9:06 
GeneralRe: DataTable output to string with filter Pin
Blubbo17-Apr-15 9:35
Blubbo17-Apr-15 9:35 
GeneralRe: DataTable output to string with filter Pin
Blubbo17-Apr-15 9:49
Blubbo17-Apr-15 9:49 
GeneralRe: DataTable output to string with filter Pin
Sascha Lefèvre17-Apr-15 9:53
professionalSascha Lefèvre17-Apr-15 9:53 
GeneralRe: DataTable output to string with filter Pin
Blubbo17-Apr-15 9:56
Blubbo17-Apr-15 9:56 
GeneralRe: DataTable output to string with filter Pin
Sascha Lefèvre17-Apr-15 11:52
professionalSascha Lefèvre17-Apr-15 11:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.