|
How to do this is quite simple, but not obvious since we do not normally think of dimensioning a variable as a control type.
The simplest way (to me) is to dimension an array of labels, Label(1), Label(2) etc. as Label. Then set each member of the array equal to each of the labels you want to control a property for.
Then you can write a loop setting a property of each label in the array as an iterated function, such as:
Dim Label(1) as Label
Dim Label(2) as Label ...
Label(1) = LabelA
Label(2) = LabelB ...
For x = 1 to 5
Label(x).text = "Text " & x
Next
(Sorry, I am an old VB.NET programmer, but the concept is the same in all )
I think this is what you want, works great for me, and works for the other common controls, too.
|
|
|
|
|
|
There has to be tools in Visual Studio 2008 for outlook that we can add to my software to allow us to connect via outlook connection to exchange.... so , which one can do that?
|
|
|
|
|
drag and drop a lable whit c#.net
|
|
|
|
|
At it's most basic:
Capture the mouse down event. Use the mouse offset while moving the label round. Capture the mouse up event.
|
|
|
|
|
Yours is not a question at all.
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Smithers-Jones wrote: Yours is not a question at all.
Sure it is. It says question in the title.
|
|
|
|
|
If a question at all, it's a questionable question.
|
|
|
|
|
Start here[^] if you're using WPF, or here[^] if you're building WinForms. There's code-examples for multiple .NET languages, and you can select the .NET version that you need by clicking the link at the top of the page.
--edit;
As an additional remark, not as criticism, but to help you get a better answer sooner; it would have helped if you had put the phrase "Drag and Drop" in the "subject"-line of your post. A few hints on your current environment (VB.NET, C++, .NET 1.1, .NET 4) are usually helpful too.
I are Troll
|
|
|
|
|
You didn't post a question at all.
But, if you want to know how to do it, read my article on the subject, here[^].
|
|
|
|
|
(i posted this incorrectly to quick answers. I am reposting this here)
I am working on my first C# SQL project. A simple checkbook register.
I referred to the CodeProject article:
Using the DataGrid Control Using the DataGrid Control[^]
I added a datagridview control to my form and set the data source as my checkbook register in SQL Express.
I am able to see all the checkbook entries when I run the form.
My first attempt at updating the sql table is generating a compile error.
The error is:
cannot convert from 'System.Data.DataSet' to 'FirstCheckBookInSQL.CheckBookManagementDataSet.CheckbookUSBPersonalDataTable'
I've been researching this for 3 days, but I'm just not making sense of what I am seeing.
Can someone help please!
Thank you.
Mark
My code in Form1.cs:
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 System.Data.SqlClient;
namespace FirstCheckBookInSQL
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.checkbookUSBPersonalTableAdapter.Fill(this.checkBookManagementDataSet.CheckbookUSBPersonal);
}
private void TBDbutton_Click(object sender, EventArgs e)
{
DataSet myChangedDataSet = this.checkBookManagementDataSet.GetChanges();
if (myChangedDataSet != null)
{
int modifiedRows = this.checkbookUSBPersonalTableAdapter.Update(myChangedDataSet);
this.checkBookManagementDataSet.AcceptChanges();
myChangedDataSet.AcceptChanges();
}
MessageBox.Show("no data changed");
}
}
}
</pre>
|
|
|
|
|
You didn't "incorrectly" post this to Q&A, I think the answer from CG was suggesting that you might want to use the Message facility at the end of the article you referenced, rather than raise a new general question thread. However, since the article is about the use of a standard .NET component a general question is perfectly valid. Don't worry about CG - Quantas probably sucks again! And don't worry about that, CG is well known for sucky things...
The first thing I would say is: since you are doing a winforms project, I would avoid using DataGrid and use DataGridView instead - it's a little more advanced, and a bit easier to play with.
However, the error you are gettign is a bit specific:
cannot convert from 'System.Data.DataSet' to 'FirstCheckBookInSQL.CheckBookManagementDataSet . CheckbookUSBPersonalDataTable'
with your code
int modifiedRows = this.checkbookUSBPersonalTableAdapter.Update(myChangedDataSet);
What it means is "Update expects a DataTable, you are providing a CheckbookUSBPersonalDataTable. Please give me a DataTable instead".
When you defined CheckbookUSBPersonalDataTable, did you derive it from DataTable? Or does it contain a DataTable and you forgot to refer to it? Because if not, then you cannot supply it to the Update method.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I actually meant to say I added a DataGridView control to the form. My bad.
The only code I personally wrote was what I copied into my post. Any other code for creating DataTables, DataSet, DataAdapters, etc. was generated by VS2008.
What's weird is that intellisence is looking for a DataSet parameter being passed to the Update function.
I would think a DataTable would be more restrictive since that's only a single table, whereas the DataSet would include a collection of my tables correct?
I putzed around trying a datatable argument in the Update function, but since I didn't know what I was doing, I didn't have much success.
Mark
|
|
|
|
|
Lets say you have code block like this
public void BindGridData<T>(IEnumerable<T> result)
{
Session["result"] = result;
gridView.DataSource = result;
gridView.DataBind();
}
How do you call this function in another event passing the Session["result"] as the argument?
How do you cast Session["result"] back to the generic object?
thanks
|
|
|
|
|
You have already asked this in your previous post, please don't repeat it.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
What do you mean by that? who made you moderator of the site??
|
|
|
|
|
There are a couple of very valid reasons for Marks reply to you. The most important reason is that it becomes very difficult to track answers if multiple threads are spawned about the same topic. Bear in mind that the question may be viewed, in the future, by others who want to know the answer to the problem; the search engines will point them to one thread. Churn and growth of other threads could mean that they end up not seeing the whole picture because the vital part of the answer is now in another thread.
Now, take a deep breath and relax.
|
|
|
|
|
If you don't have a meaningful contribution to make, then you should be quiet.
|
|
|
|
|
I think you should take a deep breath before responding.
If you want to get pissy about being told of the conventions and expectations of this community then perhaps you should step away for a bit.
You have been given assistance on your problem, don't spoil it with such an attitude.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
How bloody obvious
Now perhaps you'd like to actually read the OP's question.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for the response, but the data type is a generic data type as shown form the code I originally posted.
The session object has a generic object of IEnumerable<T> type, so how would I cast back to that generic type?
|
|
|
|
|
Hi,
Is there any way to change SQL server 2008 product key (Using C# or command prompt)?
Thanks
|
|
|
|
|
And setup a software piracy business?
|
|
|
|
|
No. I just want to change product key.
|
|
|
|