|
how to read data from excel and display it in a list box using visual c# ????
|
|
|
|
|
This is a multi step process. The data in an Excel sheet may or may not be suitable to show in a listbox. Which bit have you tried ? What research have you done ? Where are you stuck ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I am not understanding how to go about it actually !!!
E.g..if i fill 4-5 columns of data in an excel sheet, i want to display them in my form (without any grid view)....[just d values]. I wanted to try with list box, but i guess its not working out for me !!!
can u help me plz...!!
|
|
|
|
|
I won't do all your work for you, no. A listview is surely better than a list box for this ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
You can use Ole db to read data from an excel file.
|
|
|
|
|
hw should i display (only the values) in the windows form ??
|
|
|
|
|
Any way you like, really.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
|
How the sequential structure code looked like? Can anyone give me some examples?
Thanks!
|
|
|
|
|
low_sinwei@yahoo.com wrote: How the sequential structure code looked like?
It looked fine. Now tell us what you are asking?
|
|
|
|
|
What are you talking about ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Looks like the following:
class Program{public static int Oct(int dec){return ((dec / 8) * 10) + (dec % 8);}static void Main(string[] args){... Anyway I don't encourage you to use it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
sequential structure code means no function inside right?
thanks for above comments.
|
|
|
|
|
Are you referring to System.Runtime.InteropServices.LayoutKind[^]
Just an example from something I'm currently looking at:
[StructLayout(LayoutKind.Sequential)]
private struct MIDIINCAPS
{
public ushort wMid;
public ushort wPid;
public uint vDriverVersion;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string szPname;
public uint dwSupport;
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6 ? Do you hate yourself ? (Christian Graus)
|
|
|
|
|
I got 5 label side by side and i have a textbox. The textbox value will need to input to the label 1 by 1 after the user click on the button to submit.
Example
protected void btnSave_Click(object sender, EventArgs e)
{
if (label1.text != "") Then
label2.Text = Textbox1.Text;
}
I know the logic for this method is wrong. Any advice?
|
|
|
|
|
Hi,
you could:
1. keep an int that counts the button clicks
2. give the five labels consecutive names (or tags), say label1..label5
3a. inside btnSave_Click() scan myForm.Controls for the Control with the right label# name
3b. alternative: hold an array, say Label[] labels=new Label[5]{label1,label2,...}; and use the counter as an index.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Do you have any sample coding on 3b for me to reference. Thanks.
|
|
|
|
|
It's very simple, why not try to do something yourself before asking someone to give you code ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
This is my coding
for (int i = 0; i < 6; i++)
{
List<string> vote = new List<string>();
vote.Add(TextBox1.Text);
if (i == 1)
{
lblvote.Text = (vote[0]);
break;
}
else if (i == 2)
{
lblvote1.Text = (vote[1]);
break;
}
else if (i == 3)
{
lblvote2.Text = (vote[2]);
}
else if (i == 4)
{
lblvote3.Text = (vote[3]);
}
else if (i == 5)
{
lblvote4.Text = (vote[4]);
}
}
Still got error...
|
|
|
|
|
ciqing wrote: vote.Add(TextBox1.Text);
whatever the content is, this statement only adds one thing.
BTW: "Still got error..." is not informative.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi all
I would like to popup an Outlook contact via a Click button. The "Popup action" works fine~
However, after the outlook contact comes up, the WinForm(Form1) seem stuck and hold ....
I can't move, minimize and maximize the WinForm ?????
Any body know what is the problem in here ??
Thanks
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace testing1
{
public partial class Form1 : Form
{
Outlook.Application oApp = new Outlook.Application();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void FindContactEmailByName(string firstName, string lastName)
{
Outlook.NameSpace outlookNameSpace = oApp.GetNamespace("MAPI");
Outlook.MAPIFolder contactsFolder = outlookNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);
Outlook.Items contactItems = contactsFolder.Items;
try
{
Outlook.ContactItem contact = (Outlook.ContactItem)contactItems.Find(String.Format("[FirstName]='{0}' and " + "[LastName]='{1}'", firstName, lastName));
if (contact != null)
{
contact.Display(true);
}
else
{
MessageBox.Show("The contact information was not found.");
}
}
catch (Exception ex)
{
throw ex;
}
}
private void button1_Click(object sender, EventArgs e)
{
FindContactEmailByName("Tom", "Lee");
}
}
}
|
|
|
|
|
contact.Display opens the contact window as a dialog window due to which parent window is stuck. You can call the this function in another thread if you want your parent window to work normally.
Regards
Shajeel
|
|
|
|
|
WOW!! Thanks for your answer! it works perfect with Threading !!! ~
|
|
|
|
|
We know that in winform,we can use "Tab" key to move focus,and now I want to move focus when I pressed "Enter" key in C# code project, I had added this code section in my form source,but it doesn't work sometimes.How can I do?
protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
{
if (keyData == Keys.Enter)
{
SendKeys.Send("{TAB}");
}
return base.ProcessCmdKey(ref msg, keyData);
}
|
|
|
|
|
I haven't tried, but if key is enter, don't call base.ProcessCmdKey .
|
|
|
|