Click here to Skip to main content
15,899,313 members
Home / Discussions / C#
   

C#

 
AnswerRe: To use first clicked button's .... and second clicked button's... in run time application? Pin
omegazafer14-Nov-07 11:25
omegazafer14-Nov-07 11:25 
QuestionKey Events Pin
kingletas14-Nov-07 10:04
kingletas14-Nov-07 10:04 
AnswerRe: Key Events Pin
led mike14-Nov-07 10:58
led mike14-Nov-07 10:58 
GeneralRe: Key Events Pin
kingletas14-Nov-07 11:08
kingletas14-Nov-07 11:08 
GeneralRe: Key Events Pin
led mike14-Nov-07 11:17
led mike14-Nov-07 11:17 
AnswerRe: Key Events Pin
Dave Kreskowiak14-Nov-07 11:02
mveDave Kreskowiak14-Nov-07 11:02 
GeneralRe: Key Events Pin
kingletas14-Nov-07 11:13
kingletas14-Nov-07 11:13 
QuestionReorder List View Pin
Ian Uy14-Nov-07 8:19
Ian Uy14-Nov-07 8:19 
Good day guys,

How do you reorder a List View? What I am doing is transfer all the LVItems to a DataTable then sort the Datatable, after that, clear the ListView then re-add the sorted data rows.

private static void SortDataTable(DataTable dt, string sort)<br />
{<br />
DataTable newDT = dt.Clone();<br />
int rowCount = dt.Rows.Count;<br />
<br />
DataRow[] foundRows = dt.Select(null, sort); // Sort with Column name<br />
for (int i = 0 ; i < rowCount; i++)<br />
{<br />
object[] arr = new object[dt.Columns.Count];<br />
for (int j = 0; j < dt.Columns.Count; j++)<br />
{<br />
arr[j]=foundRows[i][j];<br />
}<br />
DataRow data_row = newDT.NewRow();<br />
data_row.ItemArray=arr;<br />
newDT.Rows.Add(data_row);<br />
}<br />
<br />
//clear the incoming dt<br />
dt.Rows.Clear();<br />
<br />
for(int i = 0; i < newDT.Rows.Count; i++)<br />
{<br />
object[] arr = new object[dt.Columns.Count];<br />
for (int j = 0; j < dt.Columns.Count; j++)<br />
{<br />
arr[j]=newDT.Rows[i][j];<br />
}<br />
<br />
DataRow data_row = dt.NewRow();<br />
data_row.ItemArray = arr;<br />
dt.Rows.Add(data_row);<br />
}<br />
<br />
}


I'm using that function found on the net. The problem with that one is if I sort {2,11,12,13,14,15} the output is {11,12,13,14,15,2} or {3,1,11,12,15} the output is {1,11,12,15,3}. I don't know why.

Can you suggest an alternate way to reorder a listview? (Not just sorting it, I really mean reordering it.) Not using DataView or listview.sort.

Thank You.
AnswerRe: Reorder List View Pin
SABhatti14-Nov-07 8:38
SABhatti14-Nov-07 8:38 
GeneralRe: Reorder List View Pin
Ian Uy14-Nov-07 17:35
Ian Uy14-Nov-07 17:35 
GeneralRe: Reorder List View Pin
SABhatti14-Nov-07 19:09
SABhatti14-Nov-07 19:09 
AnswerRe: Reorder List View Pin
DaveyM6914-Nov-07 11:22
professionalDaveyM6914-Nov-07 11:22 
GeneralRe: Reorder List View Pin
Ian Uy14-Nov-07 17:38
Ian Uy14-Nov-07 17:38 
GeneralRe: Reorder List View [modified] Pin
DaveyM6914-Nov-07 23:27
professionalDaveyM6914-Nov-07 23:27 
QuestionHow 2 Run exe from Network ? Pin
hdv21214-Nov-07 7:40
hdv21214-Nov-07 7:40 
AnswerRe: How 2 Run exe from Network ? Pin
Ian Uy14-Nov-07 8:14
Ian Uy14-Nov-07 8:14 
AnswerRe: How 2 Run exe from Network ? Pin
Dave Kreskowiak14-Nov-07 8:29
mveDave Kreskowiak14-Nov-07 8:29 
GeneralRe: How 2 Run exe from Network ? Pin
hdv21214-Nov-07 9:11
hdv21214-Nov-07 9:11 
GeneralRe: How 2 Run exe from Network ? Pin
Pete O'Hanlon14-Nov-07 9:19
mvePete O'Hanlon14-Nov-07 9:19 
GeneralRe: How 2 Run exe from Network ? Pin
Dave Kreskowiak14-Nov-07 10:37
mveDave Kreskowiak14-Nov-07 10:37 
GeneralRe: How 2 Run exe from Network ? Pin
hdv21214-Nov-07 10:26
hdv21214-Nov-07 10:26 
GeneralRe: How 2 Run exe from Network ? Pin
Dave Kreskowiak14-Nov-07 10:31
mveDave Kreskowiak14-Nov-07 10:31 
GeneralRe: How 2 Run exe from Network ? Pin
led mike14-Nov-07 10:40
led mike14-Nov-07 10:40 
GeneralRe: How 2 Run exe from Network ? Pin
Dave Kreskowiak14-Nov-07 10:56
mveDave Kreskowiak14-Nov-07 10:56 
GeneralRe: How 2 Run exe from Network ? Pin
led mike14-Nov-07 11:07
led mike14-Nov-07 11:07 

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.