Load images from file c#
this is my code this is showing only one image data multiple times in list view instead of showing all images data.
public void loadImages()
{
string liness = File.ReadAllLines("Food.txt");
for (int a = 0; a < liness.Length; a++)
{
string check = liness[a].Split(',');
listView.Items.Clear();
foreach (var line in liness)
{
ListViewItem item = new ListViewItem(check[2]);
listView.Items.Add(item);
}
}
}
c#
|
show 4 more comments
this is my code this is showing only one image data multiple times in list view instead of showing all images data.
public void loadImages()
{
string liness = File.ReadAllLines("Food.txt");
for (int a = 0; a < liness.Length; a++)
{
string check = liness[a].Split(',');
listView.Items.Clear();
foreach (var line in liness)
{
ListViewItem item = new ListViewItem(check[2]);
listView.Items.Add(item);
}
}
}
c#
It is not clear what you arent asking. there doest appear to be any code dealing with any kind of images
– None of the Above
Nov 23 '18 at 1:50
@Disaffected1070452 basically check[2] is the index of images saved in file
– Hanzala Iqbal
Nov 23 '18 at 1:51
1
@HanzalaIqballistView.Items.Clear();
You are clearing listview in each loop iteration. PutlistView.Items.Clear();
line out of loop.
– Gaurang Dave
Nov 23 '18 at 1:54
@HanzalaIqbal Also there is no need offoreach (var line in liness)
inner loop. Remove this foreach loop.
– Gaurang Dave
Nov 23 '18 at 1:56
@GaurangDave thankyou i have done this so far but nothing happened the actual problem is in foreach loop.
– Hanzala Iqbal
Nov 23 '18 at 1:56
|
show 4 more comments
this is my code this is showing only one image data multiple times in list view instead of showing all images data.
public void loadImages()
{
string liness = File.ReadAllLines("Food.txt");
for (int a = 0; a < liness.Length; a++)
{
string check = liness[a].Split(',');
listView.Items.Clear();
foreach (var line in liness)
{
ListViewItem item = new ListViewItem(check[2]);
listView.Items.Add(item);
}
}
}
c#
this is my code this is showing only one image data multiple times in list view instead of showing all images data.
public void loadImages()
{
string liness = File.ReadAllLines("Food.txt");
for (int a = 0; a < liness.Length; a++)
{
string check = liness[a].Split(',');
listView.Items.Clear();
foreach (var line in liness)
{
ListViewItem item = new ListViewItem(check[2]);
listView.Items.Add(item);
}
}
}
c#
c#
edited Nov 23 '18 at 1:59
Gaurang Dave
2,9511928
2,9511928
asked Nov 23 '18 at 1:48
Hanzala IqbalHanzala Iqbal
86
86
It is not clear what you arent asking. there doest appear to be any code dealing with any kind of images
– None of the Above
Nov 23 '18 at 1:50
@Disaffected1070452 basically check[2] is the index of images saved in file
– Hanzala Iqbal
Nov 23 '18 at 1:51
1
@HanzalaIqballistView.Items.Clear();
You are clearing listview in each loop iteration. PutlistView.Items.Clear();
line out of loop.
– Gaurang Dave
Nov 23 '18 at 1:54
@HanzalaIqbal Also there is no need offoreach (var line in liness)
inner loop. Remove this foreach loop.
– Gaurang Dave
Nov 23 '18 at 1:56
@GaurangDave thankyou i have done this so far but nothing happened the actual problem is in foreach loop.
– Hanzala Iqbal
Nov 23 '18 at 1:56
|
show 4 more comments
It is not clear what you arent asking. there doest appear to be any code dealing with any kind of images
– None of the Above
Nov 23 '18 at 1:50
@Disaffected1070452 basically check[2] is the index of images saved in file
– Hanzala Iqbal
Nov 23 '18 at 1:51
1
@HanzalaIqballistView.Items.Clear();
You are clearing listview in each loop iteration. PutlistView.Items.Clear();
line out of loop.
– Gaurang Dave
Nov 23 '18 at 1:54
@HanzalaIqbal Also there is no need offoreach (var line in liness)
inner loop. Remove this foreach loop.
– Gaurang Dave
Nov 23 '18 at 1:56
@GaurangDave thankyou i have done this so far but nothing happened the actual problem is in foreach loop.
– Hanzala Iqbal
Nov 23 '18 at 1:56
It is not clear what you arent asking. there doest appear to be any code dealing with any kind of images
– None of the Above
Nov 23 '18 at 1:50
It is not clear what you arent asking. there doest appear to be any code dealing with any kind of images
– None of the Above
Nov 23 '18 at 1:50
@Disaffected1070452 basically check[2] is the index of images saved in file
– Hanzala Iqbal
Nov 23 '18 at 1:51
@Disaffected1070452 basically check[2] is the index of images saved in file
– Hanzala Iqbal
Nov 23 '18 at 1:51
1
1
@HanzalaIqbal
listView.Items.Clear();
You are clearing listview in each loop iteration. Put listView.Items.Clear();
line out of loop.– Gaurang Dave
Nov 23 '18 at 1:54
@HanzalaIqbal
listView.Items.Clear();
You are clearing listview in each loop iteration. Put listView.Items.Clear();
line out of loop.– Gaurang Dave
Nov 23 '18 at 1:54
@HanzalaIqbal Also there is no need of
foreach (var line in liness)
inner loop. Remove this foreach loop.– Gaurang Dave
Nov 23 '18 at 1:56
@HanzalaIqbal Also there is no need of
foreach (var line in liness)
inner loop. Remove this foreach loop.– Gaurang Dave
Nov 23 '18 at 1:56
@GaurangDave thankyou i have done this so far but nothing happened the actual problem is in foreach loop.
– Hanzala Iqbal
Nov 23 '18 at 1:56
@GaurangDave thankyou i have done this so far but nothing happened the actual problem is in foreach loop.
– Hanzala Iqbal
Nov 23 '18 at 1:56
|
show 4 more comments
1 Answer
1
active
oldest
votes
You are clearing listview in each loop iteration. Put listView.Items.Clear();
line out of loop. Also there is no need of foreach (var line in liness)
inner loop. Remove this foreach loop.
Try this
public void loadImages()
{
listView.Items.Clear();
string liness = File.ReadAllLines("Food.txt");
for (int a = 0; a < liness.Length; a++)
{
string check = liness[a].Split(',');
ListViewItem item = new ListViewItem(check[2]);
listView.Items.Add(item);
}
}
Is there anyway to delete entire row that when i select list view item and press delete it can delete that data from file
– Hanzala Iqbal
Nov 23 '18 at 2:09
You need to get the selected ListViewItem and then you can remove it fromlistView.Items.Remove(item);
. I suggest you to create new question if you get any other doubt.
– Gaurang Dave
Nov 23 '18 at 2:12
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439770%2fload-images-from-file-c-sharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are clearing listview in each loop iteration. Put listView.Items.Clear();
line out of loop. Also there is no need of foreach (var line in liness)
inner loop. Remove this foreach loop.
Try this
public void loadImages()
{
listView.Items.Clear();
string liness = File.ReadAllLines("Food.txt");
for (int a = 0; a < liness.Length; a++)
{
string check = liness[a].Split(',');
ListViewItem item = new ListViewItem(check[2]);
listView.Items.Add(item);
}
}
Is there anyway to delete entire row that when i select list view item and press delete it can delete that data from file
– Hanzala Iqbal
Nov 23 '18 at 2:09
You need to get the selected ListViewItem and then you can remove it fromlistView.Items.Remove(item);
. I suggest you to create new question if you get any other doubt.
– Gaurang Dave
Nov 23 '18 at 2:12
add a comment |
You are clearing listview in each loop iteration. Put listView.Items.Clear();
line out of loop. Also there is no need of foreach (var line in liness)
inner loop. Remove this foreach loop.
Try this
public void loadImages()
{
listView.Items.Clear();
string liness = File.ReadAllLines("Food.txt");
for (int a = 0; a < liness.Length; a++)
{
string check = liness[a].Split(',');
ListViewItem item = new ListViewItem(check[2]);
listView.Items.Add(item);
}
}
Is there anyway to delete entire row that when i select list view item and press delete it can delete that data from file
– Hanzala Iqbal
Nov 23 '18 at 2:09
You need to get the selected ListViewItem and then you can remove it fromlistView.Items.Remove(item);
. I suggest you to create new question if you get any other doubt.
– Gaurang Dave
Nov 23 '18 at 2:12
add a comment |
You are clearing listview in each loop iteration. Put listView.Items.Clear();
line out of loop. Also there is no need of foreach (var line in liness)
inner loop. Remove this foreach loop.
Try this
public void loadImages()
{
listView.Items.Clear();
string liness = File.ReadAllLines("Food.txt");
for (int a = 0; a < liness.Length; a++)
{
string check = liness[a].Split(',');
ListViewItem item = new ListViewItem(check[2]);
listView.Items.Add(item);
}
}
You are clearing listview in each loop iteration. Put listView.Items.Clear();
line out of loop. Also there is no need of foreach (var line in liness)
inner loop. Remove this foreach loop.
Try this
public void loadImages()
{
listView.Items.Clear();
string liness = File.ReadAllLines("Food.txt");
for (int a = 0; a < liness.Length; a++)
{
string check = liness[a].Split(',');
ListViewItem item = new ListViewItem(check[2]);
listView.Items.Add(item);
}
}
answered Nov 23 '18 at 2:08
Gaurang DaveGaurang Dave
2,9511928
2,9511928
Is there anyway to delete entire row that when i select list view item and press delete it can delete that data from file
– Hanzala Iqbal
Nov 23 '18 at 2:09
You need to get the selected ListViewItem and then you can remove it fromlistView.Items.Remove(item);
. I suggest you to create new question if you get any other doubt.
– Gaurang Dave
Nov 23 '18 at 2:12
add a comment |
Is there anyway to delete entire row that when i select list view item and press delete it can delete that data from file
– Hanzala Iqbal
Nov 23 '18 at 2:09
You need to get the selected ListViewItem and then you can remove it fromlistView.Items.Remove(item);
. I suggest you to create new question if you get any other doubt.
– Gaurang Dave
Nov 23 '18 at 2:12
Is there anyway to delete entire row that when i select list view item and press delete it can delete that data from file
– Hanzala Iqbal
Nov 23 '18 at 2:09
Is there anyway to delete entire row that when i select list view item and press delete it can delete that data from file
– Hanzala Iqbal
Nov 23 '18 at 2:09
You need to get the selected ListViewItem and then you can remove it from
listView.Items.Remove(item);
. I suggest you to create new question if you get any other doubt.– Gaurang Dave
Nov 23 '18 at 2:12
You need to get the selected ListViewItem and then you can remove it from
listView.Items.Remove(item);
. I suggest you to create new question if you get any other doubt.– Gaurang Dave
Nov 23 '18 at 2:12
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439770%2fload-images-from-file-c-sharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It is not clear what you arent asking. there doest appear to be any code dealing with any kind of images
– None of the Above
Nov 23 '18 at 1:50
@Disaffected1070452 basically check[2] is the index of images saved in file
– Hanzala Iqbal
Nov 23 '18 at 1:51
1
@HanzalaIqbal
listView.Items.Clear();
You are clearing listview in each loop iteration. PutlistView.Items.Clear();
line out of loop.– Gaurang Dave
Nov 23 '18 at 1:54
@HanzalaIqbal Also there is no need of
foreach (var line in liness)
inner loop. Remove this foreach loop.– Gaurang Dave
Nov 23 '18 at 1:56
@GaurangDave thankyou i have done this so far but nothing happened the actual problem is in foreach loop.
– Hanzala Iqbal
Nov 23 '18 at 1:56