|
|
I have used a great resource for something similar. It doesn't support everything (such as css) but if you are looking to create html aware forms in Windows.Forms, the HTMLRenderer NuGet packages are perfect (you may be stuck with .NET Framework as the support for .NET Core is questionable). It is also specific to HTML 4.1. I believe it does support bulleted lists as long as you don't mind that you can't use CSS. (It says it can but CSS is only partially implemented so many of its features do not work).
EDIT: Here is an image of an example control I made with these packages which make use of bulleted lists:
ibb.co/6b4JSJQ
[edit]Link made visible (your choice if you follow it, but it seems to be some link shortening image site) : OriginalGriff[/edit]
|
|
|
|
|
Be careful when posting links (especially links that look like link shorteners) - your original held what is called a "hidden link": no text so the link can't be seen, much less clicked on. Normally, that would have been an open-and-shut moderation, and your account would disappear as a spammer.
If you must post image links, then expect two things: lots of moderation and false positive reports against you - particularly when the link looks like yours does and you can't tell what is at the other end. In deference to your length of membership, I spun up a VM to check it, but many will not want to do that and will report your account as spam instead. That will mean you get shown the door ... so it's in your interest not to look suspicious!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Ok... thanks for the heads up. I copied the embedded link provided to me by imgbb, not aware of this issue. I wanted to just embed an image but there doesn't seem to be a direct way to do that. I just wanted to demonstrate the capabilities of the solution I was proposing. The software I showed in the picture isn't even available... (at least not yet), so I am not sure how that could qualify as spam (other than in appearance).
|
|
|
|
|
You can't post images directly, except in a very limited number of (highly policed) forums - this is a SFW site and nobody wants your corporate net nazis to get offended by some of the images that would get posted ... we have visitors that would post some truely offensive images if given the chance ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I've just seen you post, so sorry for the late reply.
The answer is yes, you can. Blazor WASM (Web Assembly) enables you to do just that. I have written an article recently that demonstrates this with WPF, however WinForms can do the same. Here is the article: Blazing.Mvvm - Blazor WASM & Blazor Hybrid using the Community Toolkit[^] - ignore the fact that the article focuses on MVVM. The key thing for you, in the article, is not only proof of concept, but also how you can interact with the Blazor part from within your WinForms app and vice versa. IT is made possible by the BlazorWebView control.
Microsoft have an article that shows you how to host Blazor within WinForms: Build a Windows Forms Blazor app | Microsoft Learn[^].
Be aware though, to do this, you need to work with .Net 7.0+, not .Net Framework. However, if you need to move from .Net Framework to .Net, then your app will receive an immediate performance boost due to improvements made to .Net - no legacy support.
Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
|
|
|
|
|
Quote: i need to help create master detail form in winform means when i click on orderno then it will be show order detail like table 2 data on gridview like item name,rice and quantity
|
|
|
|
|
OK, what have you tried?
Where are you stuck?
What help do you need?
This isn't a difficult problem if you know what you are doing, but there are a lot of different ways it can be done - so we need to know what you have at the moment, and what is stopping you from progressing. Otherwise, what we suggest could take you off in a direction that just doesn't work well with the rest of your code - the way you do things is likely to be very different from the way I would!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Actually i created 2 tables ordm in this i created primary key is orderno ,orderdate,credit term and days and ordc i created foreign key is orderno,item name,price and value in sql server then i created 2 forms for both table in winform then i connected both of them with sql server,but i need to show ordc all column data in gridview with the help of orderno like when i enter order in ordm so it can save data in ordc grid with order detail.but order dont have to show in grid.
|
|
|
|
|
OK, so you have two tables in an SQL DB, and you have imported the data into your app.
How? DataSet, DataTable, Data Reader? Is it loaded into classes your created to hold them, or still in tabular form?
You have two DataGridViews, you want one to display all the items from one DB table, and when you select one, its details from the second DB table should be displayed in the second DGV.
How are the two tables "linked"? What are you using as the DataSource for the DGV's?
What have you done so far to make the tables displays work?
See what I mean about there being a lot of different ways to do this?
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?
That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
first i created 2 tables in sql and then connected them with orderno then i connect sql with my winform with sqlconnection and taake all column with sqlcommand then i got all data on grid view with dataadapter then load with datatable and then use data gridview datasourse but this process show both table on gridview but i just want to show child table on grid with the help of orderno.
|
|
|
|
|
OK, so we have some information now: you used a DataAdapter to fill a DataTable with both tables results, then set that as the datasource for both DGVs.
That's the first problem: you need to separate the two SQL Tables into different DataTables and use them to fill the two DataGridViews with different data.
When you have the separate tables, what do you know about BindingSources? Have you used them?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
yes i used datasource in connectionstring which pass as a parameter in sqlconnection constructer then bind data in this connectionstring.
|
|
|
|
|
I'm impressed about the patience of OriginalGriff ...
For me you explain more or less nothing - it could be very useful if you provide the significant code. Perhaps we could help you much better - or don't ypu have any code ?
|
|
|
|
|
It is a little slow going, isn't it?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
No, the connection and it's string use a different idea of "dataSource" - a DGV (and all other data aware controls) have a DataSource Property: DataGridView.DataSource Property (System.Windows.Forms) | Microsoft Learn[^]
Your previous post says you are using that to "get the data into the DGV".
I assume that you are doing something like:
MyDataAdapter.Fill(MyDataTable);
MyMasterDGV.DataSource = myDataTable;
MyDetailDGV.DataSource = myDataTable; Is that correct?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
yes exatly i did this
private string connectionString = "Data Source=DESKTOP-5GRDQ7C\\SQLEXPRESS;Initial Catalog=Orders;Integrated Security=True";
private SqlDataAdapter masterDataAdapter;
private SqlDataAdapter detailDataAdapter;
private DataSet dataSet;
public Form1()
{
InitializeComponent();
}
private void LoadMasterData()
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
string query = "SELECT * FROM ordm";
SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);
masterDataGridView.DataSource = dataTable;
}
}
private void LoadData()
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
string ordmQuery = "SELECT * FROM ORDM";
masterDataAdapter = new SqlDataAdapter(ordmQuery, connection);
masterDataAdapter.Fill(dataSet, "ORDM");
string ordcQuery = "SELECT * FROM ORDC";
detailDataAdapter = new SqlDataAdapter(ordcQuery, connection);
detailDataAdapter.Fill(dataSet, "ORDC");
}
DataColumn parentColumn = dataSet.Tables["ORDM"].Columns["ORD_NO"];
DataColumn childColumn = dataSet.Tables["ORDC"].Columns["ORD_NO"];
DataRelation relation = new DataRelation("ORDM_ORDC_Relation", parentColumn, childColumn);
dataSet.Relations.Add(relation);
}
private void Form1_Load(object sender, EventArgs e)
{
LoadMasterData();
dataSet = new DataSet();
LoadData();
masterDataGridView.DataSource = dataSet.Tables["ORDM"];
masterDataGridView.SelectionChanged += masterDataGridView_SelectionChanged_1;
}
private void masterDataGridView_SelectionChanged_1(object sender, EventArgs e)
{
if (masterDataGridView.SelectedRows.Count > 0)
{
string orderNumber = Convert.ToString(masterDataGridView.SelectedRows[0].Cells["ordcol"].Value);
LoadChildData(orderNumber);
}
}
private void LoadChildData(string orderNumber)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
string query = $"SELECT * FROM ordc WHERE ord_no = ord_no";
SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);
childDataGridView.DataSource = dataTable;
}
}
}
modified 27-Jul-23 5:38am.
|
|
|
|
|
I've edited your question and added a code block - this engages the syntax highlighter, preserves the indentation, and makes it easier to read - edit it yourself and you'll see what I did (it's only a couple of clicks to do it and it makes everybody's life easier).
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OK, that's very definitely the long way round - you don't need the events as if you hook up the DataTables to the DGV correctly using BindingSources, the system will do it all for you.
Do you want me to show you how I would do it, or do you want to fix this line of code?
string query = $"SELECT * FROM ordc WHERE ord_no = ord_no";
If it's the later, then there are two ways to do it - the incredibly dangerous way you are trying to do it, and the proper way which means users can't destroy your database?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
the data from the 1st row is getting saved to the database but the 2nd row is created dainamically so the data in the newly added dainamic rows data is not saving to the database, insted it giving this error
System.Exception: 'Violation of PRIMARY KEY constraint 'PK_Timesheet'. Cannot insert duplicate key in object 'dbo.Timesheet'. The duplicate key value is (2).
The statement has been terminated.
code:
protected void SaveButton_Click(object sender, EventArgs e)
{
string EmpId = Session["EmpId"].ToString();
string StrSQL = "";
clsDB obj = new clsDB();
StrSQL = "SELECT MAX(TaskID) FROM Timesheet";
object maxTaskID = obj.GetScalar(StrSQL);
int TaskID = maxTaskID != DBNull.Value ? Convert.ToInt32(maxTaskID) + 1 : 1;
StrSQL = "INSERT INTO Timesheet ";
StrSQL += "VALUES('" + EmpId + "','" + TaskID + "','" + txttask.Text + "','" + txttaskdate.Text + "', ";
StrSQL += "'" + txtDescription.Text + "', '" + txttimetaken.Text + "')";
Result = Convert.ToInt32(obj.ExecuteNonQuery(StrSQL));
if (Result == 1)
{
string script = "alert('Data saved Successfully')";
ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
}
string message = "";
int currentTaskID = TaskID;
StrSQL = "INSERT INTO Timesheet ("+" EmployeeId, TaskId, TaskDate, TaskName, Description, TimeTaken) VALUES ";
StrSQL += "('" + EmpId + "','" + currentTaskID + "','";
foreach (TextBox textBox in pnlTextBoxes.Controls.OfType<TextBox>())
{
StrSQL += textBox.Text + "','";
}
StrSQL = StrSQL.Substring(0, StrSQL.Length - 2) + ");";
Result = Convert.ToInt32(obj.ExecuteNonQuery(StrSQL));
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('" + message + "');", true);
}
}
|
|
|
|
|
|
Read the error message, it tells you exactly what you are doing wrong.
|
|
|
|
|
Primary Key ("PK") columns must be unique in a table; they cannot have the same column value in any other row in the same table.
What I'd suggest ios that you either user UNIQUEIDENTIFIER values for your ID's and pass a new Guid to the DB from your C# code, or use an IDENTITY column in the DB, and SELECT it back to your C# code immediately after the INSERT using the SCOPE_IDENTITY function.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
protected void Page_PreInit(object sender, EventArgs e)
{
List<string> keys = Request.Form.AllKeys.Where(key => key.Contains("ltIndex")).ToList();
int i = 1;
int j = keys.Count;
j = j / 4;
for (int k = 0; k < j; k++)
{
this.CreateTextBox("ltIndex" + i);
i++;
}
protected void btnAddRow_Click(object sender, EventArgs e)
{
int index = pnlTextBoxes.Controls.OfType<textbox>().ToList().Count + 1;
this.CreateTextBox("ltIndex" + index);
}
private void CreateTextBox(string i)
{
Literal ltIndex = new Literal();
ltIndex.Text = 1 + ".";
pnlTextBoxes.Controls.Add(ltIndex);
Literal lt = new Literal();
lt.Text = "<br>";
pnlTextBoxes.Controls.Add(lt);
}
its provoiding index value as 1 for all the newly added row,its not providing autoincrementing of indexing
|
|
|
|
|
Look atg the code for CreateTextBox :
private void CreateTextBox(string i)
{
Literal ltIndex = new Literal();
ltIndex.Text = 1 + ".";
pnlTextBoxes.Controls.Add(ltIndex);
Literal lt = new Literal();
lt.Text = "<br>";
pnlTextBoxes.Controls.Add(lt);
}
|
|
|
|
|