• 0

[C#] Text box in list View


Question

I'm trying to create list view which has five columns. Text in list view depends on a selection in a combo box that I have. Depending on that selection program reads xml and fulfill's first three columns. Fourth column should be a text box and fifth should be a result of a calculation.

Here I have a problem because I don't now how to create text box in fourth column. I have something like this:

foreach (XmlNode node in chosen)
			{
				XmlElement element = (XmlElement)node;

				string name = element.GetElementsByTagName("Name")[0].InnerText; //get name of product
				string price= element.GetElementsByTagName("Price")[0].InnerText; //get price of product
				string id = "";

				if (element.HasAttributes) //remove to zeros from beginning (because they are writen like 001 and I want just 1 at output)
				{
					id = element.Attributes["ID"].InnerText;
					int idd = int.Parse((string)id); //Parsing seems like the easiest way to do that
					id = idd.ToString();
				}

				list = lvindex.Items.Add(id + "."); //first i put a number and dot
				list.SubItems.Add(ime); //then the name of a product
				list.SubItems.Add(cijena + "EUR"); //Then price of it

				 //Here I miss fourt and five columns because I don't know to createtext box in listview therefore I cant calculate the fifth column which should be a third column times fourth column

			}

Can anybody help? I can't find anything online...

Thank in advance :)

Link to comment
https://www.neowin.net/forum/topic/609198-c-text-box-in-list-view/
Share on other sites

10 answers to this question

Recommended Posts

  • 0
  The2 said:

This last solution from Code Project seemed like my saviour so I tried it. I didn't put anything in tablemodel but i organized columnmodel like this:

first three columns are not editable text columns, fourth is editable number column and fifth is like first three-non editable tect column.

My goal is to print out some information from xlm in to first three column, enable user to enter fourth column, and then do some mathematical calculations which I convert into string and print it to fifth... The only problem is that I don't understand description on how to do anything with this table.

It says that you have to put something like "table.EditCell(0, 0);" if you want to start editing cell 0,0 but that's it. I don't understant how to even print some string in let's say first cell...

Can ANYBODY help - please... (I hope that you did understand in my complicated text above)

Sincerely,

neocooler

  • 0

I don't think the listview common control supports textboxes, although their *might* be some support for editing like the "rename" functionality in Explorer.

However, it sounds like you might just be better off using a DataGridView control instead of a listview. That's what it was designed for.

  • 0
  neocooler said:
@azcodemonkey - thank in in advance, you could be my saviour :)

@+Brandon Live - I agree so I think that XPTable could help me but I don't know how to use it...

If you know how to use the DataGridView, that would be a good solution. I was going to recommend that when I first saw this thread. It doesn't appear that the XPTable supports databinding, but I'm not 100% on that as I've only given it a cursory glance.

The DataGridView is not that hard to use. It's light years better than the old DataGrid that used to come with Visual Studio. I hated that thing!

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Oh, what if the AI skips over some "editor's" personally cherished lie in an article? The Horror!
    • eagerly awaiting a version that runs on android tablets
    • I grew up with the Beach Boys. Even saw them in concert in the 70's. Brian suffered from mental issues all his life. May you find peace wherever you are.
    • Wikipedia suffers backlash from human editors over AI summaries, prompting feature pause by David Uzondu Wikipedia editors have pushed back against plans from the Wikimedia Foundation to test AI-generated article summaries, powered by Aya, the open-weight AI model from Cohere. The non-profit has now paused the project. The decision came after a swift and overwhelmingly negative reaction from its community. As first reported by 404Media, the plan involved a two-week, opt-in trial on the mobile version of Wikipedia. But the volunteer editors who build the encyclopedia met the idea with immediate and fierce opposition. The project's discussion page became a torrent of rejection. It included simple comments like "Yuck" and blunt declarations like "strongest possible oppose" and "Absolutely not." One editor argued that a test would cause "immediate and irreversible harm to our readers and to our reputation as a decently trustworthy and serious source." They noted that Wikipedia has built its name on being sober and reliable, not flashy. Another feared it would destroy the site's collaborative model. They argued that while the "collective mass" of human editors "evens out into a beautiful corpus," the AI would install "one singular editor with known reliability and NPOV [neutral point-of-view] issues" at the very top of an article. That same editor also noted the following: For context, this is what AI-generated summaries on the platform was supposed to look like: Image: 404Media It is not hard to see why they are so protective. The editors' fears are grounded in recent and very public failures of AI features from tech giants. For example, Google's AI overviews recently hit 1.5 billion monthly users. The feature became a laughingstock for telling people to put glue on their pizza and that a dog had played in the NBA. This is the kind of humiliating error Wikipedia's community is desperate to avoid, as it would undermine two-plus decades of careful work. We also saw the potential for reputational damage back in January. That was when Apple's AI feature falsely generated a notification claiming that Luigi Mangione had died by suicide. The man was actually alive and in custody. On the site's technical discussion page earlier today, Marshall Miller (MMiller), a Senior Director at the Wikimedia Foundation, posted an update acknowledging the feedback. He admitted, "It's clear we could have done a better job introducing this idea," and confirmed the experiment was paused. The Foundation says the goal was to explore accessibility for different readers. While this specific test is off the table, the organization still wants to use new technologies. Miller ended with a promise: "We do not have any plans for bringing a summary feature to the wikis without editor involvement." A WMF spokesperson also told 404Media that though the feature has been paused, the foundation is still interested in AI-generated summaries. The spokesperson insisted the goal was to eventually build moderation systems where "humans remain central" and called this kind of backlash feedback part of what makes Wikipedia a "truly collaborative platform."
    • I see, yeah that makes sense. I have been in situations where I barely did not crush badly on the road due to other driver starting to change lanes into another car - freaked out last second and avoided it by crashing into the side of the bridge instead. i got away because I quickly changed lanes 2 times in a couple of second and unlike that idiot I did not lose control big part of this was my car was good 😊 (audi a7) vs the old van the crashed driver was driving would AI be able to react and quickly change lanes twice both time barely avoiding collision … I don’t know my car systems pumped the breaks and tried to warn me with a beep and vibration but if I slammed the breaks the car behind me would hit me then again I have BMW driver training and a good car - so I have no idea how robot taxi would react i am not sure extreme fast lane changes would be programmed in - it is dangerous as hell unless you are FULLY aware, and have done it before but it is a general risk to do it especially in the conditions with bad weather and when you are not driving a sports car with 4 wheel drive and very good control
  • Recent Achievements

    • Collaborator
      CHUNWEI earned a badge
      Collaborator
    • Apprentice
      Cole Multipass went up a rank
      Apprentice
    • Posting Machine
      David Uzondu earned a badge
      Posting Machine
    • One Month Later
      Stokenking earned a badge
      One Month Later
    • One Month Later
      Kevin Jones earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      537
    2. 2
      ATLien_0
      266
    3. 3
      +Edouard
      193
    4. 4
      +FloatingFatMan
      181
    5. 5
      snowy owl
      135
  • Tell a friend

    Love Neowin? Tell a friend!