C#.NET 或 VB.NET Windows 窗體中的 DataGridView – 技巧、竅門和常見問題

????????DataGridView 控件是一個 Windows 窗體控件,它允許您自定義和編輯表格數據。它提供了許多屬性、方法和事件來自定義其外觀和行為。在本文中,我們將討論一些常見問題及其解決方案。這些問題來自各種來源,包括一些新聞組、MSDN 網站以及一些由我在 MSDN 論壇上解答的問題。

技巧 1 – 填充 DataGridView

????????在這個簡短的代碼片段中,我們將使用 LoadData() 方法填充 DataGridView。此方法使用 SqlDataAdapter 填充 DataSet。然后將 DataSet 中的“Orders”表綁定到 BindingSource 組件,這使我們能夠靈活地選擇/修改數據位置。

C#

public partial class Form1 : Form
? ? {
? ? ? ? private SqlDataAdapter da;
? ? ? ? private SqlConnection conn;
? ? ? ? BindingSource bsource = new BindingSource();
? ? ? ? DataSet ds = null;
? ? ? ? string sql;
?
? ? ? ? public Form1()
? ? ? ? {
? ? ? ? ? ? InitializeComponent();
? ? ? ? }
?
? ? ? ? private void btnLoad_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? LoadData();
? ? ? ? }
?
? ? ? ? private void LoadData()
? ? ? ? {
string connectionString = "Data Source=localhost;Initial Catalog=Northwind;" + "Integrated Security=SSPI;";
? ? ? ? ? ? conn = new SqlConnection(connectionString);
sql = "SELECT OrderID, CustomerID, EmployeeID, OrderDate, Freight," + "ShipName, ShipCountry FROM Orders";
?
? ? ? ? ? ? da = new SqlDataAdapter(sql, conn);
? ? ? ? ? ? conn.Open();
? ? ? ? ? ? ds = new DataSet();
? ? ? ? ? ? SqlCommandBuilder commandBuilder = new SqlCommandBuilder(da); ? ? ? ? ?
? ? ? ? ? ? da.Fill(ds, "Orders");
? ? ? ? ? ? bsource.DataSource = ds.Tables["Orders"];
? ? ? ? ? ? dgv.DataSource = bsource; ? ? ? ? ?
? ? ? ? }
? ? }
?? ?
VB.NET

Public Partial Class Form1
? ? ? Inherits Form
? ? ? ? ? ? Private da As SqlDataAdapter
? ? ? ? ? ? Private conn As SqlConnection
? ? ? ? ? ? Private bsource As BindingSource = New BindingSource()
? ? ? ? ? ? Private ds As DataSet = Nothing
? ? ? ? ? ? Private sql As String
?
? ? ? ? ? ? Public Sub New()
? ? ? ? ? ? ? ? ? InitializeComponent()
? ? ? ? ? ? End Sub
?
Private Sub btnLoad_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? LoadData()
? ? ? ? ? ? End Sub
?
? ? ? ? ? ? Private Sub LoadData()
Dim connectionString As String = "Data Source=localhost;Initial Catalog=Northwind;" & "Integrated Security=SSPI;"
? ? ? ? ? ? ? ? ? conn = New SqlConnection(connectionString)
sql = "SELECT OrderID, CustomerID, EmployeeID, OrderDate, Freight," & "ShipName, ShipCountry FROM Orders"
?
? ? ? ? ? ? ? ? ? da = New SqlDataAdapter(sql, conn)
? ? ? ? ? ? ? ? ? conn.Open()
? ? ? ? ? ? ? ? ? ds = New DataSet()
Dim commandBuilder As SqlCommandBuilder = New SqlCommandBuilder(da)
? ? ? ? ? ? ? ? ? da.Fill(ds, "Orders")
? ? ? ? ? ? ? ? ? bsource.DataSource = ds.Tables("Orders")
? ? ? ? ? ? ? ? ? dgv.DataSource = bsource
? ? ? ? ? ? End Sub
End Class

技巧 2 – 更新 DataGridView 中的數據并將更改保存到數據庫中

????????編輯單元格中的數據后,如果您想在數據庫中永久更新更改,請使用以下代碼:

C#

private void btnUpdate_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? DataTable dt = ds.Tables["Orders"];
? ? ? ? ? ?this.dgv.BindingContext[dt].EndCurrentEdit();
? ? ? ? ? ? this.da.Update(dt);
? ? ? ? }
?? ??? ?
VB.NET

Private Sub btnUpdate_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? Dim dt As DataTable = ds.Tables("Orders")
? ? ? ? ? ? ? ? ? Me.dgv.BindingContext(dt).EndCurrentEdit()
? ? ? ? ? ? ? ? ? Me.da.Update(dt)
? ? ? End Sub

技巧3 – 在 DataGridView 中刪除行之前顯示確認框

????????處理 UserDeletingRow 事件,向用戶顯示確認框。如果用戶確認刪除,則刪除該行。如果用戶點擊“取消”,則設置 e.cancel = true,取消行刪除。

C#

private void dgv_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
? ? ? ? {
? ? ? ? ? ? if (!e.Row.IsNewRow)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? DialogResult res = MessageBox.Show("Are you sure you want to delete this row?", "Delete confirmation",
? ? ? ? ? ? ? ? ? ? ? ? ?MessageBoxButtons.YesNo, MessageBoxIcon.Question);
? ? ? ? ? ? ? ? if (res == DialogResult.No)
? ? ? ? ? ? ? ? ? ? e.Cancel = true;
? ? ? ? ? ? }
? ? ? ? }
?? ??? ?
VB.NET

Private Sub dgv_UserDeletingRow(ByVal sender As Object, ByVal e As DataGridViewRowCancelEventArgs)
? ? ? ? ? ? ? ? ? If (Not e.Row.IsNewRow) Then
? ? ? ? ? ? ? ? ? ? ? ? Dim res As DialogResult = MessageBox.Show("Are you sure you want to delete this row?", "Delete confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
? ? ? ? ? ? ? ? ? ? ? ? If res = DialogResult.No Then
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? e.Cancel = True
? ? ? ? ? ? ? ? ? ? ? ? End If
? ? ? ? ? ? ? ? ? End If
End Sub

技巧 4 – 如何自動調整 DataGridView 中的列寬

????????下面的代碼片段首先自動調整列的大小以適應其內容。然后將 AutoSizeColumnsMode 設置為“DataGridViewAutoSizeColumnsMode.AllCells”枚舉值,以便在數據發生變化時自動調整列的寬度。

C#

private void btnResize_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? dgv.AutoResizeColumns();
? ? ? ? ? ? dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
?
? ? ? ? }
?? ??? ?
VB.NET

Private Sub btnResize_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? dgv.AutoResizeColumns()
? ? ? ? ? ? ? ? ? dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
?
End Sub

技巧 5 - 在 DataGridView 中選擇并突出顯示整行

C#

int rowToBeSelected = 3; // third row
if (dgv.Rows.Count >= rowToBeSelected)
{ ? ? ? ? ? ??
? ? ? ?// Since index is zero based, you have to subtract 1
? ? ? ? dgv.Rows[rowToBeSelected - 1].Selected = true;
}

VB.NET

Dim rowToBeSelected As Integer = 3 ' third row
If dgv.Rows.Count >= rowToBeSelected Then
? ? ? ? ?' Since index is zero based, you have to subtract 1
? ? ? ? ? ? dgv.Rows(rowToBeSelected - 1).Selected = True
End If

技巧 6 - 如何以編程方式滾動到 DataGridView 中的某一行

????????DataGridView 有一個名為 FirstDisplayedScrollingRowIndex 的屬性,可用于以編程方式滾動到某一行。

C#

int jumpToRow = 20;
if (dgv.Rows.Count >= jumpToRow && jumpToRow >= 1)
{ ? ? ? ? ? ??
? ? ? ? dgv.FirstDisplayedScrollingRowIndex = jumpToRow;
? ? ? ? dgv.Rows[jumpToRow].Selected = true;
}
?
VB.NET

Dim jumpToRow As Integer = 20
If dgv.Rows.Count >= jumpToRow AndAlso jumpToRow >= 1 Then
? ? ? ? ? ? dgv.FirstDisplayedScrollingRowIndex = jumpToRow
? ? ? ? ? ? dgv.Rows(jumpToRow).Selected = True
End If

技巧 7 - 計算 DataGridView 中的列總數并顯示在文本框中

????????一個常見的需求是計算貨幣字段的總計并將其顯示在文本框中。在下面的代碼片段中,我們將計算“運費”字段的總計。然后,我們將在顯示數據的同時,通過格式化結果(觀察ToString( "c" ) )將數據顯示在文本框中,該文本框會顯示特定于文化的貨幣。

C#

private void btnTotal_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? if(dgv.Rows.Count > 0)
? ? ? ? ? ? ?txtTotal.Text = Total().ToString("c");
? ? ? ? }
?
? ? ? ? private double Total()
? ? ? ? {
? ? ? ? ? ? double tot = 0;
? ? ? ? ? ? int i = 0;
? ? ? ? ? ? for (i = 0; i < dgv.Rows.Count; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? tot = tot + Convert.ToDouble(dgv.Rows[i].Cells["Freight"].Value);
? ? ? ? ? ? }
? ? ? ? ? ? return tot;
? ? ? ? }
?? ??? ?
VB.NET

Private Sub btnTotal_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? If dgv.Rows.Count > 0 Then
? ? ? ? ? ? ? ? ? ?txtTotal.Text = Total().ToString("c")
? ? ? ? ? ? ? ? ? End If
End Sub
?
Private Function Total() As Double
? ? ? ? ? ? ? ? ? Dim tot As Double = 0
? ? ? ? ? ? ? ? ? Dim i As Integer = 0
? ? ? ? ? ? ? ? ? For i = 0 To dgv.Rows.Count - 1
? ? ? ? ? ? ? ? ? ? ? ? tot = tot + Convert.ToDouble(dgv.Rows(i).Cells("Freight").Value)
? ? ? ? ? ? ? ? ? Next i
? ? ? ? ? ? ? ? ? Return tot
End Function

技巧 8 - 更改 DataGridView 中的標題名稱

????????如果從數據庫檢索的列沒有有意義的名稱,我們始終可以選擇更改標題名稱,如下段所示:

C#

private void btnChange_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? dgv.Columns[0].HeaderText = "MyHeader1";
? ? ? ? ? ? dgv.Columns[1].HeaderText = "MyHeader2";
? ? ? ? }
?
VB.NET

Private Sub btnChange_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? dgv.Columns(0).HeaderText = "MyHeader1"
? ? ? ? ? ? ? ? ? dgv.Columns(1).HeaderText = "MyHeader2"
End Sub

技巧 9 - 更改 DataGridView 中單元格、行和邊框的顏色

C#

private void btnCellRow_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? // Change ForeColor of each Cell
? ? ? ? ? ? this.dgv.DefaultCellStyle.ForeColor = Color.Coral;
? ? ? ? ? ? // Change back color of each row
? ? ? ? ? ? this.dgv.RowsDefaultCellStyle.BackColor = Color.AliceBlue;
? ? ? ? ? ? // Change GridLine Color
? ? ? ? ? ? this.dgv.GridColor = Color.Blue;
? ? ? ? ? ? // Change Grid Border Style
? ? ? ? ? ? this.dgv.BorderStyle = BorderStyle.Fixed3D;
? ? ? ? }

VB.NET

Private Sub btnCellRow_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? ' Change ForeColor of each Cell
? ? ? ? ? ? ? ? ? Me.dgv.DefaultCellStyle.ForeColor = Color.Coral
? ? ? ? ? ? ? ? ? ' Change back color of each row
? ? ? ? ? ? ? ? ? Me.dgv.RowsDefaultCellStyle.BackColor = Color.AliceBlue
? ? ? ? ? ? ? ? ? ' Change GridLine Color
? ? ? ? ? ? ? ? ? Me.dgv.GridColor = Color.Blue
? ? ? ? ? ? ? ? ? ' Change Grid Border Style
? ? ? ? ? ? ? ? ? Me.dgv.BorderStyle = BorderStyle.Fixed3D
End Sub

技巧 10 - 隱藏 DataGridView 中的列

????????如果您想根據特定條件隱藏某一列,這里有一個代碼片段。

C#

private void btnHide_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? this.dgv.Columns["EmployeeID"].Visible = false;
? ? ? ? }

VB.NET

Private Sub btnHide_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? Me.dgv.Columns("EmployeeID").Visible = False
End Sub

技巧 11 - 處理 DataGridView 中 ComboBox 的 SelectedIndexChanged

????????要處理 DataGridViewComboBox 的 SelectedIndexChanged 事件,您需要使用 DataGridView.EditingControlShowing 事件,如下所示。然后,您可以檢索組合框的選定索引或選定文本。

C#

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
? ? ? ? {
? ? ? ? ? ? ComboBox editingComboBox = (ComboBox)e.Control;
? ? ? ? ? ? if(editingComboBox != null)
? ? ? ? ? ? ? ? editingComboBox.SelectedIndexChanged += new System.EventHandler(this.editingComboBox_SelectedIndexChanged);
? ? ? ? }
?? ??? ?
private void editingComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
? ? ? ? {
? ? ? ? ? ? ComboBox comboBox1 = (ComboBox)sender;
? ? ? ? ? ? // Display index
? ? ? ? ? ? MessageBox.Show(comboBox1.SelectedIndex.ToString());
? ? ? ? ? ? // Display value
? ? ? ? ? ? MessageBox.Show(comboBox1.Text);
? ? ? ? }

VB.NET

Private Sub dataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs)
? ? ? ? ? ? ? ? ? Dim editingComboBox As ComboBox = CType(e.Control, ComboBox)
? ? ? ? ? ? ? ? ? If Not editingComboBox Is Nothing Then
? ? ? ? ? ? ? ? ? ? ? ? AddHandler editingComboBox.SelectedIndexChanged, AddressOf editingComboBox_SelectedIndexChanged
? ? ? ? ? ? ? ? ? End If
End Sub
?
Private Sub editingComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
? ? ? ? ? ? ? ? ? Dim comboBox1 As ComboBox = CType(sender, ComboBox)
? ? ? ? ? ? ? ? ? ' Display index
? ? ? ? ? ? ? ? ? MessageBox.Show(comboBox1.SelectedIndex.ToString())
? ? ? ? ? ? ? ? ? ' Display value
? ? ? ? ? ? ? ? ? MessageBox.Show(comboBox1.Text)
End Sub

技巧 12 - 更改 DataGridView 中交替行的顏色

C#

private void btnAlternate_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? this.dgv.RowsDefaultCellStyle.BackColor = Color.White;
? ? ? ? ? ? this.dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.Aquamarine;
? ? ? ? }

VB.NET

Private Sub btnAlternate_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? Me.dgv.RowsDefaultCellStyle.BackColor = Color.White
? ? ? ? ? ? ? ? ? Me.dgv.AlternatingRowsDefaultCellStyle.BackColor = Color.Aquamarine
End Sub

技巧 13 - 在 DataGridView 中格式化數據

????????DataGridView 公開了一些屬性,使您能夠格式化數據,例如以特定文化的貨幣顯示貨幣列或以所需的格式顯示空值等等。

C#

private void btnFormat_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? // display currency in culture-specific currency for
? ? ? ? ? ? this.dgv.Columns["Freight"].DefaultCellStyle.Format = "c";
? ? ? ? ? ? // display nulls as 'NA'
? ? ? ? ? ? this.dgv.DefaultCellStyle.NullValue = "NA";
? ? ? ? }

VB.NET

Private Sub btnFormat_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? ' display currency in culture-specific currency for
? ? ? ? ? ? ? ? ? Me.dgv.Columns("Freight").DefaultCellStyle.Format = "c"
? ? ? ? ? ? ? ? ? ' display nulls as 'NA'
? ? ? ? ? ? ? ? ? Me.dgv.DefaultCellStyle.NullValue = "NA"
End Sub

技巧 14 – 更改 DataGridView 中的列順序

????????要更改列的順序,只需將 DataGridView 的 DisplayIndex 屬性設置為所需的值。請記住,索引從零開始。

C#

private void btnReorder_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? ?dgv.Columns["CustomerID"].DisplayIndex = 5;
? ? ? ? ? ? ?dgv.Columns["OrderID"].DisplayIndex = 3;
? ? ? ? ? ? ?dgv.Columns["EmployeeID"].DisplayIndex = 1;
? ? ? ? ? ? ?dgv.Columns["OrderDate"].DisplayIndex = 2;
? ? ? ? ? ? ?dgv.Columns["Freight"].DisplayIndex = 6;
? ? ? ? ? ? ?dgv.Columns["ShipCountry"].DisplayIndex = 0;
? ? ? ? ? ? ?dgv.Columns["ShipName"].DisplayIndex = 4;
? ? ? ? }

VB.NET

Private Sub btnReorder_Click(ByVal sender As Object, ByVal e As EventArgs)
? ? ? ? ? ? ? ? ? ?dgv.Columns("CustomerID").DisplayIndex = 5
? ? ? ? ? ? ? ? ? ?dgv.Columns("OrderID").DisplayIndex = 3
? ? ? ? ? ? ? ? ? ?dgv.Columns("EmployeeID").DisplayIndex = 1
? ? ? ? ? ? ? ? ? ?dgv.Columns("OrderDate").DisplayIndex = 2
? ? ? ? ? ? ? ? ? ?dgv.Columns("Freight").DisplayIndex = 6
? ? ? ? ? ? ? ? ? ?dgv.Columns("ShipCountry").DisplayIndex = 0
? ? ? ? ? ? ? ? ? ?dgv.Columns("ShipName").DisplayIndex = 4
End Sub
?
我希望這篇文章對您有用,并感謝您的閱讀。

如果您喜歡此文章,請收藏、點贊、評論,謝謝,祝您快樂每一天。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/905660.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/905660.shtml
英文地址,請注明出處:http://en.pswp.cn/news/905660.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

表記錄的檢索

1.select語句的語法格式 select 字段列表 from 表名 where 條件表達式 group by 分組字段 [having 條件表達式] order by 排序字段 [asc|desc];說明&#xff1a; from 子句用于指定檢索的數據源 where子句用于指定記錄的過濾條件 group by 子句用于對檢索的數據進行分組 ha…

能源設備數據采集

在全球可持續發展目標與環境保護理念日益深入人心的時代背景下&#xff0c;有效管理和優化能源使用已成為企業實現綠色轉型、提升競爭力的關鍵路徑。能源設備數據采集系統&#xff0c;作為能源管理的核心技術支撐&#xff0c;通過對各類能源生產設備運行數據的全面收集、深度分…

【鴻蒙開發】性能優化

語言層面的優化 使用明確的數據類型&#xff0c;避免使用模糊的數據類型&#xff0c;例如ESObject。 使用AOT模式 AOT就是提前編譯&#xff0c;將字節碼提前編譯成機器碼&#xff0c;這樣可以充分優化&#xff0c;從而加快執行速度。 未啟用AOT時&#xff0c;一邊運行一邊進…

群暉NAS部署PlaylistDL音樂下載器結合cpolar搭建私有云音樂庫

文章目錄 前言1.關于PlaylistDL音樂下載器2.Docker部署3.PlaylistDL簡單使用4.群暉安裝Cpolar工具5.創建PlaylistDL音樂下載器的公網地址6.配置固定公網地址總結 前言 各位小伙伴們&#xff0c;你們是不是經常為了聽幾首歌而開通各種平臺的VIP&#xff1f;或者為了下載無損音質…

REST架構風格介紹

一.REST&#xff08;表述性狀態轉移&#xff09; 1.定義 REST&#xff08;Representational State Transfer&#xff09;是由 Roy Fielding 在 2000 年提出的一種軟件架構風格&#xff0c;用于設計網絡應用的通信模式。它基于 HTTP 協議&#xff0c;強調通過統一的接口&#…

計算機視覺----基于錨點的車道線檢測、從Line-CNN到CLRNet到CLRKDNet 本文所提算法Line-CNN 后續會更新以下全部算法

本文所提算法如下&#xff1a; 敘述按時間順序 你也可以把本文當作快速閱讀這幾篇文獻的一個途徑 所有重要的部分我都已經標注并弄懂其原理 方便自己也是方便大家 Line-CNN&#xff1a;基于線提議單元的端到端交通線檢測 摘要 交通線檢測是一項基礎且具有挑戰性的任務。以往的…

一.android Studio開發系統應用——導入TvSettings源碼

目標 最終效果如上,實現在AS中編輯源碼后一鍵在真機中運行。達到和普通應用開發一樣的調試和編碼過程。這種方法可以大幅度提升開發速度,但是導入過程確實相對繁瑣和消耗時間。適合需要精細或者頻繁改動的系統app源碼。 一、新建項目 包名:com.android.tv.settings 版本:…

20250515讓飛凌的OK3588-C的核心板在Linux R4下適配以太網RTL8211F-CG為4線百兆時的接線圖

20250515讓飛凌的OK3588-C的核心板在Linux R4下適配以太網RTL8211F-CG為4線百兆時的接線圖 2025/5/15 20:19 緣起&#xff1a;以前做的網線找不到了&#xff0c;那就再來一條吧。 引腳定義要從頭來過&#xff1f;還好找到了一條。 開干&#xff01; 萬用表一對/點&#xff0c;幾…

【技術原理】Linux 文件時間屬性詳解:Access、Modify、Change 的區別與聯系

在 Linux 系統中&#xff0c;每個文件都有三個核心時間屬性&#xff1a;Access Time (atime)、Modify Time (mtime) 和 Change Time (ctime)。它們分別記錄文件不同維度的變更信息&#xff0c;以下是具體區別與聯系&#xff1a; 一、定義與觸發條件 時間屬性定義觸發條件示例A…

乘法口訣練習神器

請你利用python語言開發一個“乘法口訣練習神器”&#xff0c;主要輔助小學生練習乘法口訣&#xff0c;主要功能如下&#xff1a; 1. 能夠隨機循環出10道題&#xff0c;可以是乘法或者是除法。如果是乘法&#xff0c;確保兩個因數都是1-9之間的整數&#xff1b;如果是除法&…

[c語言日寄]數據結構:棧

【作者主頁】siy2333 【專欄介紹】?c語言日寄?&#xff1a;這是一個專注于C語言刷題的專欄&#xff0c;精選題目&#xff0c;搭配詳細題解、拓展算法。從基礎語法到復雜算法&#xff0c;題目涉及的知識點全面覆蓋&#xff0c;助力你系統提升。無論你是初學者&#xff0c;還是…

磁盤I/O瓶頸排查:面試通關“三部曲”心法

想象一下&#xff0c;你就是線上系統的“交通調度總指揮”&#xff0c;服務器的磁盤是所有數據進出的“核心樞紐港口”。當這個“港口”突然擁堵不堪&#xff0c;卡車&#xff08;數據請求&#xff09;排起長龍&#xff0c;進不去也出不來&#xff0c;整個系統的“物流”&#…

基于大模型預測胃穿孔預測與圍手術期管理系統技術方案

目錄 1. 系統架構模塊2. 關鍵算法實現2.1 術前預測模型(Transformer多模態融合)2.2 術中實時分析(在線學習LSTM)3. 模塊流程圖(Mermaid)3.1 數據預處理系統3.2 術前預測系統3.3 術中實時分析系統4. 技術驗證模塊4.1 模型可解釋性驗證4.2 邊緣計算部署架構1. 系統架構模塊…

C++:類和對象4

一&#xff0c;日期類實現 學習建議&#xff1a; 對于計算機學習來說&#xff0c;調試十分重要&#xff0c;所以在日常學習中一定要加大代碼練習&#xff0c;刷代碼題和課后自己敲出課上代碼例題&#xff0c;注意不要去對比正確代碼或者網上找正確代碼直接使用&#xff0c;一…

大數據架構選型分析

選擇依據 1.業務需求與技術要求 用戶需要根據自己的業務需求來選擇架構&#xff0c;如果業務對于Hadoop、Spark、Strom等關鍵技術有強制性依賴&#xff0c;選擇Lambda架構可能較為合適&#xff1b;如果處理數據偏好于流式計算&#xff0c;又依賴Flink計算引擎&#xff0c;那么…

Trae 插件 Builder 模式:從 0 到 1 開發天氣查詢小程序,解鎖 AI 編程新體驗

在軟件開發領域&#xff0c;效率與創新始終是開發者追求的核心目標。Trae 插件&#xff08;原 MarsCode 編程助手&#xff09;Builder 模式的全面上線&#xff0c;無疑為開發者帶來了全新的解決方案。它不僅同時支持 VS Code、JetBrains IDEs 等主流開發環境&#xff0c;還能讓…

SSM項目集成redis、Linux服務器安裝redis

在SSM&#xff08;Spring Spring MVC MyBatis&#xff09;項目中引入Redis主要分為以下步驟&#xff0c;確保配置正確并能在業務中靈活使用&#xff1a; 1. 添加Redis依賴?? 在Maven的pom.xml中添加Spring Data Redis和Jedis&#xff08;或Lettuce&#xff09;依賴&#…

【Redis】壓縮列表

目錄 1、背景2、壓縮列表【1】底層結構【2】特性【3】優缺點 1、背景 ziplist&#xff08;壓縮列表&#xff09;是redis中一種特殊編碼的雙向鏈表數據結構&#xff0c;主要用于存儲小型列表和哈希表。它通過緊湊的內存布局和特殊的編碼方式來節省內存空間。 2、壓縮列表 【1…

LocalDateTime類型的時間在前端頁面不顯示或者修改數據時因為LocalDateTime導致無法修改,解決方案

1.數據庫中的時間數據&#xff0c;在控制臺可以正常返回&#xff0c;在前端無法返回&#xff0c;即顯示空白&#xff0c;如下圖所示: 2.這種問題一般時由于數據庫和我們實體類的名稱不一致引起的&#xff0c;我們數據庫一般采用_的方式命名&#xff0c;但是在Java中我們一般采用…

Spring框架核心技術深度解析:JDBC模板、模擬轉賬與事務管理

一、JDBC模板技術&#xff1a;簡化數據庫操作 在傳統JDBC開發中&#xff0c;繁瑣的資源管理和重復代碼一直是開發者的痛點。Spring框架提供的 JDBC模板&#xff08;JdbcTemplate) 徹底改變了這一現狀&#xff0c;它通過封裝底層JDBC操作&#xff0c;讓開發者僅需關注SQL邏輯&a…