Click here to Skip to main content
15,904,024 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do I add an object to a list within a class? Pin
Sascha Lefèvre18-Apr-15 10:27
professionalSascha Lefèvre18-Apr-15 10:27 
GeneralRe: How do I add an object to a list within a class? Pin
BillWoodruff18-Apr-15 17:28
professionalBillWoodruff18-Apr-15 17:28 
GeneralRe: How do I add an object to a list within a class? Pin
Sascha Lefèvre19-Apr-15 0:44
professionalSascha Lefèvre19-Apr-15 0:44 
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 
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 
Updated code... Seems to be working... Any suggestion for a better approach?
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("Hide", typeof(bool));

dataTable.Rows.Add("Ronald", 0x0, "Value = 0", false);
dataTable.Rows.Add("Ronald", 0x1, "Value = 1", true);
dataTable.Rows.Add("Ronald", 0x2, "Value = 2", false);
dataTable.Rows.Add("Ronald", 0x4, "Value = 4", true);
dataTable.Rows.Add("Ronald", 0x8, "Value = 8", false);
dataTable.Rows.Add("Ronald", 0x16, "Value = 16", false);
dataTable.Rows.Add("Ronald", 0x32, "Value = 32", false);
dataTable.Rows.Add("Ronald", 0x64, "Value = 64", true);
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";
}

DataRow[] drArrRow = dataTable.Select("Hide = False");
DataTable filteredDataTable = new DataTable();

filteredDataTable.Columns.Add("Variable", typeof(string));
filteredDataTable.Columns.Add("Value", typeof(string));

foreach (DataRow dr in drArrRow)
{
    filteredDataTable.Rows.Add(dr["Variable"], dr["Value"]);
}

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

MessageBox.Show(res);

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.